Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-config-spreetail

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-config-spreetail

ESLint configuration used at Spreetail.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

eslint-config-spreetail

This package provides an extensible eslint configuration used by Spreetail.

This is intended for use with ES6+ projects.

Installation

You will need eslint installed.

This package can be installed from npm:

npm install eslint-config-spreetail --save-dev

Usage

Once installed, add "extends": "spreetail" to your .eslintrc file:

{
    "extends":  "spreetail"
}

Explanations

Every rule in the configuration should be documented here with an explanation of its inclusion. It's important to include only rules with clear benefits and avoid rules which amount to little more than personal preference. The purpose of this configuration is to aid developers rather than to coerce conformity.

Rules with an asterisk (*) will issue warnings rather than errors.

Possible Errors

no-await-in-loop

This will lead to poor performance. Use Promise.all() instead.

no-constant-condition*

This is almost certainly a mistake.

no-compare-neg-zero

Comparing to -0 will pass for 0 and -0 which is confusing.

no-dupe-args*

This is almost certainly a mistake.

no-dupe-keys*

This is almost certainly a mistake.

no-duplicate-case*

This is almost certainly a mistake.

no-empty*

Empty block statements are almost certainly unintentional and may be a sign of incomplete code.

no-empty-character-class*

Empty character classes won't match anything and are probably just a sign of unfinished regex.

no-ex-assign

Reassigning to an exception in a catch block is destructive.

no-extra-semi*

This is almost certainly a mistake.

no-func-assign

Reassigning a function declaration (outside of the function itself) is probably a mistake and otherwise will lead to extremely confusing code.

no-invalid-regexp

These will throw errors anyway.

no-obj-calls

This is not allowed as of ES5 anyway.

no-prototype-builtins

It's not safe to assume the default Object.prototype methods are accessible by every object since it's possible to create objects without the default prototype.

no-sparse-arrays*

This is almost certainly a mistake.

no-template-curly-in-string*

This is almost certainly a mistake. Backticks (`) were probably intended.

no-unexpected-multiline

This may not behave as expected due to automatic semicolon insertion.

no-unreachable*

This is almost certainly a mistake.

no-unsafe-finally

This does not behave as expected.

no-unsafe-negation*

This is almost certainly a mistake.

use-isnan

Comparisons directly to NaN do not behave as expected.

valid-typeof*

This is almost certainly a mistake.

Best Practices

array-callback-return*

This is almost certainly a mistake.

block-scoped-var

var scoping is broken and confusing. This rules prevents accidental usage.

consistent-return*

This is almost certainly a mistake.

curly

Omitting curly braces can lead to extremely confusing code. For example:

if (foo)
    bar();
    baz();

This is actually equivalent to:

if (foo) {
    bar();
}
baz();

Any benefits of omitting curly braces is surely outweighed by the potential for confusion.

eqeqeq

The == and != operators use type coercion which may not behave as expected. Be explicit and use === and !== instead.

no-alert

The default alert, confirm, and prompt UI elements will block the event loop (not to mention they are horrid).

no-caller

This is not allowed as of ES5 anyway.

no-case-declarations

This does not behave as expected.

no-div-regex*

This is almost certainly a mistake.

no-empty-function*

This is almost certainly a mistake.

no-empty-pattern*

This is almost certainly a mistake.

no-eq-null

This does not behave as expected.

no-eval

While there may be valid use cases for eval(), you probably aren't writing one of them.

no-extend-native

Modifying built-in prototypes can cause conflicts with other scripts and libraries. Use a function instead:

// Bad
String.prototype.getLength = function() {
    return this.length;
}
const helloLength = 'hello'.getLength();

// Good
function getStringLength(string) {
    return string.length;
}
const helloLength = getStringLength('hello');
no-extra-bind*

This is almost certainly a mistake.

no-fallthrough*

This is far more likely to be a mistake than intentional.

no-global-assign*

This is almost certainly a mistake.

no-implicit-globals*

This may conflict with other scripts and libraries and should be avoided.

no-implied-eval

See no-eval.

no-invalid-this

This will throw an error in strict mode anyway.

no-iterator

This is obsolete as of ES6.

no-lone-blocks

This is almost certainly a mistake.

no-loop-func

This does not behave as expected.

no-new

new should only be used with constructors.

no-new-func

See no-eval.

no-new-wrappers

This does not behave as expected.

no-octal

This is deprecated as of ES5 anyway.

no-octal-escape

This is deprecated as of ES5 anyway.

no-proto

This is deprecated as of ES3.1 anyway.

no-redeclare*

This is almost certainly a mistake.

no-return-await*

This is almost certainly a mistake.

no-script-url

See no-eval.

no-self-assign*

This is almost certainly a mistake.

no-self-compare*

This is almost certainly a mistake.

no-sequences*

This is more likely to be a mistake than intentional.

no-throw-literal

Only Error objects should be thrown, as they provide information about where they originated.

no-unmodified-loop-condition*

This is almost certainly a mistake.

no-unused-expressions*

This is almost certainly a mistake.

no-useless-escape*

This is almost certainly a mistake.

no-with

This is too ambiguous. Use a new variable instead:

my.really.long.variable.has.some.properties.named = {
    thing1: 'and',
    thing2: '!'
};

// BAD
with (my.really.long.variable.has.some.properties.named) {
    console.log(thing1, thing2);
}

// GOOD
const named = my.really.long.variable.has.some.properties.named;
console.log(named.thing1, named.thing2);
prefer-promise-reject-errors

Promises should always reject with an Error object so the consumers know exactly what to expect. Additionally, Error objects provide information about where they originated.

radix

Calling parseInt() with a string that starts with '0' will force evaluation as an octal, which is almost certainly a mistake. Always pass the intended radix parameter (probably 10):

// BAD
parseInt('071'); // returns 57

// GOOD
parseInt('071', 10); // returns 71
require-await*

This is almost certainly a mistake.

wrap-iife

Attempting to immediately execute a function declaration will cause a SyntaxError. This should be wrapped in parentheses instead.

Strict Mode

strict

This should be in strict mode.

Variables

no-undef*

This is almost certainly a mistake (or perhaps you need to specify your project's environment or its globals in your .eslintrc file).

no-undefined

This may not behave as expected. Use typeof myVar === 'undefined' instead.

no-unused-vars*

This is almost certainly a mistake.

no-use-before-define*

var hoisting can lead to confusing code. If variables are used before they are declared, it may be indicative of a mistake.

Stylistic Issues

brace-style

In most cases, curly brace placement is a matter of personal preference (and such rules do not belong is this configuration). However, there is one situation in which curly brace placement may alter the behavior of code:

// BAD
function getValue()
{
    return
    {
        value: 'here it is!'
    };
}

Due to automatic semicolon insertion, in this example a semicolon will be replaced after the return statement and getValue() will actually return undefined, not the object that was probably intended to be returned. For this reason, the one true brace style is enforced by this configuration. Turn it off if you must.

// GOOD
function getValue() {
    return {
        value: 'here it is!'
    };
}
comma-dangle

This is for the sole purpose of generating cleaner git diffs.

new-cap*

Only constructors should begin with a capital letter to act as a visual differentiator between constructors and other functions or properties.

no-array-constructor

This may not behave as expected. For example:

// BAD
const myArray = new Array(1, 2); // [1, 2]

const myOtherArray = new Array(3); // [undefined, undefined, undefined]

Use array literals ([]) instead:

// GOOD
const myArray = [1, 2]; // [1, 2]

const myOtherArray = [3]; // [3]
semi

Automatic semicolon insertion may not behave as expected.

ECMAScript 6

constructor-super

This will raise a runtime error anyway.

no-class-assign*

This is almost certainly a mistake.

no-const-assign

This will raise a runtime error anyway.

no-dupe-class-members*

This is almost certainly a mistake.

no-duplicate-imports*

This is almost certainly a mistake.

no-new-symbol

This will throw a TypeError anyway.

no-this-before-super

This raises a reference error anyway.

no-useless-computed-key*

This is almost certainly a mistake.

no-var*

var behavior can be confusing and may not behave as expected. Use const or let instead. See this article for more information.

prefer-rest-params

The arguments object does not behave as expected. It is "array-like" rather than a real array. Instead of using arguments, use rest parameters.

require-yield*

This is almost certainly a mistake.

symbol-description

This will throw a TypeError anyway.

License

Licensed under the MIT License.

Keywords

FAQs

Package last updated on 26 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc