jluchiji/node-ignis

View on GitHub
src/core.js

Summary

Maintainability
A
3 hrs
Test Coverage

Function __init has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async __init() {

    /* Prepare to toposort */
    const graph = [ ];

Severity: Minor
Found in src/core.js - About 1 hr to fix

    Function use has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      use(service) {
    
        /* Handle ES6 modules */
        if (service.__esModule) { service = service.default; }
    
    
    Severity: Minor
    Found in src/core.js - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function __init has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      async __init() {
    
        /* Prepare to toposort */
        const graph = [ ];
    
    
    Severity: Minor
    Found in src/core.js - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    There should be no space after '['.
    Open

          let deps = Service.meta(service[$$base], 'deps') || [ ];
    Severity: Minor
    Found in src/core.js by eslint

    Disallow or enforce spaces inside of brackets (array-bracket-spacing)

    A number of style guides require or disallow spaces between array brackets and other tokens. This rule applies to both array literals and destructuring assignments (ECMAScript 6).

    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var [ x, y ] = z;
    
    var arr = ['foo', 'bar'];
    var [x,y] = z;

    Rule Details

    This rule enforces consistent spacing inside array brackets.

    Options

    This rule has a string option:

    • "never" (default) disallows spaces inside array brackets
    • "always" requires one or more spaces or newlines inside array brackets

    This rule has an object option for exceptions to the "never" option:

    • "singleValue": true requires one or more spaces or newlines inside brackets of array literals that contain a single element
    • "objectsInArrays": true requires one or more spaces or newlines between brackets of array literals and braces of their object literal elements [ { or } ]
    • "arraysInArrays": true requires one or more spaces or newlines between brackets of array literals and brackets of their array literal elements [ [ or ] ]

    This rule has an object option for exceptions to the "always" option:

    • "singleValue": false disallows spaces inside brackets of array literals that contain a single element
    • "objectsInArrays": false disallows spaces between brackets of array literals and braces of their object literal elements [{ or }]
    • "arraysInArrays": false disallows spaces between brackets of array literals and brackets of their array literal elements [[ or ]]

    This rule has built-in exceptions:

    • "never" (and also the exceptions to the "always" option) allows newlines inside array brackets, because this is a common pattern
    • "always" does not require spaces or newlines in empty array literals []

    never

    Examples of incorrect code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar'];
    var arr = [[ 'foo' ], 'bar'];
    var arr = [ 'foo',
      'bar'
    ];
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    Examples of correct code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = ['foo', 'bar', 'baz'];
    var arr = [['foo'], 'bar', 'baz'];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    always

    Examples of incorrect code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = ['foo', 'bar'];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar' ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    Examples of correct code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = [ 'foo', 'bar', 'baz' ];
    var arr = [ [ 'foo' ], 'bar', 'baz' ];
    var arr = [ 'foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar' ];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    singleValue

    Examples of incorrect code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = [ 'foo' ];
    var foo = [ 'foo'];
    var foo = ['foo' ];
    var foo = [ 1 ];
    var foo = [ 1];
    var foo = [1 ];
    var foo = [ [ 1, 2 ] ];
    var foo = [ { 'foo': 'bar' } ];

    Examples of correct code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = ['foo'];
    var foo = [1];
    var foo = [[ 1, 1 ]];
    var foo = [{ 'foo': 'bar' }];

    objectsInArrays

    Examples of incorrect code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [ { 'foo': 'bar' } ];
    var arr = [ {
      'foo': 'bar'
    } ]

    Examples of correct code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [{ 'foo': 'bar' }];
    var arr = [{
      'foo': 'bar'
    }];

    arraysInArrays

    Examples of incorrect code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [ [ 1, 2 ], 2, 3, 4 ];
    var arr = [ [ 1, 2 ], 2, [ 3, 4 ] ];

    Examples of correct code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [[ 1, 2 ], 2, 3, 4 ];
    var arr = [[ 1, 2 ], 2, [ 3, 4 ]];

    When Not To Use It

    You can turn this rule off if you are not concerned with the consistency of spacing between array brackets.

    Related Rules

    • [space-in-parens](space-in-parens.md)
    • [object-curly-spacing](object-curly-spacing.md)
    • [computed-property-spacing](computed-property-spacing.md) Source: http://eslint.org/docs/rules/

    Unexpected string concatenation.
    Open

            debug(Chalk.bold.cyan('skip') + ` ${service.name}`);
    Severity: Minor
    Found in src/core.js by eslint

    Suggest using template literals instead of string concatenation. (prefer-template)

    In ES2015 (ES6), we can use template literals instead of string concatenation.

    var str = "Hello, " + name + "!";
    /*eslint-env es6*/
    
    var str = `Hello, ${name}!`;

    Rule Details

    This rule is aimed to flag usage of + operators with strings.

    Examples

    Examples of incorrect code for this rule:

    /*eslint prefer-template: "error"*/
    
    var str = "Hello, " + name + "!";
    var str = "Time: " + (12 * 60 * 60 * 1000);

    Examples of correct code for this rule:

    /*eslint prefer-template: "error"*/
    /*eslint-env es6*/
    
    var str = "Hello World!";
    var str = `Hello, ${name}!`;
    var str = `Time: ${12 * 60 * 60 * 1000}`;
    
    // This is reported by `no-useless-concat`.
    var str = "Hello, " + "World!";

    When Not To Use It

    This rule should not be used in ES3/5 environments.

    In ES2015 (ES6) or later, if you don't want to be notified about string concatenation, you can safely disable this rule.

    Related Rules

    There should be no space after '['.
    Open

          for (const dep of deps) { graph.push([ dep, name ]); }
    Severity: Minor
    Found in src/core.js by eslint

    Disallow or enforce spaces inside of brackets (array-bracket-spacing)

    A number of style guides require or disallow spaces between array brackets and other tokens. This rule applies to both array literals and destructuring assignments (ECMAScript 6).

    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var [ x, y ] = z;
    
    var arr = ['foo', 'bar'];
    var [x,y] = z;

    Rule Details

    This rule enforces consistent spacing inside array brackets.

    Options

    This rule has a string option:

    • "never" (default) disallows spaces inside array brackets
    • "always" requires one or more spaces or newlines inside array brackets

    This rule has an object option for exceptions to the "never" option:

    • "singleValue": true requires one or more spaces or newlines inside brackets of array literals that contain a single element
    • "objectsInArrays": true requires one or more spaces or newlines between brackets of array literals and braces of their object literal elements [ { or } ]
    • "arraysInArrays": true requires one or more spaces or newlines between brackets of array literals and brackets of their array literal elements [ [ or ] ]

    This rule has an object option for exceptions to the "always" option:

    • "singleValue": false disallows spaces inside brackets of array literals that contain a single element
    • "objectsInArrays": false disallows spaces between brackets of array literals and braces of their object literal elements [{ or }]
    • "arraysInArrays": false disallows spaces between brackets of array literals and brackets of their array literal elements [[ or ]]

    This rule has built-in exceptions:

    • "never" (and also the exceptions to the "always" option) allows newlines inside array brackets, because this is a common pattern
    • "always" does not require spaces or newlines in empty array literals []

    never

    Examples of incorrect code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar'];
    var arr = [[ 'foo' ], 'bar'];
    var arr = [ 'foo',
      'bar'
    ];
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    Examples of correct code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = ['foo', 'bar', 'baz'];
    var arr = [['foo'], 'bar', 'baz'];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    always

    Examples of incorrect code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = ['foo', 'bar'];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar' ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    Examples of correct code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = [ 'foo', 'bar', 'baz' ];
    var arr = [ [ 'foo' ], 'bar', 'baz' ];
    var arr = [ 'foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar' ];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    singleValue

    Examples of incorrect code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = [ 'foo' ];
    var foo = [ 'foo'];
    var foo = ['foo' ];
    var foo = [ 1 ];
    var foo = [ 1];
    var foo = [1 ];
    var foo = [ [ 1, 2 ] ];
    var foo = [ { 'foo': 'bar' } ];

    Examples of correct code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = ['foo'];
    var foo = [1];
    var foo = [[ 1, 1 ]];
    var foo = [{ 'foo': 'bar' }];

    objectsInArrays

    Examples of incorrect code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [ { 'foo': 'bar' } ];
    var arr = [ {
      'foo': 'bar'
    } ]

    Examples of correct code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [{ 'foo': 'bar' }];
    var arr = [{
      'foo': 'bar'
    }];

    arraysInArrays

    Examples of incorrect code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [ [ 1, 2 ], 2, 3, 4 ];
    var arr = [ [ 1, 2 ], 2, [ 3, 4 ] ];

    Examples of correct code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [[ 1, 2 ], 2, 3, 4 ];
    var arr = [[ 1, 2 ], 2, [ 3, 4 ]];

    When Not To Use It

    You can turn this rule off if you are not concerned with the consistency of spacing between array brackets.

    Related Rules

    • [space-in-parens](space-in-parens.md)
    • [object-curly-spacing](object-curly-spacing.md)
    • [computed-property-spacing](computed-property-spacing.md) Source: http://eslint.org/docs/rules/

    Expected parentheses around arrow function argument having a body with curly braces.
    Open

              set: options.readonly ? undefined : v => { service[name] = v; }
    Severity: Minor
    Found in src/core.js by eslint

    Require parens in arrow function arguments (arrow-parens)

    Arrow functions can omit parentheses when they have exactly one parameter. In all other cases the parameter(s) must be wrapped in parentheses. This rule enforces the consistent use of parentheses in arrow functions.

    Rule Details

    This rule enforces parentheses around arrow function parameters regardless of arity. For example:

    /*eslint-env es6*/
    
    // Bad
    a => {}
    
    // Good
    (a) => {}

    Following this style will help you find arrow functions (=>) which may be mistakenly included in a condition when a comparison such as >= was the intent.

    /*eslint-env es6*/
    
    // Bad
    if (a => 2) {
    }
    
    // Good
    if (a >= 2) {
    }

    The rule can also be configured to discourage the use of parens when they are not required:

    /*eslint-env es6*/
    
    // Bad
    (a) => {}
    
    // Good
    a => {}

    Options

    This rule has a string option and an object one.

    String options are:

    • "always" (default) requires parens around arguments in all cases.
    • "as-needed" allows omitting parens when there is only one argument.

    Object properties for variants of the "as-needed" option:

    • "requireForBlockBody": true modifies the as-needed rule in order to require parens if the function body is in an instructions block (surrounded by braces).

    always

    Examples of incorrect code for this rule with the default "always" option:

    /*eslint arrow-parens: ["error", "always"]*/
    /*eslint-env es6*/
    
    a => {};
    a => a;
    a => {'\n'};
    a.then(foo => {});
    a.then(foo => a);
    a(foo => { if (true) {} });

    Examples of correct code for this rule with the default "always" option:

    /*eslint arrow-parens: ["error", "always"]*/
    /*eslint-env es6*/
    
    () => {};
    (a) => {};
    (a) => a;
    (a) => {'\n'}
    a.then((foo) => {});
    a.then((foo) => { if (true) {} });

    If Statements

    One of benefits of this option is that it prevents the incorrect use of arrow functions in conditionals:

    /*eslint-env es6*/
    
    var a = 1;
    var b = 2;
    // ...
    if (a => b) {
     console.log('bigger');
    } else {
     console.log('smaller');
    }
    // outputs 'bigger', not smaller as expected

    The contents of the if statement is an arrow function, not a comparison.

    If the arrow function is intentional, it should be wrapped in parens to remove ambiguity.

    /*eslint-env es6*/
    
    var a = 1;
    var b = 0;
    // ...
    if ((a) => b) {
     console.log('truthy value returned');
    } else {
     console.log('falsey value returned');
    }
    // outputs 'truthy value returned'

    The following is another example of this behavior:

    /*eslint-env es6*/
    
    var a = 1, b = 2, c = 3, d = 4;
    var f = a => b ? c: d;
    // f = ?

    f is an arrow function which takes a as an argument and returns the result of b ? c: d.

    This should be rewritten like so:

    /*eslint-env es6*/
    
    var a = 1, b = 2, c = 3, d = 4;
    var f = (a) => b ? c: d;

    as-needed

    Examples of incorrect code for this rule with the "as-needed" option:

    /*eslint arrow-parens: ["error", "as-needed"]*/
    /*eslint-env es6*/
    
    (a) => {};
    (a) => a;
    (a) => {'\n'};
    a.then((foo) => {});
    a.then((foo) => a);
    a((foo) => { if (true) {} });

    Examples of correct code for this rule with the "as-needed" option:

    /*eslint arrow-parens: ["error", "as-needed"]*/
    /*eslint-env es6*/
    
    () => {};
    a => {};
    a => a;
    a => {'\n'};
    a.then(foo => {});
    a.then(foo => { if (true) {} });
    (a, b, c) => a;
    (a = 10) => a;
    ([a, b]) => a;
    ({a, b}) => a;

    requireForBlockBody

    Examples of incorrect code for the { "requireForBlockBody": true } option:

    /*eslint arrow-parens: [2, "as-needed", { "requireForBlockBody": true }]*/
    /*eslint-env es6*/
    
    (a) => a;
    a => {};
    a => {'\n'};
    a.map((x) => x * x);
    a.map(x => {
      return x * x;
    });
    a.then(foo => {});

    Examples of correct code for the { "requireForBlockBody": true } option:

    /*eslint arrow-parens: [2, "as-needed", { "requireForBlockBody": true }]*/
    /*eslint-env es6*/
    
    (a) => {};
    (a) => {'\n'};
    a => ({});
    () => {};
    a => a;
    a.then((foo) => {});
    a.then((foo) => { if (true) {} });
    a((foo) => { if (true) {} });
    (a, b, c) => a;
    (a = 10) => a;
    ([a, b]) => a;
    ({a, b}) => a;

    Further Reading

    Unexpected string concatenation.
    Open

          debug(Chalk.bold.cyan('create') + ` ${name}`);
    Severity: Minor
    Found in src/core.js by eslint

    Suggest using template literals instead of string concatenation. (prefer-template)

    In ES2015 (ES6), we can use template literals instead of string concatenation.

    var str = "Hello, " + name + "!";
    /*eslint-env es6*/
    
    var str = `Hello, ${name}!`;

    Rule Details

    This rule is aimed to flag usage of + operators with strings.

    Examples

    Examples of incorrect code for this rule:

    /*eslint prefer-template: "error"*/
    
    var str = "Hello, " + name + "!";
    var str = "Time: " + (12 * 60 * 60 * 1000);

    Examples of correct code for this rule:

    /*eslint prefer-template: "error"*/
    /*eslint-env es6*/
    
    var str = "Hello World!";
    var str = `Hello, ${name}!`;
    var str = `Time: ${12 * 60 * 60 * 1000}`;
    
    // This is reported by `no-useless-concat`.
    var str = "Hello, " + "World!";

    When Not To Use It

    This rule should not be used in ES3/5 environments.

    In ES2015 (ES6) or later, if you don't want to be notified about string concatenation, you can safely disable this rule.

    Related Rules

    Unexpected string concatenation.
    Open

          debug(Chalk.bold.green('postinit') + ` ${name}`);
    Severity: Minor
    Found in src/core.js by eslint

    Suggest using template literals instead of string concatenation. (prefer-template)

    In ES2015 (ES6), we can use template literals instead of string concatenation.

    var str = "Hello, " + name + "!";
    /*eslint-env es6*/
    
    var str = `Hello, ${name}!`;

    Rule Details

    This rule is aimed to flag usage of + operators with strings.

    Examples

    Examples of incorrect code for this rule:

    /*eslint prefer-template: "error"*/
    
    var str = "Hello, " + name + "!";
    var str = "Time: " + (12 * 60 * 60 * 1000);

    Examples of correct code for this rule:

    /*eslint prefer-template: "error"*/
    /*eslint-env es6*/
    
    var str = "Hello World!";
    var str = `Hello, ${name}!`;
    var str = `Time: ${12 * 60 * 60 * 1000}`;
    
    // This is reported by `no-useless-concat`.
    var str = "Hello, " + "World!";

    When Not To Use It

    This rule should not be used in ES3/5 environments.

    In ES2015 (ES6) or later, if you don't want to be notified about string concatenation, you can safely disable this rule.

    Related Rules

    Unexpected string concatenation.
    Open

          debug(Chalk.bold.cyan('invoke') + ` ${service.name || '<anonymous>'}`);
    Severity: Minor
    Found in src/core.js by eslint

    Suggest using template literals instead of string concatenation. (prefer-template)

    In ES2015 (ES6), we can use template literals instead of string concatenation.

    var str = "Hello, " + name + "!";
    /*eslint-env es6*/
    
    var str = `Hello, ${name}!`;

    Rule Details

    This rule is aimed to flag usage of + operators with strings.

    Examples

    Examples of incorrect code for this rule:

    /*eslint prefer-template: "error"*/
    
    var str = "Hello, " + name + "!";
    var str = "Time: " + (12 * 60 * 60 * 1000);

    Examples of correct code for this rule:

    /*eslint prefer-template: "error"*/
    /*eslint-env es6*/
    
    var str = "Hello World!";
    var str = `Hello, ${name}!`;
    var str = `Time: ${12 * 60 * 60 * 1000}`;
    
    // This is reported by `no-useless-concat`.
    var str = "Hello, " + "World!";

    When Not To Use It

    This rule should not be used in ES3/5 environments.

    In ES2015 (ES6) or later, if you don't want to be notified about string concatenation, you can safely disable this rule.

    Related Rules

    Unexpected string concatenation.
    Open

          debug(Chalk.bold.green('success') + ` ${name}`);
    Severity: Minor
    Found in src/core.js by eslint

    Suggest using template literals instead of string concatenation. (prefer-template)

    In ES2015 (ES6), we can use template literals instead of string concatenation.

    var str = "Hello, " + name + "!";
    /*eslint-env es6*/
    
    var str = `Hello, ${name}!`;

    Rule Details

    This rule is aimed to flag usage of + operators with strings.

    Examples

    Examples of incorrect code for this rule:

    /*eslint prefer-template: "error"*/
    
    var str = "Hello, " + name + "!";
    var str = "Time: " + (12 * 60 * 60 * 1000);

    Examples of correct code for this rule:

    /*eslint prefer-template: "error"*/
    /*eslint-env es6*/
    
    var str = "Hello World!";
    var str = `Hello, ${name}!`;
    var str = `Time: ${12 * 60 * 60 * 1000}`;
    
    // This is reported by `no-useless-concat`.
    var str = "Hello, " + "World!";

    When Not To Use It

    This rule should not be used in ES3/5 environments.

    In ES2015 (ES6) or later, if you don't want to be notified about string concatenation, you can safely disable this rule.

    Related Rules

    Expected Symbol to have a description.
    Open

    const $$base = Symbol();
    Severity: Minor
    Found in src/core.js by eslint

    require symbol description (symbol-description)

    The Symbol function may have optional description:

    var foo = Symbol("some description");
    
    var someString = "some description";
    var bar = Symbol(someString);

    Using description promotes easier debugging: when a symbol is logged the description is used:

    var foo = Symbol("some description");
    
    > console.log(foo);
    // Symbol(some description)

    It may facilitate identifying symbols when one is observed during debugging.

    Rule Details

    This rules requires a description when creating symbols.

    Examples

    Examples of incorrect code for this rule:

    /*eslint symbol-description: "error"*/
    /*eslint-env es6*/
    
    var foo = Symbol();

    Examples of correct code for this rule:

    /*eslint symbol-description: "error"*/
    /*eslint-env es6*/
    
    var foo = Symbol("some description");
    
    var someString = "some description";
    var bar = Symbol(someString);

    When Not To Use It

    This rule should not be used in ES3/5 environments. In addition, this rule can be safely turned off if you don't want to enforce presence of description when creating Symbols.

    Further Reading

    Unexpected dangling '_' in '__esModule'.
    Open

        if (service.__esModule) { service = service.default; }
    Severity: Minor
    Found in src/core.js by eslint

    disallow dangling underscores in identifiers (no-underscore-dangle)

    As far as naming conventions for identifiers go, dangling underscores may be the most polarizing in JavaScript. Dangling underscores are underscores at either the beginning or end of an identifier, such as:

    var _foo;

    There is actually a long history of using dangling underscores to indicate "private" members of objects in JavaScript (though JavaScript doesn't have truly private members, this convention served as a warning). This began with SpiderMonkey adding nonstandard methods such as __defineGetter__(). The intent with the underscores was to make it obvious that this method was special in some way. Since that time, using a single underscore prefix has become popular as a way to indicate "private" members of objects.

    Whether or not you choose to allow dangling underscores in identifiers is purely a convention and has no effect on performance, readability, or complexity. It's purely a preference.

    Rule Details

    This rule disallows dangling underscores in identifiers.

    Examples of incorrect code for this rule:

    /*eslint no-underscore-dangle: "error"*/
    
    var foo_;
    var __proto__ = {};
    foo._bar();

    Examples of correct code for this rule:

    /*eslint no-underscore-dangle: "error"*/
    
    var _ = require('underscore');
    var obj = _.contains(items, item);
    obj.__proto__ = {};
    var file = __filename;

    Options

    This rule has an object option:

    • "allow" allows specified identifiers to have dangling underscores
    • "allowAfterThis": false (default) disallows dangling underscores in members of the this object
    • "allowAfterSuper": false (default) disallows dangling underscores in members of the super object

    allow

    Examples of additional correct code for this rule with the { "allow": ["foo_", "_bar"] } option:

    /*eslint no-underscore-dangle: ["error", { "allow": ["foo_", "_bar"] }]*/
    
    var foo_;
    foo._bar();

    allowAfterThis

    Examples of correct code for this rule with the { "allowAfterThis": true } option:

    /*eslint no-underscore-dangle: ["error", { "allowAfterThis": true }]*/
    
    var a = this.foo_;
    this._bar();

    allowAfterSuper

    Examples of correct code for this rule with the { "allowAfterSuper": true } option:

    /*eslint no-underscore-dangle: ["error", { "allowAfterSuper": true }]*/
    
    var a = super.foo_;
    super._bar();

    When Not To Use It

    If you want to allow dangling underscores in identifiers, then you can safely turn this rule off. Source: http://eslint.org/docs/rules/

    There should be no space after '['.
    Open

        const graph = [ ];
    Severity: Minor
    Found in src/core.js by eslint

    Disallow or enforce spaces inside of brackets (array-bracket-spacing)

    A number of style guides require or disallow spaces between array brackets and other tokens. This rule applies to both array literals and destructuring assignments (ECMAScript 6).

    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var [ x, y ] = z;
    
    var arr = ['foo', 'bar'];
    var [x,y] = z;

    Rule Details

    This rule enforces consistent spacing inside array brackets.

    Options

    This rule has a string option:

    • "never" (default) disallows spaces inside array brackets
    • "always" requires one or more spaces or newlines inside array brackets

    This rule has an object option for exceptions to the "never" option:

    • "singleValue": true requires one or more spaces or newlines inside brackets of array literals that contain a single element
    • "objectsInArrays": true requires one or more spaces or newlines between brackets of array literals and braces of their object literal elements [ { or } ]
    • "arraysInArrays": true requires one or more spaces or newlines between brackets of array literals and brackets of their array literal elements [ [ or ] ]

    This rule has an object option for exceptions to the "always" option:

    • "singleValue": false disallows spaces inside brackets of array literals that contain a single element
    • "objectsInArrays": false disallows spaces between brackets of array literals and braces of their object literal elements [{ or }]
    • "arraysInArrays": false disallows spaces between brackets of array literals and brackets of their array literal elements [[ or ]]

    This rule has built-in exceptions:

    • "never" (and also the exceptions to the "always" option) allows newlines inside array brackets, because this is a common pattern
    • "always" does not require spaces or newlines in empty array literals []

    never

    Examples of incorrect code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar'];
    var arr = [[ 'foo' ], 'bar'];
    var arr = [ 'foo',
      'bar'
    ];
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    Examples of correct code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = ['foo', 'bar', 'baz'];
    var arr = [['foo'], 'bar', 'baz'];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    always

    Examples of incorrect code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = ['foo', 'bar'];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar' ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    Examples of correct code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = [ 'foo', 'bar', 'baz' ];
    var arr = [ [ 'foo' ], 'bar', 'baz' ];
    var arr = [ 'foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar' ];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    singleValue

    Examples of incorrect code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = [ 'foo' ];
    var foo = [ 'foo'];
    var foo = ['foo' ];
    var foo = [ 1 ];
    var foo = [ 1];
    var foo = [1 ];
    var foo = [ [ 1, 2 ] ];
    var foo = [ { 'foo': 'bar' } ];

    Examples of correct code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = ['foo'];
    var foo = [1];
    var foo = [[ 1, 1 ]];
    var foo = [{ 'foo': 'bar' }];

    objectsInArrays

    Examples of incorrect code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [ { 'foo': 'bar' } ];
    var arr = [ {
      'foo': 'bar'
    } ]

    Examples of correct code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [{ 'foo': 'bar' }];
    var arr = [{
      'foo': 'bar'
    }];

    arraysInArrays

    Examples of incorrect code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [ [ 1, 2 ], 2, 3, 4 ];
    var arr = [ [ 1, 2 ], 2, [ 3, 4 ] ];

    Examples of correct code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [[ 1, 2 ], 2, 3, 4 ];
    var arr = [[ 1, 2 ], 2, [ 3, 4 ]];

    When Not To Use It

    You can turn this rule off if you are not concerned with the consistency of spacing between array brackets.

    Related Rules

    • [space-in-parens](space-in-parens.md)
    • [object-curly-spacing](object-curly-spacing.md)
    • [computed-property-spacing](computed-property-spacing.md) Source: http://eslint.org/docs/rules/

    Unexpected string concatenation.
    Open

          debug(Chalk.bold.yellow('init') + ` ${name}`);
    Severity: Minor
    Found in src/core.js by eslint

    Suggest using template literals instead of string concatenation. (prefer-template)

    In ES2015 (ES6), we can use template literals instead of string concatenation.

    var str = "Hello, " + name + "!";
    /*eslint-env es6*/
    
    var str = `Hello, ${name}!`;

    Rule Details

    This rule is aimed to flag usage of + operators with strings.

    Examples

    Examples of incorrect code for this rule:

    /*eslint prefer-template: "error"*/
    
    var str = "Hello, " + name + "!";
    var str = "Time: " + (12 * 60 * 60 * 1000);

    Examples of correct code for this rule:

    /*eslint prefer-template: "error"*/
    /*eslint-env es6*/
    
    var str = "Hello World!";
    var str = `Hello, ${name}!`;
    var str = `Time: ${12 * 60 * 60 * 1000}`;
    
    // This is reported by `no-useless-concat`.
    var str = "Hello, " + "World!";

    When Not To Use It

    This rule should not be used in ES3/5 environments.

    In ES2015 (ES6) or later, if you don't want to be notified about string concatenation, you can safely disable this rule.

    Related Rules

    Unexpected string concatenation.
    Open

          debug(Chalk.bold.cyan('register') + ` ${service.name}`);
    Severity: Minor
    Found in src/core.js by eslint

    Suggest using template literals instead of string concatenation. (prefer-template)

    In ES2015 (ES6), we can use template literals instead of string concatenation.

    var str = "Hello, " + name + "!";
    /*eslint-env es6*/
    
    var str = `Hello, ${name}!`;

    Rule Details

    This rule is aimed to flag usage of + operators with strings.

    Examples

    Examples of incorrect code for this rule:

    /*eslint prefer-template: "error"*/
    
    var str = "Hello, " + name + "!";
    var str = "Time: " + (12 * 60 * 60 * 1000);

    Examples of correct code for this rule:

    /*eslint prefer-template: "error"*/
    /*eslint-env es6*/
    
    var str = "Hello World!";
    var str = `Hello, ${name}!`;
    var str = `Time: ${12 * 60 * 60 * 1000}`;
    
    // This is reported by `no-useless-concat`.
    var str = "Hello, " + "World!";

    When Not To Use It

    This rule should not be used in ES3/5 environments.

    In ES2015 (ES6) or later, if you don't want to be notified about string concatenation, you can safely disable this rule.

    Related Rules

    There should be no space before ']'.
    Open

          for (const dep of deps) { graph.push([ dep, name ]); }
    Severity: Minor
    Found in src/core.js by eslint

    Disallow or enforce spaces inside of brackets (array-bracket-spacing)

    A number of style guides require or disallow spaces between array brackets and other tokens. This rule applies to both array literals and destructuring assignments (ECMAScript 6).

    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var [ x, y ] = z;
    
    var arr = ['foo', 'bar'];
    var [x,y] = z;

    Rule Details

    This rule enforces consistent spacing inside array brackets.

    Options

    This rule has a string option:

    • "never" (default) disallows spaces inside array brackets
    • "always" requires one or more spaces or newlines inside array brackets

    This rule has an object option for exceptions to the "never" option:

    • "singleValue": true requires one or more spaces or newlines inside brackets of array literals that contain a single element
    • "objectsInArrays": true requires one or more spaces or newlines between brackets of array literals and braces of their object literal elements [ { or } ]
    • "arraysInArrays": true requires one or more spaces or newlines between brackets of array literals and brackets of their array literal elements [ [ or ] ]

    This rule has an object option for exceptions to the "always" option:

    • "singleValue": false disallows spaces inside brackets of array literals that contain a single element
    • "objectsInArrays": false disallows spaces between brackets of array literals and braces of their object literal elements [{ or }]
    • "arraysInArrays": false disallows spaces between brackets of array literals and brackets of their array literal elements [[ or ]]

    This rule has built-in exceptions:

    • "never" (and also the exceptions to the "always" option) allows newlines inside array brackets, because this is a common pattern
    • "always" does not require spaces or newlines in empty array literals []

    never

    Examples of incorrect code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar'];
    var arr = [[ 'foo' ], 'bar'];
    var arr = [ 'foo',
      'bar'
    ];
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    Examples of correct code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = ['foo', 'bar', 'baz'];
    var arr = [['foo'], 'bar', 'baz'];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    always

    Examples of incorrect code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = ['foo', 'bar'];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar' ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    Examples of correct code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = [ 'foo', 'bar', 'baz' ];
    var arr = [ [ 'foo' ], 'bar', 'baz' ];
    var arr = [ 'foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar' ];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    singleValue

    Examples of incorrect code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = [ 'foo' ];
    var foo = [ 'foo'];
    var foo = ['foo' ];
    var foo = [ 1 ];
    var foo = [ 1];
    var foo = [1 ];
    var foo = [ [ 1, 2 ] ];
    var foo = [ { 'foo': 'bar' } ];

    Examples of correct code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = ['foo'];
    var foo = [1];
    var foo = [[ 1, 1 ]];
    var foo = [{ 'foo': 'bar' }];

    objectsInArrays

    Examples of incorrect code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [ { 'foo': 'bar' } ];
    var arr = [ {
      'foo': 'bar'
    } ]

    Examples of correct code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [{ 'foo': 'bar' }];
    var arr = [{
      'foo': 'bar'
    }];

    arraysInArrays

    Examples of incorrect code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [ [ 1, 2 ], 2, 3, 4 ];
    var arr = [ [ 1, 2 ], 2, [ 3, 4 ] ];

    Examples of correct code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [[ 1, 2 ], 2, 3, 4 ];
    var arr = [[ 1, 2 ], 2, [ 3, 4 ]];

    When Not To Use It

    You can turn this rule off if you are not concerned with the consistency of spacing between array brackets.

    Related Rules

    • [space-in-parens](space-in-parens.md)
    • [object-curly-spacing](object-curly-spacing.md)
    • [computed-property-spacing](computed-property-spacing.md) Source: http://eslint.org/docs/rules/

    Unexpected dangling '_' in '__init'.
    Open

        this.startup = this.__init();
    Severity: Minor
    Found in src/core.js by eslint

    disallow dangling underscores in identifiers (no-underscore-dangle)

    As far as naming conventions for identifiers go, dangling underscores may be the most polarizing in JavaScript. Dangling underscores are underscores at either the beginning or end of an identifier, such as:

    var _foo;

    There is actually a long history of using dangling underscores to indicate "private" members of objects in JavaScript (though JavaScript doesn't have truly private members, this convention served as a warning). This began with SpiderMonkey adding nonstandard methods such as __defineGetter__(). The intent with the underscores was to make it obvious that this method was special in some way. Since that time, using a single underscore prefix has become popular as a way to indicate "private" members of objects.

    Whether or not you choose to allow dangling underscores in identifiers is purely a convention and has no effect on performance, readability, or complexity. It's purely a preference.

    Rule Details

    This rule disallows dangling underscores in identifiers.

    Examples of incorrect code for this rule:

    /*eslint no-underscore-dangle: "error"*/
    
    var foo_;
    var __proto__ = {};
    foo._bar();

    Examples of correct code for this rule:

    /*eslint no-underscore-dangle: "error"*/
    
    var _ = require('underscore');
    var obj = _.contains(items, item);
    obj.__proto__ = {};
    var file = __filename;

    Options

    This rule has an object option:

    • "allow" allows specified identifiers to have dangling underscores
    • "allowAfterThis": false (default) disallows dangling underscores in members of the this object
    • "allowAfterSuper": false (default) disallows dangling underscores in members of the super object

    allow

    Examples of additional correct code for this rule with the { "allow": ["foo_", "_bar"] } option:

    /*eslint no-underscore-dangle: ["error", { "allow": ["foo_", "_bar"] }]*/
    
    var foo_;
    foo._bar();

    allowAfterThis

    Examples of correct code for this rule with the { "allowAfterThis": true } option:

    /*eslint no-underscore-dangle: ["error", { "allowAfterThis": true }]*/
    
    var a = this.foo_;
    this._bar();

    allowAfterSuper

    Examples of correct code for this rule with the { "allowAfterSuper": true } option:

    /*eslint no-underscore-dangle: ["error", { "allowAfterSuper": true }]*/
    
    var a = super.foo_;
    super._bar();

    When Not To Use It

    If you want to allow dangling underscores in identifiers, then you can safely turn this rule off. Source: http://eslint.org/docs/rules/

    There should be no space after '['.
    Open

          const deps = Service.meta(service, 'deps') || [ ];
    Severity: Minor
    Found in src/core.js by eslint

    Disallow or enforce spaces inside of brackets (array-bracket-spacing)

    A number of style guides require or disallow spaces between array brackets and other tokens. This rule applies to both array literals and destructuring assignments (ECMAScript 6).

    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var [ x, y ] = z;
    
    var arr = ['foo', 'bar'];
    var [x,y] = z;

    Rule Details

    This rule enforces consistent spacing inside array brackets.

    Options

    This rule has a string option:

    • "never" (default) disallows spaces inside array brackets
    • "always" requires one or more spaces or newlines inside array brackets

    This rule has an object option for exceptions to the "never" option:

    • "singleValue": true requires one or more spaces or newlines inside brackets of array literals that contain a single element
    • "objectsInArrays": true requires one or more spaces or newlines between brackets of array literals and braces of their object literal elements [ { or } ]
    • "arraysInArrays": true requires one or more spaces or newlines between brackets of array literals and brackets of their array literal elements [ [ or ] ]

    This rule has an object option for exceptions to the "always" option:

    • "singleValue": false disallows spaces inside brackets of array literals that contain a single element
    • "objectsInArrays": false disallows spaces between brackets of array literals and braces of their object literal elements [{ or }]
    • "arraysInArrays": false disallows spaces between brackets of array literals and brackets of their array literal elements [[ or ]]

    This rule has built-in exceptions:

    • "never" (and also the exceptions to the "always" option) allows newlines inside array brackets, because this is a common pattern
    • "always" does not require spaces or newlines in empty array literals []

    never

    Examples of incorrect code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar'];
    var arr = [[ 'foo' ], 'bar'];
    var arr = [ 'foo',
      'bar'
    ];
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    Examples of correct code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = ['foo', 'bar', 'baz'];
    var arr = [['foo'], 'bar', 'baz'];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    always

    Examples of incorrect code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = ['foo', 'bar'];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar' ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    Examples of correct code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = [ 'foo', 'bar', 'baz' ];
    var arr = [ [ 'foo' ], 'bar', 'baz' ];
    var arr = [ 'foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar' ];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    singleValue

    Examples of incorrect code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = [ 'foo' ];
    var foo = [ 'foo'];
    var foo = ['foo' ];
    var foo = [ 1 ];
    var foo = [ 1];
    var foo = [1 ];
    var foo = [ [ 1, 2 ] ];
    var foo = [ { 'foo': 'bar' } ];

    Examples of correct code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = ['foo'];
    var foo = [1];
    var foo = [[ 1, 1 ]];
    var foo = [{ 'foo': 'bar' }];

    objectsInArrays

    Examples of incorrect code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [ { 'foo': 'bar' } ];
    var arr = [ {
      'foo': 'bar'
    } ]

    Examples of correct code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [{ 'foo': 'bar' }];
    var arr = [{
      'foo': 'bar'
    }];

    arraysInArrays

    Examples of incorrect code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [ [ 1, 2 ], 2, 3, 4 ];
    var arr = [ [ 1, 2 ], 2, [ 3, 4 ] ];

    Examples of correct code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [[ 1, 2 ], 2, 3, 4 ];
    var arr = [[ 1, 2 ], 2, [ 3, 4 ]];

    When Not To Use It

    You can turn this rule off if you are not concerned with the consistency of spacing between array brackets.

    Related Rules

    • [space-in-parens](space-in-parens.md)
    • [object-curly-spacing](object-curly-spacing.md)
    • [computed-property-spacing](computed-property-spacing.md) Source: http://eslint.org/docs/rules/

    Expected Symbol to have a description.
    Open

    const $$services = Symbol();
    Severity: Minor
    Found in src/core.js by eslint

    require symbol description (symbol-description)

    The Symbol function may have optional description:

    var foo = Symbol("some description");
    
    var someString = "some description";
    var bar = Symbol(someString);

    Using description promotes easier debugging: when a symbol is logged the description is used:

    var foo = Symbol("some description");
    
    > console.log(foo);
    // Symbol(some description)

    It may facilitate identifying symbols when one is observed during debugging.

    Rule Details

    This rules requires a description when creating symbols.

    Examples

    Examples of incorrect code for this rule:

    /*eslint symbol-description: "error"*/
    /*eslint-env es6*/
    
    var foo = Symbol();

    Examples of correct code for this rule:

    /*eslint symbol-description: "error"*/
    /*eslint-env es6*/
    
    var foo = Symbol("some description");
    
    var someString = "some description";
    var bar = Symbol(someString);

    When Not To Use It

    This rule should not be used in ES3/5 environments. In addition, this rule can be safely turned off if you don't want to enforce presence of description when creating Symbols.

    Further Reading

    There should be no space before ']'.
    Open

          if (deps.length === 0) { graph.push([ name ]); }
    Severity: Minor
    Found in src/core.js by eslint

    Disallow or enforce spaces inside of brackets (array-bracket-spacing)

    A number of style guides require or disallow spaces between array brackets and other tokens. This rule applies to both array literals and destructuring assignments (ECMAScript 6).

    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var [ x, y ] = z;
    
    var arr = ['foo', 'bar'];
    var [x,y] = z;

    Rule Details

    This rule enforces consistent spacing inside array brackets.

    Options

    This rule has a string option:

    • "never" (default) disallows spaces inside array brackets
    • "always" requires one or more spaces or newlines inside array brackets

    This rule has an object option for exceptions to the "never" option:

    • "singleValue": true requires one or more spaces or newlines inside brackets of array literals that contain a single element
    • "objectsInArrays": true requires one or more spaces or newlines between brackets of array literals and braces of their object literal elements [ { or } ]
    • "arraysInArrays": true requires one or more spaces or newlines between brackets of array literals and brackets of their array literal elements [ [ or ] ]

    This rule has an object option for exceptions to the "always" option:

    • "singleValue": false disallows spaces inside brackets of array literals that contain a single element
    • "objectsInArrays": false disallows spaces between brackets of array literals and braces of their object literal elements [{ or }]
    • "arraysInArrays": false disallows spaces between brackets of array literals and brackets of their array literal elements [[ or ]]

    This rule has built-in exceptions:

    • "never" (and also the exceptions to the "always" option) allows newlines inside array brackets, because this is a common pattern
    • "always" does not require spaces or newlines in empty array literals []

    never

    Examples of incorrect code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar'];
    var arr = [[ 'foo' ], 'bar'];
    var arr = [ 'foo',
      'bar'
    ];
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    Examples of correct code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = ['foo', 'bar', 'baz'];
    var arr = [['foo'], 'bar', 'baz'];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    always

    Examples of incorrect code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = ['foo', 'bar'];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar' ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    Examples of correct code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = [ 'foo', 'bar', 'baz' ];
    var arr = [ [ 'foo' ], 'bar', 'baz' ];
    var arr = [ 'foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar' ];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    singleValue

    Examples of incorrect code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = [ 'foo' ];
    var foo = [ 'foo'];
    var foo = ['foo' ];
    var foo = [ 1 ];
    var foo = [ 1];
    var foo = [1 ];
    var foo = [ [ 1, 2 ] ];
    var foo = [ { 'foo': 'bar' } ];

    Examples of correct code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = ['foo'];
    var foo = [1];
    var foo = [[ 1, 1 ]];
    var foo = [{ 'foo': 'bar' }];

    objectsInArrays

    Examples of incorrect code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [ { 'foo': 'bar' } ];
    var arr = [ {
      'foo': 'bar'
    } ]

    Examples of correct code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [{ 'foo': 'bar' }];
    var arr = [{
      'foo': 'bar'
    }];

    arraysInArrays

    Examples of incorrect code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [ [ 1, 2 ], 2, 3, 4 ];
    var arr = [ [ 1, 2 ], 2, [ 3, 4 ] ];

    Examples of correct code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [[ 1, 2 ], 2, 3, 4 ];
    var arr = [[ 1, 2 ], 2, [ 3, 4 ]];

    When Not To Use It

    You can turn this rule off if you are not concerned with the consistency of spacing between array brackets.

    Related Rules

    • [space-in-parens](space-in-parens.md)
    • [object-curly-spacing](object-curly-spacing.md)
    • [computed-property-spacing](computed-property-spacing.md) Source: http://eslint.org/docs/rules/

    There should be no space after '['.
    Open

          if (deps.length === 0) { graph.push([ name ]); }
    Severity: Minor
    Found in src/core.js by eslint

    Disallow or enforce spaces inside of brackets (array-bracket-spacing)

    A number of style guides require or disallow spaces between array brackets and other tokens. This rule applies to both array literals and destructuring assignments (ECMAScript 6).

    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var [ x, y ] = z;
    
    var arr = ['foo', 'bar'];
    var [x,y] = z;

    Rule Details

    This rule enforces consistent spacing inside array brackets.

    Options

    This rule has a string option:

    • "never" (default) disallows spaces inside array brackets
    • "always" requires one or more spaces or newlines inside array brackets

    This rule has an object option for exceptions to the "never" option:

    • "singleValue": true requires one or more spaces or newlines inside brackets of array literals that contain a single element
    • "objectsInArrays": true requires one or more spaces or newlines between brackets of array literals and braces of their object literal elements [ { or } ]
    • "arraysInArrays": true requires one or more spaces or newlines between brackets of array literals and brackets of their array literal elements [ [ or ] ]

    This rule has an object option for exceptions to the "always" option:

    • "singleValue": false disallows spaces inside brackets of array literals that contain a single element
    • "objectsInArrays": false disallows spaces between brackets of array literals and braces of their object literal elements [{ or }]
    • "arraysInArrays": false disallows spaces between brackets of array literals and brackets of their array literal elements [[ or ]]

    This rule has built-in exceptions:

    • "never" (and also the exceptions to the "always" option) allows newlines inside array brackets, because this is a common pattern
    • "always" does not require spaces or newlines in empty array literals []

    never

    Examples of incorrect code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [ 'foo', 'bar' ];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar'];
    var arr = [[ 'foo' ], 'bar'];
    var arr = [ 'foo',
      'bar'
    ];
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    Examples of correct code for this rule with the default "never" option:

    /*eslint array-bracket-spacing: ["error", "never"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = ['foo', 'bar', 'baz'];
    var arr = [['foo'], 'bar', 'baz'];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    always

    Examples of incorrect code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = ['foo', 'bar'];
    var arr = ['foo', 'bar' ];
    var arr = [ ['foo'], 'bar' ];
    var arr = ['foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar'];
    
    var [x, y] = z;
    var [x,y] = z;
    var [x, ...y] = z;
    var [,,x,] = z;

    Examples of correct code for this rule with the "always" option:

    /*eslint array-bracket-spacing: ["error", "always"]*/
    /*eslint-env es6*/
    
    var arr = [];
    var arr = [ 'foo', 'bar', 'baz' ];
    var arr = [ [ 'foo' ], 'bar', 'baz' ];
    var arr = [ 'foo',
      'bar'
    ];
    var arr = [
      'foo',
      'bar' ];
    var arr = [
      'foo',
      'bar',
      'baz'
    ];
    
    var [ x, y ] = z;
    var [ x,y ] = z;
    var [ x, ...y ] = z;
    var [ ,,x, ] = z;

    singleValue

    Examples of incorrect code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = [ 'foo' ];
    var foo = [ 'foo'];
    var foo = ['foo' ];
    var foo = [ 1 ];
    var foo = [ 1];
    var foo = [1 ];
    var foo = [ [ 1, 2 ] ];
    var foo = [ { 'foo': 'bar' } ];

    Examples of correct code for this rule with the "always", { "singleValue": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "singleValue": false }]*/
    
    var foo = ['foo'];
    var foo = [1];
    var foo = [[ 1, 1 ]];
    var foo = [{ 'foo': 'bar' }];

    objectsInArrays

    Examples of incorrect code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [ { 'foo': 'bar' } ];
    var arr = [ {
      'foo': 'bar'
    } ]

    Examples of correct code for this rule with the "always", { "objectsInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "objectsInArrays": false }]*/
    
    var arr = [{ 'foo': 'bar' }];
    var arr = [{
      'foo': 'bar'
    }];

    arraysInArrays

    Examples of incorrect code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [ [ 1, 2 ], 2, 3, 4 ];
    var arr = [ [ 1, 2 ], 2, [ 3, 4 ] ];

    Examples of correct code for this rule with the "always", { "arraysInArrays": false } options:

    /*eslint array-bracket-spacing: ["error", "always", { "arraysInArrays": false }]*/
    
    var arr = [[ 1, 2 ], 2, 3, 4 ];
    var arr = [[ 1, 2 ], 2, [ 3, 4 ]];

    When Not To Use It

    You can turn this rule off if you are not concerned with the consistency of spacing between array brackets.

    Related Rules

    • [space-in-parens](space-in-parens.md)
    • [object-curly-spacing](object-curly-spacing.md)
    • [computed-property-spacing](computed-property-spacing.md) Source: http://eslint.org/docs/rules/

    iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.
    Open

        for (const name of sorted) {
    Severity: Minor
    Found in src/core.js by eslint

    disallow specified syntax (no-restricted-syntax)

    JavaScript has a lot of language features, and not everyone likes all of them. As a result, some projects choose to disallow the use of certain language features altogether. For instance, you might decide to disallow the use of try-catch or class, or you might decide to disallow the use of the in operator.

    Rather than creating separate rules for every language feature you want to turn off, this rule allows you to configure the syntax elements you want to restrict use of. These elements are represented by their ESTree node types. For example, a function declaration is represented by FunctionDeclaration and the with statement is represented by WithStatement. You may find the full list of AST node names you can use on GitHub and use the online parser to see what type of nodes your code consists of.

    You can also specify [AST selectors](../developer-guide/selectors) to restrict, allowing much more precise control over syntax patterns.

    Rule Details

    This rule disallows specified (that is, user-defined) syntax.

    Options

    This rule takes a list of strings, where each string is an AST selector:

    {
        "rules": {
            "no-restricted-syntax": ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"]
        }
    }

    Alternatively, the rule also accepts objects, where the selector and an optional custom message are specified:

    {
        "rules": {
            "no-restricted-syntax": [
                "error",
                {
                    "selector": "FunctionExpression",
                    "message": "Function expressions are not allowed."
                },
                {
                    "selector": "CallExpression[callee.name='setTimeout'][arguments.length!=2]",
                    "message": "setTimeout must always be invoked with two arguments."
                }
            ]
        }
    }

    If a custom message is specified with the message property, ESLint will use that message when reporting occurrences of the syntax specified in the selector property.

    The string and object formats can be freely mixed in the configuration as needed.

    Examples of incorrect code for this rule with the "FunctionExpression", "WithStatement", BinaryExpression[operator='in'] options:

    /* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"] */
    
    with (me) {
        dontMess();
    }
    
    var doSomething = function () {};
    
    foo in bar;

    Examples of correct code for this rule with the "FunctionExpression", "WithStatement", BinaryExpression[operator='in'] options:

    /* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"] */
    
    me.dontMess();
    
    function doSomething() {};
    
    foo instanceof bar;

    When Not To Use It

    If you don't want to restrict your code from using any JavaScript features or syntax, you should not use this rule.

    Related Rules

    • [no-alert](no-alert.md)
    • [no-console](no-console.md)
    • [no-debugger](no-debugger.md)
    • [no-restricted-properties](no-restricted-properties.md) Source: http://eslint.org/docs/rules/

    Expected 'this' to be used by class method 'import'.
    Open

      import(service) {
    Severity: Minor
    Found in src/core.js by eslint

    Enforce that class methods utilize this (class-methods-use-this)

    If a class method does not use this, it can safely be made a static function.

    It's possible to have a class method which doesn't use this, such as:

    class A {
        constructor() {
            this.a = "hi";
        }
    
        print() {
            console.log(this.a);
        }
    
        sayHi() {
            console.log("hi");
        }
    }
    
    let a = new A();
    a.sayHi(); // => "hi"

    In the example above, the sayHi method doesn't use this, so we can make it a static method:

    class A {
        constructor() {
            this.a = "hi";
        }
    
        print() {
            console.log(this.a);
        }
    
        static sayHi() {
            console.log("hi");
        }
    }
    
    A.sayHi(); // => "hi"

    Also note in the above examples that the code calling the function on an instance of the class (let a = new A(); a.sayHi();) changes to calling it on the class itself (A.sayHi();).

    Rule Details

    This rule is aimed to flag class methods that do not use this.

    Examples of incorrect code for this rule:

    /*eslint class-methods-use-this: "error"*/
    /*eslint-env es6*/
    
    class A {
        foo() {
            console.log("Hello World");     /*error Expected 'this' to be used by class method 'foo'.*/
        }
    }

    Examples of correct code for this rule:

    /*eslint class-methods-use-this: "error"*/
    /*eslint-env es6*/
    class A {
        foo() {
            this.bar = "Hello World"; // OK, this is used
        }
    }
    
    class A {
        constructor() {
            // OK. constructor is exempt
        }
    }
    
    class A {
        static foo() {
            // OK. static methods aren't expected to use this.
        }
    }

    Options

    Exceptions

    "class-methods-use-this": [<enabled>, { "exceptMethods": [&lt;...exceptions&gt;] }]</enabled>

    The exceptMethods option allows you to pass an array of method names for which you would like to ignore warnings.

    Examples of incorrect code for this rule when used without exceptMethods:

    /*eslint class-methods-use-this: "error"*/
    
    class A {
        foo() {
        }
    }

    Examples of correct code for this rule when used with exceptMethods:

    /*eslint class-methods-use-this: ["error", { "exceptMethods": ["foo"] }] */
    
    class A {
        foo() {
        }
    }

    Source: http://eslint.org/docs/rules/

    iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.
    Open

        for (const service of Ignis[$$services]) {
    Severity: Minor
    Found in src/core.js by eslint

    disallow specified syntax (no-restricted-syntax)

    JavaScript has a lot of language features, and not everyone likes all of them. As a result, some projects choose to disallow the use of certain language features altogether. For instance, you might decide to disallow the use of try-catch or class, or you might decide to disallow the use of the in operator.

    Rather than creating separate rules for every language feature you want to turn off, this rule allows you to configure the syntax elements you want to restrict use of. These elements are represented by their ESTree node types. For example, a function declaration is represented by FunctionDeclaration and the with statement is represented by WithStatement. You may find the full list of AST node names you can use on GitHub and use the online parser to see what type of nodes your code consists of.

    You can also specify [AST selectors](../developer-guide/selectors) to restrict, allowing much more precise control over syntax patterns.

    Rule Details

    This rule disallows specified (that is, user-defined) syntax.

    Options

    This rule takes a list of strings, where each string is an AST selector:

    {
        "rules": {
            "no-restricted-syntax": ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"]
        }
    }

    Alternatively, the rule also accepts objects, where the selector and an optional custom message are specified:

    {
        "rules": {
            "no-restricted-syntax": [
                "error",
                {
                    "selector": "FunctionExpression",
                    "message": "Function expressions are not allowed."
                },
                {
                    "selector": "CallExpression[callee.name='setTimeout'][arguments.length!=2]",
                    "message": "setTimeout must always be invoked with two arguments."
                }
            ]
        }
    }

    If a custom message is specified with the message property, ESLint will use that message when reporting occurrences of the syntax specified in the selector property.

    The string and object formats can be freely mixed in the configuration as needed.

    Examples of incorrect code for this rule with the "FunctionExpression", "WithStatement", BinaryExpression[operator='in'] options:

    /* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"] */
    
    with (me) {
        dontMess();
    }
    
    var doSomething = function () {};
    
    foo in bar;

    Examples of correct code for this rule with the "FunctionExpression", "WithStatement", BinaryExpression[operator='in'] options:

    /* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"] */
    
    me.dontMess();
    
    function doSomething() {};
    
    foo instanceof bar;

    When Not To Use It

    If you don't want to restrict your code from using any JavaScript features or syntax, you should not use this rule.

    Related Rules

    • [no-alert](no-alert.md)
    • [no-console](no-console.md)
    • [no-debugger](no-debugger.md)
    • [no-restricted-properties](no-restricted-properties.md) Source: http://eslint.org/docs/rules/

    iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.
    Open

          for (const dep of deps) { graph.push([ dep, name ]); }
    Severity: Minor
    Found in src/core.js by eslint

    disallow specified syntax (no-restricted-syntax)

    JavaScript has a lot of language features, and not everyone likes all of them. As a result, some projects choose to disallow the use of certain language features altogether. For instance, you might decide to disallow the use of try-catch or class, or you might decide to disallow the use of the in operator.

    Rather than creating separate rules for every language feature you want to turn off, this rule allows you to configure the syntax elements you want to restrict use of. These elements are represented by their ESTree node types. For example, a function declaration is represented by FunctionDeclaration and the with statement is represented by WithStatement. You may find the full list of AST node names you can use on GitHub and use the online parser to see what type of nodes your code consists of.

    You can also specify [AST selectors](../developer-guide/selectors) to restrict, allowing much more precise control over syntax patterns.

    Rule Details

    This rule disallows specified (that is, user-defined) syntax.

    Options

    This rule takes a list of strings, where each string is an AST selector:

    {
        "rules": {
            "no-restricted-syntax": ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"]
        }
    }

    Alternatively, the rule also accepts objects, where the selector and an optional custom message are specified:

    {
        "rules": {
            "no-restricted-syntax": [
                "error",
                {
                    "selector": "FunctionExpression",
                    "message": "Function expressions are not allowed."
                },
                {
                    "selector": "CallExpression[callee.name='setTimeout'][arguments.length!=2]",
                    "message": "setTimeout must always be invoked with two arguments."
                }
            ]
        }
    }

    If a custom message is specified with the message property, ESLint will use that message when reporting occurrences of the syntax specified in the selector property.

    The string and object formats can be freely mixed in the configuration as needed.

    Examples of incorrect code for this rule with the "FunctionExpression", "WithStatement", BinaryExpression[operator='in'] options:

    /* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"] */
    
    with (me) {
        dontMess();
    }
    
    var doSomething = function () {};
    
    foo in bar;

    Examples of correct code for this rule with the "FunctionExpression", "WithStatement", BinaryExpression[operator='in'] options:

    /* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"] */
    
    me.dontMess();
    
    function doSomething() {};
    
    foo instanceof bar;

    When Not To Use It

    If you don't want to restrict your code from using any JavaScript features or syntax, you should not use this rule.

    Related Rules

    • [no-alert](no-alert.md)
    • [no-console](no-console.md)
    • [no-debugger](no-debugger.md)
    • [no-restricted-properties](no-restricted-properties.md) Source: http://eslint.org/docs/rules/

    iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.
    Open

        for (const name of sorted) {
    Severity: Minor
    Found in src/core.js by eslint

    disallow specified syntax (no-restricted-syntax)

    JavaScript has a lot of language features, and not everyone likes all of them. As a result, some projects choose to disallow the use of certain language features altogether. For instance, you might decide to disallow the use of try-catch or class, or you might decide to disallow the use of the in operator.

    Rather than creating separate rules for every language feature you want to turn off, this rule allows you to configure the syntax elements you want to restrict use of. These elements are represented by their ESTree node types. For example, a function declaration is represented by FunctionDeclaration and the with statement is represented by WithStatement. You may find the full list of AST node names you can use on GitHub and use the online parser to see what type of nodes your code consists of.

    You can also specify [AST selectors](../developer-guide/selectors) to restrict, allowing much more precise control over syntax patterns.

    Rule Details

    This rule disallows specified (that is, user-defined) syntax.

    Options

    This rule takes a list of strings, where each string is an AST selector:

    {
        "rules": {
            "no-restricted-syntax": ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"]
        }
    }

    Alternatively, the rule also accepts objects, where the selector and an optional custom message are specified:

    {
        "rules": {
            "no-restricted-syntax": [
                "error",
                {
                    "selector": "FunctionExpression",
                    "message": "Function expressions are not allowed."
                },
                {
                    "selector": "CallExpression[callee.name='setTimeout'][arguments.length!=2]",
                    "message": "setTimeout must always be invoked with two arguments."
                }
            ]
        }
    }

    If a custom message is specified with the message property, ESLint will use that message when reporting occurrences of the syntax specified in the selector property.

    The string and object formats can be freely mixed in the configuration as needed.

    Examples of incorrect code for this rule with the "FunctionExpression", "WithStatement", BinaryExpression[operator='in'] options:

    /* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"] */
    
    with (me) {
        dontMess();
    }
    
    var doSomething = function () {};
    
    foo in bar;

    Examples of correct code for this rule with the "FunctionExpression", "WithStatement", BinaryExpression[operator='in'] options:

    /* eslint no-restricted-syntax: ["error", "FunctionExpression", "WithStatement", "BinaryExpression[operator='in']"] */
    
    me.dontMess();
    
    function doSomething() {};
    
    foo instanceof bar;

    When Not To Use It

    If you don't want to restrict your code from using any JavaScript features or syntax, you should not use this rule.

    Related Rules

    • [no-alert](no-alert.md)
    • [no-console](no-console.md)
    • [no-debugger](no-debugger.md)
    • [no-restricted-properties](no-restricted-properties.md) Source: http://eslint.org/docs/rules/

    Unexpected await inside a loop.
    Open

          await service.init(...deps);
    Severity: Minor
    Found in src/core.js by eslint

    Disallow await inside of loops (no-await-in-loop)

    Performing an operation on each element of an iterable is a common task. However, performing an await as part of each operation is an indication that the program is not taking full advantage of the parallelization benefits of async/await.

    Usually, the code should be refactored to create all the promises at once, then get access to the results using Promise.all(). Otherwise, each successive operation will not start until the previous one has completed.

    Concretely, the following function should be refactored as shown:

    async function foo(things) {
      const results = [];
      for (const thing of things) {
        // Bad: each loop iteration is delayed until the entire asynchronous operation completes
        results.push(await bar(thing));
      }
      return baz(results);
    }
    async function foo(things) {
      const results = [];
      for (const thing of things) {
        // Good: all asynchronous operations are immediately started.
        results.push(bar(thing));
      }
      // Now that all the asynchronous operations are running, here we wait until they all complete.
      return baz(await Promise.all(results));
    }

    Rule Details

    This rule disallows the use of await within loop bodies.

    Examples

    Examples of correct code for this rule:

    async function foo(things) {
      const results = [];
      for (const thing of things) {
        // Good: all asynchronous operations are immediately started.
        results.push(bar(thing));
      }
      // Now that all the asynchronous operations are running, here we wait until they all complete.
      return baz(await Promise.all(results));
    }

    Examples of incorrect code for this rule:

    async function foo(things) {
      const results = [];
      for (const thing of things) {
        // Bad: each loop iteration is delayed until the entire asynchronous operation completes
        results.push(await bar(thing));
      }
      return baz(results);
    }

    When Not To Use It

    In many cases the iterations of a loop are not actually independent of each-other. For example, the output of one iteration might be used as the input to another. Or, loops may be used to retry asynchronous operations that were unsuccessful. In such cases it makes sense to use await within a loop and it is recommended to disable the rule via a standard ESLint disable comment. Source: http://eslint.org/docs/rules/

    Expected 'this' to be used by class method 'env'.
    Open

      env(expr) {
    Severity: Minor
    Found in src/core.js by eslint

    Enforce that class methods utilize this (class-methods-use-this)

    If a class method does not use this, it can safely be made a static function.

    It's possible to have a class method which doesn't use this, such as:

    class A {
        constructor() {
            this.a = "hi";
        }
    
        print() {
            console.log(this.a);
        }
    
        sayHi() {
            console.log("hi");
        }
    }
    
    let a = new A();
    a.sayHi(); // => "hi"

    In the example above, the sayHi method doesn't use this, so we can make it a static method:

    class A {
        constructor() {
            this.a = "hi";
        }
    
        print() {
            console.log(this.a);
        }
    
        static sayHi() {
            console.log("hi");
        }
    }
    
    A.sayHi(); // => "hi"

    Also note in the above examples that the code calling the function on an instance of the class (let a = new A(); a.sayHi();) changes to calling it on the class itself (A.sayHi();).

    Rule Details

    This rule is aimed to flag class methods that do not use this.

    Examples of incorrect code for this rule:

    /*eslint class-methods-use-this: "error"*/
    /*eslint-env es6*/
    
    class A {
        foo() {
            console.log("Hello World");     /*error Expected 'this' to be used by class method 'foo'.*/
        }
    }

    Examples of correct code for this rule:

    /*eslint class-methods-use-this: "error"*/
    /*eslint-env es6*/
    class A {
        foo() {
            this.bar = "Hello World"; // OK, this is used
        }
    }
    
    class A {
        constructor() {
            // OK. constructor is exempt
        }
    }
    
    class A {
        static foo() {
            // OK. static methods aren't expected to use this.
        }
    }

    Options

    Exceptions

    "class-methods-use-this": [<enabled>, { "exceptMethods": [&lt;...exceptions&gt;] }]</enabled>

    The exceptMethods option allows you to pass an array of method names for which you would like to ignore warnings.

    Examples of incorrect code for this rule when used without exceptMethods:

    /*eslint class-methods-use-this: "error"*/
    
    class A {
        foo() {
        }
    }

    Examples of correct code for this rule when used with exceptMethods:

    /*eslint class-methods-use-this: ["error", { "exceptMethods": ["foo"] }] */
    
    class A {
        foo() {
        }
    }

    Source: http://eslint.org/docs/rules/

    There are no issues that match your filters.

    Category
    Status