kubosho/kotori

View on GitHub
src/stats.js

Summary

Maintainability
A
1 hr
Test Coverage

Line 42 exceeds the maximum line length of 100.
Open

    const statsFileName = path.basename(this.statsTargetFilePath, path.extname(this.statsTargetFilePath));
Severity: Minor
Found in src/stats.js by eslint

enforce a maximum line length (max-len)

Very long lines of code in any language can be difficult to read. In order to aid in readability and maintainability many coders have developed a convention to limit lines of code to X number of characters (traditionally 80 characters).

var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" }; // very long

Rule Details

This rule enforces a maximum line length to increase code readability and maintainability. The length of a line is defined as the number of Unicode characters in the line.

Options

This rule has a number or object option:

  • "code" (default 80) enforces a maximum line length
  • "tabWidth" (default 4) specifies the character width for tab characters
  • "comments" enforces a maximum line length for comments; defaults to value of code
  • "ignorePattern" ignores lines matching a regular expression; can only match a single line and need to be double escaped when written in YAML or JSON
  • "ignoreComments": true ignores all trailing comments and comments on their own line
  • "ignoreTrailingComments": true ignores only trailing comments
  • "ignoreUrls": true ignores lines that contain a URL
  • "ignoreStrings": true ignores lines that contain a double-quoted or single-quoted string
  • "ignoreTemplateLiterals": true ignores lines that contain a template literal
  • "ignoreRegExpLiterals": true ignores lines that contain a RegExp literal

code

Examples of incorrect code for this rule with the default { "code": 80 } option:

/*eslint max-len: ["error", 80]*/

var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" }, "difficult": "to read" };

Examples of correct code for this rule with the default { "code": 80 } option:

/*eslint max-len: ["error", 80]*/

var foo = {
  "bar": "This is a bar.",
  "baz": { "qux": "This is a qux" },
  "easier": "to read"
};

tabWidth

Examples of incorrect code for this rule with the default { "tabWidth": 4 } option:

/*eslint max-len: ["error", 80, 4]*/

\t  \t  var foo = { "bar": "This is a bar.", "baz": { "qux": "This is a qux" } };

Examples of correct code for this rule with the default { "tabWidth": 4 } option:

/*eslint max-len: ["error", 80, 4]*/

\t  \t  var foo = {
\t  \t  \t  \t  "bar": "This is a bar.",
\t  \t  \t  \t  "baz": { "qux": "This is a qux" }
\t  \t  };

comments

Examples of incorrect code for this rule with the { "comments": 65 } option:

/*eslint max-len: ["error", { "comments": 65 }]*/

/**
 * This is a comment that violates the maximum line length we have specified
**/

ignoreComments

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

/*eslint max-len: ["error", { "ignoreComments": true }]*/

/**
 * This is a really really really really really really really really really long comment
**/

ignoreTrailingComments

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

/*eslint max-len: ["error", { "ignoreTrailingComments": true }]*/

var foo = 'bar'; // This is a really really really really really really really long comment

ignoreUrls

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

/*eslint max-len: ["error", { "ignoreUrls": true }]*/

var url = 'https://www.example.com/really/really/really/really/really/really/really/long';

ignoreStrings

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

/*eslint max-len: ["error", { "ignoreStrings": true }]*/

var longString = 'this is a really really really really really long string!';

ignoreTemplateLiterals

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

/*eslint max-len: ["error", { "ignoreTemplateLiterals": true }]*/

var longTemplateLiteral = `this is a really really really really really long template literal!`;

ignoreRegExpLiterals

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

/*eslint max-len: ["error", { "ignoreRegExpLiterals": true }]*/

var longRegExpLiteral = /this is a really really really really really long regular expression!/;

ignorePattern

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

/*eslint max-len: ["error", { "ignorePattern": "^\\s*var\\s.+=\\s*require\\s*\\(/" }]*/

var dep = require('really/really/really/really/really/really/really/really/long/module');

Related Rules

  • [complexity](complexity.md)
  • [max-depth](max-depth.md)
  • [max-nested-callbacks](max-nested-callbacks.md)
  • [max-params](max-params.md)
  • [max-statements](max-statements.md) Source: http://eslint.org/docs/rules/

Function writeStats has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  writeStats(statsData) {
    const statsFileName = path.basename(this.statsTargetFilePath, path.extname(this.statsTargetFilePath));
    const statsOutputDir = `${process.cwd()}/${this.statsConf.outputDir}`;
    const format = new Format(statsData);
    const formatData = selectFormat(this.statsConf.outputFormat);
Severity: Minor
Found in src/stats.js - About 1 hr to fix

    Expected indentation of 4 spaces but found 6.
    Open

          break;
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Expected indentation of 2 spaces but found 4.
    Open

        default:
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Expected indentation of 2 spaces but found 4.
    Open

        case "html":
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Expected indentation of 4 spaces but found 6.
    Open

          break;
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Expected indentation of 4 spaces but found 6.
    Open

          method = "toHTML";
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Expected indentation of 2 spaces but found 4.
    Open

        case "md":
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Expected indentation of 4 spaces but found 6.
    Open

          break;
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Identifier name 'statsTargetFilePath' is too long (> 16).
    Open

      constructor(statsTargetFilePath, statsConf) {
    Severity: Minor
    Found in src/stats.js by eslint

    enforce minimum and maximum identifier lengths (id-length)

    Very short identifier names like e, x, _t or very long ones like hashGeneratorResultOutputContainerObject can make code harder to read and potentially less maintainable. To prevent this, one may enforce a minimum and/or maximum identifier length.

    var x = 5; // too short; difficult to understand its purpose without context

    Rule Details

    This rule enforces a minimum and/or maximum identifier length convention.

    Options

    Examples of incorrect code for this rule with the default options:

    /*eslint id-length: "error"*/     // default is minimum 2-chars ({ "min": 2 })
    /*eslint-env es6*/
    
    var x = 5;
    obj.e = document.body;
    var foo = function (e) { };
    try {
        dangerousStuff();
    } catch (e) {
        // ignore as many do
    }
    var myObj = { a: 1 };
    (a) => { a * a };
    class x { }
    class Foo { x() {} }
    function foo(...x) { }
    var { x } = {};
    var { x: a} = {};
    var { a: [x]} = {};
    ({ prop: obj.x }) = {};

    Examples of correct code for this rule with the default options:

    /*eslint id-length: "error"*/     // default is minimum 2-chars ({ "min": 2 })
    /*eslint-env es6*/
    
    var num = 5;
    function _f() { return 42; }
    function _func() { return 42; }
    obj.el = document.body;
    var foo = function (evt) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (error) {
        // ignore as many do
    }
    var myObj = { apple: 1 };
    (num) => { num * num };
    function foo(num = 0) { }
    class MyClass { }
    class Foo { method() {} }
    function foo(...args) { }
    var { prop } = {};
    var { prop: a } = {};
    var { prop: [x] } = {};
    ({ prop: obj.longName }) = {};
    var data = { "x": 1 };  // excused because of quotes
    data["y"] = 3;  // excused because of calculated property access

    This rule has a shorthand integer option for the "min" object property.

    Examples of incorrect code for this rule with a minimum of 4:

    /*eslint id-length: ["error", 4]*/
    /*eslint-env es6*/
    
    var val = 5;
    obj.e = document.body;
    function (e) { };
    try {
        dangerousStuff();
    } catch (e) {
        // ignore as many do
    }
    var myObj = { a: 1 };
    (val) => { val * val };
    class x { }
    class Foo { x() {} }
    function foo(...x) { }
    var { x } = {};
    var { x: a} = {};
    var { a: [x]} = {};
    ({ prop: obj.x }) = {};

    Examples of correct code for this rule with a minimum of 4:

    /*eslint id-length: ["error", 4]*/
    /*eslint-env es6*/
    
    var value = 5;
    function func() { return 42; }
    obj.element = document.body;
    var foo = function (event) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (error) {
        // ignore as many do
    }
    var myObj = { apple: 1 };
    (value) => { value * value };
    function foobar(value = 0) { }
    class MyClass { }
    class Foobar { method() {} }
    function foobar(...args) { }
    var { prop } = {};
    var { prop: a } = {};
    var { prop: [x] } = {};
    ({ prop: obj.name }) = {};
    var data = { "x": 1 };  // excused because of quotes
    data["y"] = 3;  // excused because of calculated property access

    This rule has an object option:

    • "min" (default: 2) enforces a minimum identifier length
    • "max" (default: Infinity) enforces a maximum identifier length
    • "properties": always (default) enforces identifier length convention for property names
    • "properties": never ignores identifier length convention for property names
    • "exceptions" allows an array of specified identifier names

    min

    Examples of incorrect code for this rule with the { "min": 4 } option:

    /*eslint id-length: ["error", { "min": 4 }]*/
    /*eslint-env es6*/
    
    var val = 5;
    obj.e = document.body;
    function (e) { };
    try {
        dangerousStuff();
    } catch (e) {
        // ignore as many do
    }
    var myObj = { a: 1 };
    (val) => { val * val };
    class x { }
    class Foo { x() {} }
    function foo(...x) { }
    var { x } = {};
    var { x: a} = {};
    var { a: [x]} = {};
    ({ prop: obj.x }) = {};

    Examples of correct code for this rule with the { "min": 4 } option:

    /*eslint id-length: ["error", { "min": 4 }]*/
    /*eslint-env es6*/
    
    var value = 5;
    function func() { return 42; }
    obj.element = document.body;
    var foo = function (event) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (error) {
        // ignore as many do
    }
    var myObj = { apple: 1 };
    (value) => { value * value };
    function foobar(value = 0) { }
    class MyClass { }
    class Foobar { method() {} }
    function foobar(...args) { }
    var { prop } = {};
    var { prop: a } = {};
    var { prop: [x] } = {};
    ({ prop: obj.name }) = {};
    var data = { "x": 1 };  // excused because of quotes
    data["y"] = 3;  // excused because of calculated property access

    max

    Examples of incorrect code for this rule with the { "max": 10 } option:

    /*eslint id-length: ["error", { "max": "10" }]*/
    /*eslint-env es6*/
    
    var reallyLongVarName = 5;
    function reallyLongFuncName() { return 42; }
    obj.reallyLongPropName = document.body;
    var foo = function (reallyLongArgName) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (reallyLongErrorName) {
        // ignore as many do
    }
    (reallyLongArgName) => { return !reallyLongArgName; };

    Examples of correct code for this rule with the { "max": 10 } option:

    /*eslint id-length: ["error", { "max": "10" }]*/
    /*eslint-env es6*/
    
    var varName = 5;
    function funcName() { return 42; }
    obj.propName = document.body;
    var foo = function (arg) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (error) {
        // ignore as many do
    }
    (arg) => { return !arg; };

    properties

    Examples of correct code for this rule with the { "properties": "never" } option:

    /*eslint id-length: ["error", { "properties": "never" }]*/
    /*eslint-env es6*/
    
    var myObj = { a: 1 };
    ({ a: obj.x.y.z }) = {};
    ({ prop: obj.i }) = {};

    exceptions

    Examples of additional correct code for this rule with the { "exceptions": ["x"] } option:

    /*eslint id-length: ["error", { "exceptions": ["x"] }]*/
    /*eslint-env es6*/
    
    var x = 5;
    function x() { return 42; }
    obj.x = document.body;
    var foo = function (x) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (x) {
        // ignore as many do
    }
    (x) => { return x * x; };

    Related Rules

    'extension' is never reassigned. Use 'const' instead.
    Open

      let extension = `.${format}`;
    Severity: Minor
    Found in src/stats.js by eslint

    Suggest using const (prefer-const)

    If a variable is never reassigned, using the const declaration is better.

    const declaration tells readers, "this variable is never reassigned," reducing cognitive load and improving maintainability.

    Rule Details

    This rule is aimed at flagging variables that are declared using let keyword, but never reassigned after the initial assignment.

    Examples of incorrect code for this rule:

    /*eslint prefer-const: "error"*/
    /*eslint-env es6*/
    
    // it's initialized and never reassigned.
    let a = 3;
    console.log(a);
    
    let a;
    a = 0;
    console.log(a);
    
    // `i` is redefined (not reassigned) on each loop step.
    for (let i in [1, 2, 3]) {
        console.log(i);
    }
    
    // `a` is redefined (not reassigned) on each loop step.
    for (let a of [1, 2, 3]) {
        console.log(a);
    }

    Examples of correct code for this rule:

    /*eslint prefer-const: "error"*/
    /*eslint-env es6*/
    
    // using const.
    const a = 0;
    
    // it's never initialized.
    let a;
    console.log(a);
    
    // it's reassigned after initialized.
    let a;
    a = 0;
    a = 1;
    console.log(a);
    
    // it's initialized in a different block from the declaration.
    let a;
    if (true) {
        a = 0;
    }
    console.log(a);
    
    // it's initialized at a place that we cannot write a variable declaration.
    let a;
    if (true) a = 0;
    console.log(a);
    
    // `i` gets a new binding each iteration
    for (const i in [1, 2, 3]) {
      console.log(i);
    }
    
    // `a` gets a new binding each iteration
    for (const a of [1, 2, 3]) {
      console.log(a);
    }
    
    // `end` is never reassigned, but we cannot separate the declarations without modifying the scope.
    for (let i = 0, end = 10; i < end; ++i) {
        console.log(a);
    }
    
    // suggest to use `no-var` rule.
    var b = 3;
    console.log(b);

    Options

    {
        "prefer-const": ["error", {
            "destructuring": "any",
            "ignoreReadBeforeAssign": false
        }]
    }

    destructuring

    The kind of the way to address variables in destructuring. There are 2 values:

    • "any" (default) - If any variables in destructuring should be const, this rule warns for those variables.
    • "all" - If all variables in destructuring should be const, this rule warns the variables. Otherwise, ignores them.

    Examples of incorrect code for the default {"destructuring": "any"} option:

    /*eslint prefer-const: "error"*/
    /*eslint-env es6*/
    
    let {a, b} = obj;    /*error 'b' is never reassigned, use 'const' instead.*/
    a = a + 1;

    Examples of correct code for the default {"destructuring": "any"} option:

    /*eslint prefer-const: "error"*/
    /*eslint-env es6*/
    
    // using const.
    const {a: a0, b} = obj;
    const a = a0 + 1;
    
    // all variables are reassigned.
    let {a, b} = obj;
    a = a + 1;
    b = b + 1;

    Examples of incorrect code for the {"destructuring": "all"} option:

    /*eslint prefer-const: ["error", {"destructuring": "all"}]*/
    /*eslint-env es6*/
    
    // all of `a` and `b` should be const, so those are warned.
    let {a, b} = obj;    /*error 'a' is never reassigned, use 'const' instead.
                                 'b' is never reassigned, use 'const' instead.*/

    Examples of correct code for the {"destructuring": "all"} option:

    /*eslint prefer-const: ["error", {"destructuring": "all"}]*/
    /*eslint-env es6*/
    
    // 'b' is never reassigned, but all of `a` and `b` should not be const, so those are ignored.
    let {a, b} = obj;
    a = a + 1;

    ignoreReadBeforeAssign

    This is an option to avoid conflicting with no-use-before-define rule (without "nofunc" option). If true is specified, this rule will ignore variables that are read between the declaration and the first assignment. Default is false.

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

    /*eslint prefer-const: ["error", {"ignoreReadBeforeAssign": true}]*/
    /*eslint-env es6*/
    
    let timer;
    function initialize() {
        if (foo()) {
            clearInterval(timer);
        }
    }
    timer = setInterval(initialize, 100);

    Examples of correct code for the default {"ignoreReadBeforeAssign": false} option:

    /*eslint prefer-const: ["error", {"ignoreReadBeforeAssign": false}]*/
    /*eslint-env es6*/
    
    const timer = setInterval(initialize, 100);
    function initialize() {
        if (foo()) {
            clearInterval(timer);
        }
    }

    When Not To Use It

    If you don't want to be notified about variables that are never reassigned after initial assignment, you can safely disable this rule.

    Related Rules

    Expected indentation of 4 spaces but found 6.
    Open

          method = "toJSON";
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Expected indentation of 4 spaces but found 6.
    Open

          method = "toMarkdown";
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Expected indentation of 2 spaces but found 4.
    Open

        case "json":
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Expected indentation of 2 spaces but found 4.
    Open

        case "csv":
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Identifier name 'statsTargetFilePath' is too long (> 16).
    Open

        this.statsTargetFilePath = statsTargetFilePath;
    Severity: Minor
    Found in src/stats.js by eslint

    enforce minimum and maximum identifier lengths (id-length)

    Very short identifier names like e, x, _t or very long ones like hashGeneratorResultOutputContainerObject can make code harder to read and potentially less maintainable. To prevent this, one may enforce a minimum and/or maximum identifier length.

    var x = 5; // too short; difficult to understand its purpose without context

    Rule Details

    This rule enforces a minimum and/or maximum identifier length convention.

    Options

    Examples of incorrect code for this rule with the default options:

    /*eslint id-length: "error"*/     // default is minimum 2-chars ({ "min": 2 })
    /*eslint-env es6*/
    
    var x = 5;
    obj.e = document.body;
    var foo = function (e) { };
    try {
        dangerousStuff();
    } catch (e) {
        // ignore as many do
    }
    var myObj = { a: 1 };
    (a) => { a * a };
    class x { }
    class Foo { x() {} }
    function foo(...x) { }
    var { x } = {};
    var { x: a} = {};
    var { a: [x]} = {};
    ({ prop: obj.x }) = {};

    Examples of correct code for this rule with the default options:

    /*eslint id-length: "error"*/     // default is minimum 2-chars ({ "min": 2 })
    /*eslint-env es6*/
    
    var num = 5;
    function _f() { return 42; }
    function _func() { return 42; }
    obj.el = document.body;
    var foo = function (evt) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (error) {
        // ignore as many do
    }
    var myObj = { apple: 1 };
    (num) => { num * num };
    function foo(num = 0) { }
    class MyClass { }
    class Foo { method() {} }
    function foo(...args) { }
    var { prop } = {};
    var { prop: a } = {};
    var { prop: [x] } = {};
    ({ prop: obj.longName }) = {};
    var data = { "x": 1 };  // excused because of quotes
    data["y"] = 3;  // excused because of calculated property access

    This rule has a shorthand integer option for the "min" object property.

    Examples of incorrect code for this rule with a minimum of 4:

    /*eslint id-length: ["error", 4]*/
    /*eslint-env es6*/
    
    var val = 5;
    obj.e = document.body;
    function (e) { };
    try {
        dangerousStuff();
    } catch (e) {
        // ignore as many do
    }
    var myObj = { a: 1 };
    (val) => { val * val };
    class x { }
    class Foo { x() {} }
    function foo(...x) { }
    var { x } = {};
    var { x: a} = {};
    var { a: [x]} = {};
    ({ prop: obj.x }) = {};

    Examples of correct code for this rule with a minimum of 4:

    /*eslint id-length: ["error", 4]*/
    /*eslint-env es6*/
    
    var value = 5;
    function func() { return 42; }
    obj.element = document.body;
    var foo = function (event) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (error) {
        // ignore as many do
    }
    var myObj = { apple: 1 };
    (value) => { value * value };
    function foobar(value = 0) { }
    class MyClass { }
    class Foobar { method() {} }
    function foobar(...args) { }
    var { prop } = {};
    var { prop: a } = {};
    var { prop: [x] } = {};
    ({ prop: obj.name }) = {};
    var data = { "x": 1 };  // excused because of quotes
    data["y"] = 3;  // excused because of calculated property access

    This rule has an object option:

    • "min" (default: 2) enforces a minimum identifier length
    • "max" (default: Infinity) enforces a maximum identifier length
    • "properties": always (default) enforces identifier length convention for property names
    • "properties": never ignores identifier length convention for property names
    • "exceptions" allows an array of specified identifier names

    min

    Examples of incorrect code for this rule with the { "min": 4 } option:

    /*eslint id-length: ["error", { "min": 4 }]*/
    /*eslint-env es6*/
    
    var val = 5;
    obj.e = document.body;
    function (e) { };
    try {
        dangerousStuff();
    } catch (e) {
        // ignore as many do
    }
    var myObj = { a: 1 };
    (val) => { val * val };
    class x { }
    class Foo { x() {} }
    function foo(...x) { }
    var { x } = {};
    var { x: a} = {};
    var { a: [x]} = {};
    ({ prop: obj.x }) = {};

    Examples of correct code for this rule with the { "min": 4 } option:

    /*eslint id-length: ["error", { "min": 4 }]*/
    /*eslint-env es6*/
    
    var value = 5;
    function func() { return 42; }
    obj.element = document.body;
    var foo = function (event) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (error) {
        // ignore as many do
    }
    var myObj = { apple: 1 };
    (value) => { value * value };
    function foobar(value = 0) { }
    class MyClass { }
    class Foobar { method() {} }
    function foobar(...args) { }
    var { prop } = {};
    var { prop: a } = {};
    var { prop: [x] } = {};
    ({ prop: obj.name }) = {};
    var data = { "x": 1 };  // excused because of quotes
    data["y"] = 3;  // excused because of calculated property access

    max

    Examples of incorrect code for this rule with the { "max": 10 } option:

    /*eslint id-length: ["error", { "max": "10" }]*/
    /*eslint-env es6*/
    
    var reallyLongVarName = 5;
    function reallyLongFuncName() { return 42; }
    obj.reallyLongPropName = document.body;
    var foo = function (reallyLongArgName) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (reallyLongErrorName) {
        // ignore as many do
    }
    (reallyLongArgName) => { return !reallyLongArgName; };

    Examples of correct code for this rule with the { "max": 10 } option:

    /*eslint id-length: ["error", { "max": "10" }]*/
    /*eslint-env es6*/
    
    var varName = 5;
    function funcName() { return 42; }
    obj.propName = document.body;
    var foo = function (arg) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (error) {
        // ignore as many do
    }
    (arg) => { return !arg; };

    properties

    Examples of correct code for this rule with the { "properties": "never" } option:

    /*eslint id-length: ["error", { "properties": "never" }]*/
    /*eslint-env es6*/
    
    var myObj = { a: 1 };
    ({ a: obj.x.y.z }) = {};
    ({ prop: obj.i }) = {};

    exceptions

    Examples of additional correct code for this rule with the { "exceptions": ["x"] } option:

    /*eslint id-length: ["error", { "exceptions": ["x"] }]*/
    /*eslint-env es6*/
    
    var x = 5;
    function x() { return 42; }
    obj.x = document.body;
    var foo = function (x) { /* do stuff */ };
    try {
        dangerousStuff();
    } catch (x) {
        // ignore as many do
    }
    (x) => { return x * x; };

    Related Rules

    Expected indentation of 4 spaces but found 6.
    Open

          break;
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Missing space after key 'method'.
    Open

        method: method
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent spacing between keys and values in object literal properties (key-spacing)

    This rule enforces spacing around the colon in object literal properties. It can verify each property individually, or it can ensure horizontal alignment of adjacent properties in an object literal.

    Rule Details

    This rule enforces consistent spacing between keys and values in object literal properties. In the case of long lines, it is acceptable to add a new line wherever whitespace is allowed.

    Options

    This rule has an object option:

    • "beforeColon": false (default) disallows spaces between the key and the colon in object literals.
    • "beforeColon": true requires at least one space between the key and the colon in object literals.
    • "afterColon": true (default) requires at least one space between the colon and the value in object literals.
    • "afterColon": false disallows spaces between the colon and the value in object literals.
    • "mode": "strict" (default) enforces exactly one space before or after colons in object literals.
    • "mode": "minimum" enforces one or more spaces before or after colons in object literals.
    • "align": "value" enforces horizontal alignment of values in object literals.
    • "align": "colon" enforces horizontal alignment of both colons and values in object literals.
    • "align" with an object value allows for fine-grained spacing when values are being aligned in object literals.
    • "singleLine" specifies a spacing style for single-line object literals.
    • "multiLine" specifies a spacing style for multi-line object literals.

    Please note that you can either use the top-level options or the grouped options (singleLine and multiLine) but not both.

    beforeColon

    Examples of incorrect code for this rule with the default { "beforeColon": false } option:

    /*eslint key-spacing: ["error", { "beforeColon": false }]*/
    
    var obj = { "foo" : 42 };

    Examples of correct code for this rule with the default { "beforeColon": false } option:

    /*eslint key-spacing: ["error", { "beforeColon": false }]*/
    
    var obj = { "foo": 42 };

    Examples of incorrect code for this rule with the { "beforeColon": true } option:

    /*eslint key-spacing: ["error", { "beforeColon": true }]*/
    
    var obj = { "foo": 42 };

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

    /*eslint key-spacing: ["error", { "beforeColon": true }]*/
    
    var obj = { "foo" : 42 };

    afterColon

    Examples of incorrect code for this rule with the default { "afterColon": true } option:

    /*eslint key-spacing: ["error", { "afterColon": true }]*/
    
    var obj = { "foo":42 };

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

    /*eslint key-spacing: ["error", { "afterColon": true }]*/
    
    var obj = { "foo": 42 };

    Examples of incorrect code for this rule with the { "afterColon": false } option:

    /*eslint key-spacing: ["error", { "afterColon": false }]*/
    
    var obj = { "foo": 42 };

    Examples of correct code for this rule with the { "afterColon": false } option:

    /*eslint key-spacing: ["error", { "afterColon": false }]*/
    
    var obj = { "foo":42 };

    mode

    Examples of incorrect code for this rule with the default { "mode": "strict" } option:

    /*eslint key-spacing: ["error", { "mode": "strict" }]*/
    
    call({
        foobar: 42,
        bat:    2 * 2
    });

    Examples of correct code for this rule with the default { "mode": "strict" } option:

    /*eslint key-spacing: ["error", { "mode": "strict" }]*/
    
    call({
        foobar: 42,
        bat: 2 * 2
    });

    Examples of correct code for this rule with the { "mode": "minimum" } option:

    /*eslint key-spacing: ["error", { "mode": "minimum" }]*/
    
    call({
        foobar: 42,
        bat:    2 * 2
    });

    align

    Examples of incorrect code for this rule with the { "align": "value" } option:

    /*eslint key-spacing: ["error", { "align": "value" }]*/
    
    var obj = {
        a: value,
        bcde:  42,
        fg :   foo()
    };

    Examples of correct code for this rule with the { "align": "value" } option:

    /*eslint key-spacing: ["error", { "align": "value" }]*/
    
    var obj = {
        a:    value,
        bcde: 42,
    
        fg: foo(),
        h:  function() {
            return this.a;
        },
        ijkl: 'Non-consecutive lines form a new group'
    };
    
    var obj = { a: "foo", longPropertyName: "bar" };

    Examples of incorrect code for this rule with the { "align": "colon" } option:

    /*eslint key-spacing: ["error", { "align": "colon" }]*/
    
    call({
        foobar: 42,
        bat:    2 * 2
    });

    Examples of correct code for this rule with the { "align": "colon" } option:

    /*eslint key-spacing: ["error", { "align": "colon" }]*/
    
    call({
        foobar: 42,
        bat   : 2 * 2
    });

    align

    The align option can take additional configuration through the beforeColon, afterColon, mode, and on options.

    If align is defined as an object, but not all of the parameters are provided, undefined parameters will default to the following:

    // Defaults
    align: {
        "beforeColon": false,
        "afterColon": true,
        "on": "colon",
        "mode": "strict"
    }

    Examples of correct code for this rule with sample { "align": { } } options:

    /*eslint key-spacing: ["error", {
        "align": {
            "beforeColon": true,
            "afterColon": true,
            "on": "colon"
        }
    }]*/
    
    var obj = {
        "one"   : 1,
        "seven" : 7
    }
    /*eslint key-spacing: ["error", {
        "align": {
            "beforeColon": false,
            "afterColon": false,
            "on": "value"
        }
    }]*/
    
    var obj = {
        "one":  1,
        "seven":7
    }

    align and multiLine

    The multiLine and align options can differ, which allows for fine-tuned control over the key-spacing of your files. align will not inherit from multiLine if align is configured as an object.

    multiLine is used any time an object literal spans multiple lines. The align configuration is used when there is a group of properties in the same object. For example:

    var myObj = {
      key1: 1, // uses multiLine
    
      key2: 2, // uses align (when defined)
      key3: 3, // uses align (when defined)
    
      key4: 4 // uses multiLine
    }

    Examples of incorrect code for this rule with sample { "align": { }, "multiLine": { } } options:

    /*eslint key-spacing: ["error", {
        "multiLine": {
            "beforeColon": false,
            "afterColon":true
        },
        "align": {
            "beforeColon": true,
            "afterColon": true,
            "on": "colon"
        }
    }]*/
    
    var obj = {
        "myObjectFunction": function() {
            // Do something
        },
        "one"             : 1,
        "seven"           : 7
    }

    Examples of correct code for this rule with sample { "align": { }, "multiLine": { } } options:

    /*eslint key-spacing: ["error", {
        "multiLine": {
            "beforeColon": false,
            "afterColon": true
    
        },
        "align": {
            "beforeColon": true,
            "afterColon": true,
            "on": "colon"
        }
    }]*/
    
    var obj = {
        "myObjectFunction": function() {
            // Do something
            //
        }, // These are two separate groups, so no alignment between `myObjectFuction` and `one`
        "one"   : 1,
        "seven" : 7 // `one` and `seven` are in their own group, and therefore aligned
    }

    singleLine and multiLine

    Examples of correct code for this rule with sample { "singleLine": { }, "multiLine": { } } options:

    /*eslint "key-spacing": [2, {
        "singleLine": {
            "beforeColon": false,
            "afterColon": true
        },
        "multiLine": {
            "beforeColon": true,
            "afterColon": true,
            "align": "colon"
        }
    }]*/
    var obj = { one: 1, "two": 2, three: 3 };
    var obj2 = {
        "two" : 2,
        three : 3
    };

    When Not To Use It

    If you have another convention for property spacing that might not be consistent with the available options, or if you want to permit multiple styles concurrently you can safely disable this rule. Source: http://eslint.org/docs/rules/

    Expected indentation of 4 spaces but found 6.
    Open

          break;
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    Expected indentation of 4 spaces but found 6.
    Open

          method = "toCSV";
    Severity: Minor
    Found in src/stats.js by eslint

    enforce consistent indentation (indent)

    There are several common guidelines which require specific indentation of nested blocks and statements, like:

    function hello(indentSize, type) {
        if (indentSize === 4 && type !== 'tab') {
            console.log('Each next indentation will increase on 4 spaces');
        }
    }

    These are the most common scenarios recommended in different style guides:

    • Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix
    • Tabs: jQuery
    • Four spaces: Crockford

    Rule Details

    This rule enforces a consistent indentation style. The default style is 4 spaces.

    Options

    This rule has a mixed option:

    For example, for 2-space indentation:

    {
        "indent": ["error", 2]
    }

    Or for tabbed indentation:

    {
        "indent": ["error", "tab"]
    }

    Examples of incorrect code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
      b=c;
      function foo(d) {
        e=f;
      }
    }

    Examples of correct code for this rule with the default options:

    /*eslint indent: "error"*/
    
    if (a) {
        b=c;
        function foo(d) {
            e=f;
        }
    }

    This rule has an object option:

    • "SwitchCase" (default: 0) enforces indentation level for case clauses in switch statements
    • "VariableDeclarator" (default: 1) enforces indentation level for var declarators; can also take an object to define separate rules for var, let and const declarations.
    • "outerIIFEBody" (default: 1) enforces indentation level for file-level IIFEs.
    • "MemberExpression" (off by default) enforces indentation level for multi-line property chains (except in variable declarations and assignments)
    • "FunctionDeclaration" takes an object to define rules for function declarations.
      • parameters (off by default) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the declaration must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function declaration.
    • "FunctionExpression" takes an object to define rules for function expressions.
      • parameters (off by default) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string "first" indicating that all parameters of the expression must be aligned with the first parameter.
      • body (default: 1) enforces indentation level for the body of a function expression.
    • "CallExpression" takes an object to define rules for function call expressions.
      • arguments (off by default) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string "first" indicating that all arguments of the expression must be aligned with the first argument.
    • "ArrayExpression" (default: 1) enforces indentation level for elements in arrays. It can also be set to the string "first", indicating that all the elements in the array should be aligned with the first element.
    • "ObjectExpression" (default: 1) enforces indentation level for properties in objects. It can be set to the string "first", indicating that all properties in the object should be aligned with the first property.

    Level of indentation denotes the multiple of the indent specified. Example:

    • Indent of 4 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 8 spaces.
    • Indent of 2 spaces with VariableDeclarator set to 2 will indent the multi-line variable declarations with 4 spaces.
    • Indent of 2 spaces with VariableDeclarator set to {"var": 2, "let": 2, "const": 3} will indent the multi-line variable declarations with 4 spaces for var and let, 6 spaces for const statements.
    • Indent of tab with VariableDeclarator set to 2 will indent the multi-line variable declarations with 2 tabs.
    • Indent of 2 spaces with SwitchCase set to 0 will not indent case clauses with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 1 will indent case clauses with 2 spaces with respect to switch statements.
    • Indent of 2 spaces with SwitchCase set to 2 will indent case clauses with 4 spaces with respect to switch statements.
    • Indent of tab with SwitchCase set to 2 will indent case clauses with 2 tabs with respect to switch statements.
    • Indent of 2 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 2 spaces with MemberExpression set to 1 will indent the multi-line property chains with 2 spaces.
    • Indent of 2 spaces with MemberExpression set to 2 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 0 will indent the multi-line property chains with 0 spaces.
    • Indent of 4 spaces with MemberExpression set to 1 will indent the multi-line property chains with 4 spaces.
    • Indent of 4 spaces with MemberExpression set to 2 will indent the multi-line property chains with 8 spaces.

    tab

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
         b=c;
    function foo(d) {
               e=f;
     }
    }

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

    /*eslint indent: ["error", "tab"]*/
    
    if (a) {
    /*tab*/b=c;
    /*tab*/function foo(d) {
    /*tab*//*tab*/e=f;
    /*tab*/}
    }

    SwitchCase

    Examples of incorrect code for this rule with the 2, { "SwitchCase": 1 } options:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
    case "a":
        break;
    case "b":
        break;
    }

    Examples of correct code for this rule with the 2, { "SwitchCase": 1 } option:

    /*eslint indent: ["error", 2, { "SwitchCase": 1 }]*/
    
    switch(a){
      case "a":
        break;
      case "b":
        break;
    }

    VariableDeclarator

    Examples of incorrect code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 1 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 1 }]*/
    /*eslint-env es6*/
    
    var a,
      b,
      c;
    let a,
      b,
      c;
    const a = 1,
      b = 2,
      c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": 2 } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": 2 }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
        b = 2,
        c = 3;

    Examples of correct code for this rule with the 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } options:

    /*eslint indent: ["error", 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }]*/
    /*eslint-env es6*/
    
    var a,
        b,
        c;
    let a,
        b,
        c;
    const a = 1,
          b = 2,
          c = 3;

    outerIIFEBody

    Examples of incorrect code for this rule with the options 2, { "outerIIFEBody": 0 }:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
      function foo(x) {
        return x + 1;
      }
    
    })();
    
    
    if(y) {
    console.log('foo');
    }

    Examples of correct code for this rule with the options 2, {"outerIIFEBody": 0}:

    /*eslint indent: ["error", 2, { "outerIIFEBody": 0 }]*/
    
    (function() {
    
    function foo(x) {
      return x + 1;
    }
    
    })();
    
    
    if(y) {
       console.log('foo');
    }

    MemberExpression

    Examples of incorrect code for this rule with the 2, { "MemberExpression": 1 } options:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
    .bar
    .baz()

    Examples of correct code for this rule with the 2, { "MemberExpression": 1 } option:

    /*eslint indent: ["error", 2, { "MemberExpression": 1 }]*/
    
    foo
      .bar
      .baz();
    
    // Any indentation is permitted in variable declarations and assignments.
    var bip = aardvark.badger
                      .coyote;

    FunctionDeclaration

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }]*/
    
    function foo(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionDeclaration": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionDeclaration": {"parameters": "first"}}]*/
    
    function foo(bar, baz,
                 qux, boop) {
      qux();
    }

    FunctionExpression

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
      baz,
      qux) {
        qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"body": 1, "parameters": 2} } option:

    /*eslint indent: ["error", 2, { "FunctionExpression": {"body": 1, "parameters": 2} }]*/
    
    var foo = function(bar,
        baz,
        qux) {
      qux();
    }

    Examples of incorrect code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
      qux, boop) {
      qux();
    }

    Examples of correct code for this rule with the 2, { "FunctionExpression": {"parameters": "first"} } option:

    /*eslint indent: ["error", 2, {"FunctionExpression": {"parameters": "first"}}]*/
    
    var foo = function(bar, baz,
                       qux, boop) {
      qux();
    }

    CallExpression

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
        baz,
          qux
    );

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": 1} } option:

    /*eslint indent: ["error", 2, { "CallExpression": {"arguments": 1} }]*/
    
    foo(bar,
      baz,
      qux
    );

    Examples of incorrect code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
      baz, boop, beep);

    Examples of correct code for this rule with the 2, { "CallExpression": {"arguments": "first"} } option:

    /*eslint indent: ["error", 2, {"CallExpression": {"arguments": "first"}}]*/
    
    foo(bar, baz,
        baz, boop, beep);

    ArrayExpression

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
        bar,
    baz,
          qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ArrayExpression": 1 }]*/
    
    var foo = [
      bar,
      baz,
      qux
    ];

    Examples of incorrect code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
      baz,
      qux
    ];

    Examples of correct code for this rule with the 2, { "ArrayExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ArrayExpression": "first"}]*/
    
    var foo = [bar,
               baz,
               qux
    ];

    ObjectExpression

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
        bar: 1,
    baz: 2,
          qux: 3
    };

    Examples of correct code for this rule with the 2, { "ObjectExpression": 1 } option:

    /*eslint indent: ["error", 2, { "ObjectExpression": 1 }]*/
    
    var foo = {
      bar: 1,
      baz: 2,
      qux: 3
    };

    Examples of incorrect code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
      baz: 2 };

    Examples of correct code for this rule with the 2, { "ObjectExpression": "first" } option:

    /*eslint indent: ["error", 2, {"ObjectExpression": "first"}]*/
    
    var foo = { bar: 1,
                baz: 2 };

    Compatibility

    There are no issues that match your filters.

    Category
    Status