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

eslint-config-spreetail

Package Overview
Dependencies
Maintainers
2
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.

  • 2.2.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

eslint-config-spreetail

This package provides an extensible ESLint configuration used at 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 project's .eslintrc file:

{
    "extends":  "spreetail"
}

If you are using ES6 modules, be sure to add "sourceType": "module" to a "parserOptions" section of your project's .eslintrc file as well:

{
    "parserOptions": {
        "sourceType": "module"
    }
}

Rules

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. Therefore, it may be a bit less strict than other configurations.

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

This will throw an error.

no-obj-calls

This is not allowed as of ES5.

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 confusing.

consistent-return*

This is almost certainly a mistake.

curly

Omitting curly braces can lead to code that does not behave as expected. 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. The smart option for this rule is enabled.

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.

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(), they are extremely rare, and eval() can be dangerous.

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.

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.

no-octal-escape

This is deprecated as of ES5.

no-proto

This is deprecated as of ES3.1.

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 inferred 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.

// 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. Use semicolons instead of relying on ASI.

ECMAScript 6

constructor-super

This will raise a runtime error.

no-class-assign*

This is almost certainly a mistake.

no-const-assign

This will raise a runtime error.

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.

no-this-before-super

This raises a reference error.

no-useless-computed-key*

This is almost certainly a mistake.

no-var*

var behavior can be confusing and unexpected. 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.

License

Licensed under the MIT License.

Keywords

FAQs

Package last updated on 18 Oct 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