cloudfoundry/cloud_controller_ng

View on GitHub
docs/v3/source/javascripts/lib/_lunr.js

Summary

Maintainability
F
5 days
Test Coverage

File _lunr.js has 884 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.5.7
 * Copyright (C) 2014 Oliver Nightingale
 * MIT Licensed
 * @license
Severity: Major
Found in docs/v3/source/javascripts/lib/_lunr.js - About 2 days to fix

    Function 'porterStemmer' has too many statements (83). Maximum allowed is 30.
    Open

        var porterStemmer = function porterStemmer(w) {

    enforce a maximum number of statements allowed in function blocks (max-statements)

    The max-statements rule allows you to specify the maximum number of statements allowed in a function.

    function foo() {
      var bar = 1; // one statement
      var baz = 2; // two statements
      var qux = 3; // three statements
    }

    Rule Details

    This rule enforces a maximum number of statements allowed in function blocks.

    Options

    This rule has a number or object option:

    • "max" (default 10) enforces a maximum number of statements allows in function blocks

    Deprecated: The object property maximum is deprecated; please use the object property max instead.

    This rule has an object option:

    • "ignoreTopLevelFunctions": true ignores top-level functions

    max

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

    /*eslint max-statements: ["error", 10]*/
    /*eslint-env es6*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
    
      var foo11 = 11; // Too many.
    }
    
    let foo = () => {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
    
      var foo11 = 11; // Too many.
    };

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

    /*eslint max-statements: ["error", 10]*/
    /*eslint-env es6*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      return function () {
    
        // The number of statements in the inner function does not count toward the
        // statement maximum.
    
        return 42;
      };
    }
    
    let foo = () => {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      return function () {
    
        // The number of statements in the inner function does not count toward the
        // statement maximum.
    
        return 42;
      };
    }

    ignoreTopLevelFunctions

    Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

    /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      var foo11 = 11;
    }

    Related Rules

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

    Function has too many statements (81). Maximum allowed is 30.
    Open

    (function(){

    enforce a maximum number of statements allowed in function blocks (max-statements)

    The max-statements rule allows you to specify the maximum number of statements allowed in a function.

    function foo() {
      var bar = 1; // one statement
      var baz = 2; // two statements
      var qux = 3; // three statements
    }

    Rule Details

    This rule enforces a maximum number of statements allowed in function blocks.

    Options

    This rule has a number or object option:

    • "max" (default 10) enforces a maximum number of statements allows in function blocks

    Deprecated: The object property maximum is deprecated; please use the object property max instead.

    This rule has an object option:

    • "ignoreTopLevelFunctions": true ignores top-level functions

    max

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

    /*eslint max-statements: ["error", 10]*/
    /*eslint-env es6*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
    
      var foo11 = 11; // Too many.
    }
    
    let foo = () => {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
    
      var foo11 = 11; // Too many.
    };

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

    /*eslint max-statements: ["error", 10]*/
    /*eslint-env es6*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      return function () {
    
        // The number of statements in the inner function does not count toward the
        // statement maximum.
    
        return 42;
      };
    }
    
    let foo = () => {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      return function () {
    
        // The number of statements in the inner function does not count toward the
        // statement maximum.
    
        return 42;
      };
    }

    ignoreTopLevelFunctions

    Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

    /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      var foo11 = 11;
    }

    Related Rules

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

    Function stemmer has 166 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      lunr.stemmer = (function(){
        var step2list = {
              "ational" : "ate",
              "tional" : "tion",
              "enci" : "ence",
    Severity: Major
    Found in docs/v3/source/javascripts/lib/_lunr.js - About 6 hrs to fix

      Function porterStemmer has 103 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var porterStemmer = function porterStemmer(w) {
            var   stem,
                suffix,
                firstch,
                re,
      Severity: Major
      Found in docs/v3/source/javascripts/lib/_lunr.js - About 4 hrs to fix

        Function 'porterStemmer' has a complexity of 26.
        Open

            var porterStemmer = function porterStemmer(w) {

        Limit Cyclomatic Complexity (complexity)

        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

        function a(x) {
            if (true) {
                return x; // 1st path
            } else if (false) {
                return x+1; // 2nd path
            } else {
                return 4; // 3rd path
            }
        }

        Rule Details

        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

        Examples of incorrect code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else if (false) {
                return x+1;
            } else {
                return 4; // 3rd path
            }
        }

        Examples of correct code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else {
                return 4;
            }
        }

        Options

        Optionally, you may specify a max object property:

        "complexity": ["error", 2]

        is equivalent to

        "complexity": ["error", { "max": 2 }]

        Deprecated: the object property maximum is deprecated. Please use the property max instead.

        When Not To Use It

        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

        Further Reading

        Related Rules

        • [max-depth](max-depth.md)
        • [max-len](max-len.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 has a complexity of 8.
        Open

          lunr.SortedSet.prototype.indexOf = function (elem, start, end) {

        Limit Cyclomatic Complexity (complexity)

        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

        function a(x) {
            if (true) {
                return x; // 1st path
            } else if (false) {
                return x+1; // 2nd path
            } else {
                return 4; // 3rd path
            }
        }

        Rule Details

        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

        Examples of incorrect code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else if (false) {
                return x+1;
            } else {
                return 4; // 3rd path
            }
        }

        Examples of correct code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else {
                return 4;
            }
        }

        Options

        Optionally, you may specify a max object property:

        "complexity": ["error", 2]

        is equivalent to

        "complexity": ["error", { "max": 2 }]

        Deprecated: the object property maximum is deprecated. Please use the property max instead.

        When Not To Use It

        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

        Further Reading

        Related Rules

        • [max-depth](max-depth.md)
        • [max-len](max-len.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 has a complexity of 8.
        Open

          lunr.SortedSet.prototype.locationFor = function (elem, start, end) {

        Limit Cyclomatic Complexity (complexity)

        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

        function a(x) {
            if (true) {
                return x; // 1st path
            } else if (false) {
                return x+1; // 2nd path
            } else {
                return 4; // 3rd path
            }
        }

        Rule Details

        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

        Examples of incorrect code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else if (false) {
                return x+1;
            } else {
                return 4; // 3rd path
            }
        }

        Examples of correct code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else {
                return 4;
            }
        }

        Options

        Optionally, you may specify a max object property:

        "complexity": ["error", 2]

        is equivalent to

        "complexity": ["error", { "max": 2 }]

        Deprecated: the object property maximum is deprecated. Please use the property max instead.

        When Not To Use It

        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

        Further Reading

        Related Rules

        • [max-depth](max-depth.md)
        • [max-len](max-len.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 has a complexity of 7.
        Open

          lunr.SortedSet.prototype.intersect = function (otherSet) {

        Limit Cyclomatic Complexity (complexity)

        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

        function a(x) {
            if (true) {
                return x; // 1st path
            } else if (false) {
                return x+1; // 2nd path
            } else {
                return 4; // 3rd path
            }
        }

        Rule Details

        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

        Examples of incorrect code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else if (false) {
                return x+1;
            } else {
                return 4; // 3rd path
            }
        }

        Examples of correct code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else {
                return 4;
            }
        }

        Options

        Optionally, you may specify a max object property:

        "complexity": ["error", 2]

        is equivalent to

        "complexity": ["error", { "max": 2 }]

        Deprecated: the object property maximum is deprecated. Please use the property max instead.

        When Not To Use It

        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

        Further Reading

        Related Rules

        • [max-depth](max-depth.md)
        • [max-len](max-len.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 has a complexity of 7.
        Open

          lunr.tokenizer = function (obj) {

        Limit Cyclomatic Complexity (complexity)

        Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold.

        function a(x) {
            if (true) {
                return x; // 1st path
            } else if (false) {
                return x+1; // 2nd path
            } else {
                return 4; // 3rd path
            }
        }

        Rule Details

        This rule is aimed at reducing code complexity by capping the amount of cyclomatic complexity allowed in a program. As such, it will warn when the cyclomatic complexity crosses the configured threshold (default is 20).

        Examples of incorrect code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else if (false) {
                return x+1;
            } else {
                return 4; // 3rd path
            }
        }

        Examples of correct code for a maximum of 2:

        /*eslint complexity: ["error", 2]*/
        
        function a(x) {
            if (true) {
                return x;
            } else {
                return 4;
            }
        }

        Options

        Optionally, you may specify a max object property:

        "complexity": ["error", 2]

        is equivalent to

        "complexity": ["error", { "max": 2 }]

        Deprecated: the object property maximum is deprecated. Please use the property max instead.

        When Not To Use It

        If you can't determine an appropriate complexity limit for your code, then it's best to disable this rule.

        Further Reading

        Related Rules

        • [max-depth](max-depth.md)
        • [max-len](max-len.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 search has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          lunr.Index.prototype.search = function (query) {
            var queryTokens = this.pipeline.run(lunr.tokenizer(query)),
                queryVector = new lunr.Vector,
                documentSets = [],
                fieldBoosts = this._fields.reduce(function (memo, f) { return memo + f.boost }, 0)
        Severity: Minor
        Found in docs/v3/source/javascripts/lib/_lunr.js - About 1 hr to fix

          Avoid too many return statements within this function.
          Open

              if (pivotElem === elem) return pivot
          Severity: Major
          Found in docs/v3/source/javascripts/lib/_lunr.js - About 30 mins to fix

            'emitEvent' is already defined.
            Open

                    emitEvent = emitEvent === undefined ? true : emitEvent

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            'memo' is already defined.
            Open

                    memo = memo || []

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Unnecessary semicolon.
            Open

                };

            disallow unnecessary semicolons (no-extra-semi)

            Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.

            Rule Details

            This rule disallows unnecessary semicolons.

            Examples of incorrect code for this rule:

            /*eslint no-extra-semi: "error"*/
            
            var x = 5;;
            
            function foo() {
                // code
            };

            Examples of correct code for this rule:

            /*eslint no-extra-semi: "error"*/
            
            var x = 5;
            
            var foo = function() {
                // code
            };

            When Not To Use It

            If you intentionally use extra semicolons then you can disable this rule.

            Related Rules

            'fp' is already defined.
            Open

                    var fp = re2.exec(w);

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            'fp' is already defined.
            Open

                    var fp = re2.exec(w);

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Use ‘===’ to compare with ‘null’.
            Open

                if (!arguments.length || obj == null || obj == undefined) return []

            Disallow Null Comparisons (no-eq-null)

            Comparing to null without a type-checking operator (== or !=), can have unintended results as the comparison will evaluate to true when comparing to not just a null, but also an undefined value.

            if (foo == null) {
              bar();
            }

            Rule Details

            The no-eq-null rule aims reduce potential bug and unwanted behavior by ensuring that comparisons to null only match null, and not also undefined. As such it will flag comparisons to null when using == and !=.

            Examples of incorrect code for this rule:

            /*eslint no-eq-null: "error"*/
            
            if (foo == null) {
              bar();
            }
            
            while (qux != null) {
              baz();
            }

            Examples of correct code for this rule:

            /*eslint no-eq-null: "error"*/
            
            if (foo === null) {
              bar();
            }
            
            while (qux !== null) {
              baz();
            }

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

            Unnecessary semicolon.
            Open

                };

            disallow unnecessary semicolons (no-extra-semi)

            Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.

            Rule Details

            This rule disallows unnecessary semicolons.

            Examples of incorrect code for this rule:

            /*eslint no-extra-semi: "error"*/
            
            var x = 5;;
            
            function foo() {
                // code
            };

            Examples of correct code for this rule:

            /*eslint no-extra-semi: "error"*/
            
            var x = 5;
            
            var foo = function() {
                // code
            };

            When Not To Use It

            If you intentionally use extra semicolons then you can disable this rule.

            Related Rules

            Unnecessary semicolon.
            Open

                };

            disallow unnecessary semicolons (no-extra-semi)

            Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.

            Rule Details

            This rule disallows unnecessary semicolons.

            Examples of incorrect code for this rule:

            /*eslint no-extra-semi: "error"*/
            
            var x = 5;;
            
            function foo() {
                // code
            };

            Examples of correct code for this rule:

            /*eslint no-extra-semi: "error"*/
            
            var x = 5;
            
            var foo = function() {
                // code
            };

            When Not To Use It

            If you intentionally use extra semicolons then you can disable this rule.

            Related Rules

            'fp' is already defined.
            Open

                    var fp = re.exec(w);

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Expected '!==' and instead saw '!='.
            Open

                while (next != undefined) {

            Require === and !== (eqeqeq)

            It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

            The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

            • [] == false
            • [] == ![]
            • 3 == "03"

            If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

            Rule Details

            This rule is aimed at eliminating the type-unsafe equality operators.

            Examples of incorrect code for this rule:

            /*eslint eqeqeq: "error"*/
            
            if (x == 42) { }
            
            if ("" == text) { }
            
            if (obj.getStuff() != undefined) { }

            The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

            Options

            always

            The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

            Examples of incorrect code for the "always" option:

            /*eslint eqeqeq: ["error", "always"]*/
            
            a == b
            foo == true
            bananas != 1
            value == undefined
            typeof foo == 'undefined'
            'hello' != 'world'
            0 == 0
            true == true
            foo == null

            Examples of correct code for the "always" option:

            /*eslint eqeqeq: ["error", "always"]*/
            
            a === b
            foo === true
            bananas !== 1
            value === undefined
            typeof foo === 'undefined'
            'hello' !== 'world'
            0 === 0
            true === true
            foo === null

            This rule optionally takes a second argument, which should be an object with the following supported properties:

            • "null": Customize how this rule treats null literals. Possible values:
              • always (default) - Always use === or !==.
              • never - Never use === or !== with null.
              • ignore - Do not apply this rule to null.

            smart

            The "smart" option enforces the use of === and !== except for these cases:

            • Comparing two literal values
            • Evaluating the value of typeof
            • Comparing against null

            Examples of incorrect code for the "smart" option:

            /*eslint eqeqeq: ["error", "smart"]*/
            
            // comparing two variables requires ===
            a == b
            
            // only one side is a literal
            foo == true
            bananas != 1
            
            // comparing to undefined requires ===
            value == undefined

            Examples of correct code for the "smart" option:

            /*eslint eqeqeq: ["error", "smart"]*/
            
            typeof foo == 'undefined'
            'hello' != 'world'
            0 == 0
            true == true
            foo == null

            allow-null

            Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

            ["error", "always", {"null": "ignore"}]

            When Not To Use It

            If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

            'start' is already defined.
            Open

                var start = start || 0,

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            'end' is already defined.
            Open

                    end = end || this.elements.length,

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Expected '===' and instead saw '=='.
            Open

                if (!arguments.length || obj == null || obj == undefined) return []

            Require === and !== (eqeqeq)

            It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

            The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

            • [] == false
            • [] == ![]
            • 3 == "03"

            If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

            Rule Details

            This rule is aimed at eliminating the type-unsafe equality operators.

            Examples of incorrect code for this rule:

            /*eslint eqeqeq: "error"*/
            
            if (x == 42) { }
            
            if ("" == text) { }
            
            if (obj.getStuff() != undefined) { }

            The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

            Options

            always

            The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

            Examples of incorrect code for the "always" option:

            /*eslint eqeqeq: ["error", "always"]*/
            
            a == b
            foo == true
            bananas != 1
            value == undefined
            typeof foo == 'undefined'
            'hello' != 'world'
            0 == 0
            true == true
            foo == null

            Examples of correct code for the "always" option:

            /*eslint eqeqeq: ["error", "always"]*/
            
            a === b
            foo === true
            bananas !== 1
            value === undefined
            typeof foo === 'undefined'
            'hello' !== 'world'
            0 === 0
            true === true
            foo === null

            This rule optionally takes a second argument, which should be an object with the following supported properties:

            • "null": Customize how this rule treats null literals. Possible values:
              • always (default) - Always use === or !==.
              • never - Never use === or !== with null.
              • ignore - Do not apply this rule to null.

            smart

            The "smart" option enforces the use of === and !== except for these cases:

            • Comparing two literal values
            • Evaluating the value of typeof
            • Comparing against null

            Examples of incorrect code for the "smart" option:

            /*eslint eqeqeq: ["error", "smart"]*/
            
            // comparing two variables requires ===
            a == b
            
            // only one side is a literal
            foo == true
            bananas != 1
            
            // comparing to undefined requires ===
            value == undefined

            Examples of correct code for the "smart" option:

            /*eslint eqeqeq: ["error", "smart"]*/
            
            typeof foo == 'undefined'
            'hello' != 'world'
            0 == 0
            true == true
            foo == null

            allow-null

            Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

            ["error", "always", {"null": "ignore"}]

            When Not To Use It

            If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

            Unnecessary semicolon.
            Open

                  };

            disallow unnecessary semicolons (no-extra-semi)

            Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.

            Rule Details

            This rule disallows unnecessary semicolons.

            Examples of incorrect code for this rule:

            /*eslint no-extra-semi: "error"*/
            
            var x = 5;;
            
            function foo() {
                // code
            };

            Examples of correct code for this rule:

            /*eslint no-extra-semi: "error"*/
            
            var x = 5;
            
            var foo = function() {
                // code
            };

            When Not To Use It

            If you intentionally use extra semicolons then you can disable this rule.

            Related Rules

            Expected an assignment or function call and instead saw an expression.
            Open

                  prev = next, next = next.next

            Disallow Unused Expressions (no-unused-expressions)

            An unused expression which has no effect on the state of the program indicates a logic error.

            For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

            Rule Details

            This rule aims to eliminate unused expressions which have no effect on the state of the program.

            This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

            var i = 0;
            function increment() { i += 1; }
            increment(); // return value is unused, but i changed as a side effect
            
            var nThings = 0;
            function Thing() { nThings += 1; }
            new Thing(); // constructed object is unused, but nThings changed as a side effect

            This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

            Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

            Options

            This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

            • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
            • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
            • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

            These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

            Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

            /*eslint no-unused-expressions: "error"*/
            
            0
            
            if(0) 0
            
            {0}
            
            f(0), {}
            
            a && b()
            
            a, b()
            
            c = a, b;
            
            a() && function namedFunctionInExpressionContext () {f();}
            
            (function anIncompleteIIFE () {});
            
            injectGlobal`body{ color: red; }`

            Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

            "use strict";
            "use asm"
            "use stricter";
            "use babel"
            "any other strings like this in the prologue";

            Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

            /*eslint no-unused-expressions: "error"*/
            
            {} // In this context, this is a block statement, not an object literal
            
            {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
            
            function namedFunctionDeclaration () {}
            
            (function aGenuineIIFE () {}());
            
            f()
            
            a = 0
            
            new C
            
            delete a.b
            
            void a

            allowShortCircuit

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

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
            
            a || b

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

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
            
            a && b()
            a() || (b = c)

            allowTernary

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

            /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
            
            a ? b : 0
            a ? b : c()

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

            /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
            
            a ? b() : c()
            a ? (b = c) : d()

            allowShortCircuit and allowTernary

            Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
            
            a ? b() || (c = d) : e()

            allowTaggedTemplates

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

            /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
            
            `some untagged template string`;

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

            /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
            
            tag`some tagged template string`;

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

            Return statement should not contain assignment.
            Open

                return this._magnitude = Math.sqrt(sumOfSquares)

            Disallow Assignment in return Statement (no-return-assign)

            One of the interesting, and sometimes confusing, aspects of JavaScript is that assignment can happen at almost any point. Because of this, an errant equals sign can end up causing assignment when the true intent was to do a comparison. This is especially true when using a return statement. For example:

            function doSomething() {
                return foo = bar + 2;
            }

            It is difficult to tell the intent of the return statement here. It's possible that the function is meant to return the result of bar + 2, but then why is it assigning to foo? It's also possible that the intent was to use a comparison operator such as == and that this code is an error.

            Because of this ambiguity, it's considered a best practice to not use assignment in return statements.

            Rule Details

            This rule aims to eliminate assignments from return statements. As such, it will warn whenever an assignment is found as part of return.

            Options

            The rule takes one option, a string, which must contain one of the following values:

            • except-parens (default): Disallow assignments unless they are enclosed in parentheses.
            • always: Disallow all assignments.

            except-parens

            This is the default option. It disallows assignments unless they are enclosed in parentheses.

            Examples of incorrect code for the default "except-parens" option:

            /*eslint no-return-assign: "error"*/
            
            function doSomething() {
                return foo = bar + 2;
            }
            
            function doSomething() {
                return foo += 2;
            }

            Examples of correct code for the default "except-parens" option:

            /*eslint no-return-assign: "error"*/
            
            function doSomething() {
                return foo == bar + 2;
            }
            
            function doSomething() {
                return foo === bar + 2;
            }
            
            function doSomething() {
                return (foo = bar + 2);
            }

            always

            This option disallows all assignments in return statements. All assignments are treated as problems.

            Examples of incorrect code for the "always" option:

            /*eslint no-return-assign: ["error", "always"]*/
            
            function doSomething() {
                return foo = bar + 2;
            }
            
            function doSomething() {
                return foo += 2;
            }
            
            function doSomething() {
                return (foo = bar + 2);
            }

            Examples of correct code for the "always" option:

            /*eslint no-return-assign: ["error", "always"]*/
            
            function doSomething() {
                return foo == bar + 2;
            }
            
            function doSomething() {
                return foo === bar + 2;
            }

            When Not To Use It

            If you want to allow the use of assignment operators in a return statement, then you can safely disable this rule. Source: http://eslint.org/docs/rules/

            'start' is already defined.
            Open

                var start = start || 0,

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Don't make functions within a loop.
            Open

                  var tf = this._fields.reduce(function (memo, field) {

            Disallow Functions in Loops (no-loop-func)

            Writing functions within loops tends to result in errors due to the way the function creates a closure around the loop. For example:

            for (var i = 0; i < 10; i++) {
                funcs[i] = function() {
                    return i;
                };
            }

            In this case, you would expect each function created within the loop to return a different number. In reality, each function returns 10, because that was the last value of i in the scope.

            let or const mitigate this problem.

            /*eslint-env es6*/
            
            for (let i = 0; i < 10; i++) {
                funcs[i] = function() {
                    return i;
                };
            }

            In this case, each function created within the loop returns a different number as expected.

            Rule Details

            This error is raised to highlight a piece of code that may not work as you expect it to and could also indicate a misunderstanding of how the language works. Your code may run without any problems if you do not fix this error, but in some situations it could behave unexpectedly.

            Examples of incorrect code for this rule:

            /*eslint no-loop-func: "error"*/
            /*eslint-env es6*/
            
            for (var i=10; i; i--) {
                (function() { return i; })();
            }
            
            while(i) {
                var a = function() { return i; };
                a();
            }
            
            do {
                function a() { return i; };
                a();
            } while (i);
            
            let foo = 0;
            for (let i=10; i; i--) {
                // Bad, function is referencing block scoped variable in the outer scope.
                var a = function() { return foo; };
                a();
            }

            Examples of correct code for this rule:

            /*eslint no-loop-func: "error"*/
            /*eslint-env es6*/
            
            var a = function() {};
            
            for (var i=10; i; i--) {
                a();
            }
            
            for (var i=10; i; i--) {
                var a = function() {}; // OK, no references to variables in the outer scopes.
                a();
            }
            
            for (let i=10; i; i--) {
                var a = function() { return i; }; // OK, all references are referring to block scoped variables in the loop.
                a();
            }
            
            var foo = 100;
            for (let i=10; i; i--) {
                var a = function() { return foo; }; // OK, all references are referring to never modified variables.
                a();
            }
            //... no modifications of foo after this loop ...

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

            'fp' is already defined.
            Open

                    var fp = re.exec(w);

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Expected '===' and instead saw '=='.
            Open

                if (!arguments.length || obj == null || obj == undefined) return []

            Require === and !== (eqeqeq)

            It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

            The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

            • [] == false
            • [] == ![]
            • 3 == "03"

            If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

            Rule Details

            This rule is aimed at eliminating the type-unsafe equality operators.

            Examples of incorrect code for this rule:

            /*eslint eqeqeq: "error"*/
            
            if (x == 42) { }
            
            if ("" == text) { }
            
            if (obj.getStuff() != undefined) { }

            The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

            Options

            always

            The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

            Examples of incorrect code for the "always" option:

            /*eslint eqeqeq: ["error", "always"]*/
            
            a == b
            foo == true
            bananas != 1
            value == undefined
            typeof foo == 'undefined'
            'hello' != 'world'
            0 == 0
            true == true
            foo == null

            Examples of correct code for the "always" option:

            /*eslint eqeqeq: ["error", "always"]*/
            
            a === b
            foo === true
            bananas !== 1
            value === undefined
            typeof foo === 'undefined'
            'hello' !== 'world'
            0 === 0
            true === true
            foo === null

            This rule optionally takes a second argument, which should be an object with the following supported properties:

            • "null": Customize how this rule treats null literals. Possible values:
              • always (default) - Always use === or !==.
              • never - Never use === or !== with null.
              • ignore - Do not apply this rule to null.

            smart

            The "smart" option enforces the use of === and !== except for these cases:

            • Comparing two literal values
            • Evaluating the value of typeof
            • Comparing against null

            Examples of incorrect code for the "smart" option:

            /*eslint eqeqeq: ["error", "smart"]*/
            
            // comparing two variables requires ===
            a == b
            
            // only one side is a literal
            foo == true
            bananas != 1
            
            // comparing to undefined requires ===
            value == undefined

            Examples of correct code for the "smart" option:

            /*eslint eqeqeq: ["error", "smart"]*/
            
            typeof foo == 'undefined'
            'hello' != 'world'
            0 == 0
            true == true
            foo == null

            allow-null

            Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

            ["error", "always", {"null": "ignore"}]

            When Not To Use It

            If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

            'emitEvent' is already defined.
            Open

                var emitEvent = emitEvent === undefined ? true : emitEvent

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Expected '===' and instead saw '=='.
            Open

                  if (firstch == "y") {

            Require === and !== (eqeqeq)

            It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

            The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

            • [] == false
            • [] == ![]
            • 3 == "03"

            If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

            Rule Details

            This rule is aimed at eliminating the type-unsafe equality operators.

            Examples of incorrect code for this rule:

            /*eslint eqeqeq: "error"*/
            
            if (x == 42) { }
            
            if ("" == text) { }
            
            if (obj.getStuff() != undefined) { }

            The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

            Options

            always

            The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

            Examples of incorrect code for the "always" option:

            /*eslint eqeqeq: ["error", "always"]*/
            
            a == b
            foo == true
            bananas != 1
            value == undefined
            typeof foo == 'undefined'
            'hello' != 'world'
            0 == 0
            true == true
            foo == null

            Examples of correct code for the "always" option:

            /*eslint eqeqeq: ["error", "always"]*/
            
            a === b
            foo === true
            bananas !== 1
            value === undefined
            typeof foo === 'undefined'
            'hello' !== 'world'
            0 === 0
            true === true
            foo === null

            This rule optionally takes a second argument, which should be an object with the following supported properties:

            • "null": Customize how this rule treats null literals. Possible values:
              • always (default) - Always use === or !==.
              • never - Never use === or !== with null.
              • ignore - Do not apply this rule to null.

            smart

            The "smart" option enforces the use of === and !== except for these cases:

            • Comparing two literal values
            • Evaluating the value of typeof
            • Comparing against null

            Examples of incorrect code for the "smart" option:

            /*eslint eqeqeq: ["error", "smart"]*/
            
            // comparing two variables requires ===
            a == b
            
            // only one side is a literal
            foo == true
            bananas != 1
            
            // comparing to undefined requires ===
            value == undefined

            Examples of correct code for the "smart" option:

            /*eslint eqeqeq: ["error", "smart"]*/
            
            typeof foo == 'undefined'
            'hello' != 'world'
            0 == 0
            true == true
            foo == null

            allow-null

            Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

            ["error", "always", {"null": "ignore"}]

            When Not To Use It

            If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

            Expected an assignment or function call and instead saw an expression.
            Open

                  longSet = this, shortSet = otherSet

            Disallow Unused Expressions (no-unused-expressions)

            An unused expression which has no effect on the state of the program indicates a logic error.

            For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

            Rule Details

            This rule aims to eliminate unused expressions which have no effect on the state of the program.

            This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

            var i = 0;
            function increment() { i += 1; }
            increment(); // return value is unused, but i changed as a side effect
            
            var nThings = 0;
            function Thing() { nThings += 1; }
            new Thing(); // constructed object is unused, but nThings changed as a side effect

            This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

            Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

            Options

            This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

            • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
            • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
            • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

            These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

            Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

            /*eslint no-unused-expressions: "error"*/
            
            0
            
            if(0) 0
            
            {0}
            
            f(0), {}
            
            a && b()
            
            a, b()
            
            c = a, b;
            
            a() && function namedFunctionInExpressionContext () {f();}
            
            (function anIncompleteIIFE () {});
            
            injectGlobal`body{ color: red; }`

            Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

            "use strict";
            "use asm"
            "use stricter";
            "use babel"
            "any other strings like this in the prologue";

            Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

            /*eslint no-unused-expressions: "error"*/
            
            {} // In this context, this is a block statement, not an object literal
            
            {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
            
            function namedFunctionDeclaration () {}
            
            (function aGenuineIIFE () {}());
            
            f()
            
            a = 0
            
            new C
            
            delete a.b
            
            void a

            allowShortCircuit

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

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
            
            a || b

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

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
            
            a && b()
            a() || (b = c)

            allowTernary

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

            /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
            
            a ? b : 0
            a ? b : c()

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

            /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
            
            a ? b() : c()
            a ? (b = c) : d()

            allowShortCircuit and allowTernary

            Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
            
            a ? b() || (c = d) : e()

            allowTaggedTemplates

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

            /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
            
            `some untagged template string`;

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

            /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
            
            tag`some tagged template string`;

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

            Unexpected constant condition.
            Open

                while (true) {

            disallow constant expressions in conditions (no-constant-condition)

            A constant expression (for example, a literal) as a test condition might be a typo or development trigger for a specific behavior. For example, the following code looks as if it is not ready for production.

            if (false) {
                doSomethingUnfinished();
            }

            Rule Details

            This rule disallows constant expressions in the test condition of:

            • if, for, while, or do...while statement
            • ?: ternary expression

            Examples of incorrect code for this rule:

            /*eslint no-constant-condition: "error"*/
            
            if (false) {
                doSomethingUnfinished();
            }
            
            if (void x) {
                doSomethingUnfinished();
            }
            
            for (;-2;) {
                doSomethingForever();
            }
            
            while (typeof x) {
                doSomethingForever();
            }
            
            do {
                doSomethingForever();
            } while (x = -1);
            
            var result = 0 ? a : b;

            Examples of correct code for this rule:

            /*eslint no-constant-condition: "error"*/
            
            if (x === 0) {
                doSomething();
            }
            
            for (;;) {
                doSomethingForever();
            }
            
            while (typeof x === "undefined") {
                doSomething();
            }
            
            do {
                doSomething();
            } while (x);
            
            var result = x !== 0 ? a : b;

            Options

            checkLoops

            Set to true by default. Setting this option to false allows constant expressions in loops.

            Examples of correct code for when checkLoops is false:

            /*eslint no-constant-condition: ["error", { "checkLoops": false }]*/
            
            while (true) {
                doSomething();
                if (condition()) {
                    break;
                }
            };
            
            for (;true;) {
                doSomething();
                if (condition()) {
                    break;
                }
            };
            
            do {
                doSomething();
                if (condition()) {
                    break;
                }
            } while (true)

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

            'fp' is already defined.
            Open

                    var fp = re.exec(w);

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            'end' is already defined.
            Open

                    end = end || this.elements.length,

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Unnecessary semicolon.
            Open

                };

            disallow unnecessary semicolons (no-extra-semi)

            Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.

            Rule Details

            This rule disallows unnecessary semicolons.

            Examples of incorrect code for this rule:

            /*eslint no-extra-semi: "error"*/
            
            var x = 5;;
            
            function foo() {
                // code
            };

            Examples of correct code for this rule:

            /*eslint no-extra-semi: "error"*/
            
            var x = 5;
            
            var foo = function() {
                // code
            };

            When Not To Use It

            If you intentionally use extra semicolons then you can disable this rule.

            Related Rules

            Expected an assignment or function call and instead saw an expression.
            Open

                  longSet = otherSet, shortSet = this

            Disallow Unused Expressions (no-unused-expressions)

            An unused expression which has no effect on the state of the program indicates a logic error.

            For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

            Rule Details

            This rule aims to eliminate unused expressions which have no effect on the state of the program.

            This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

            var i = 0;
            function increment() { i += 1; }
            increment(); // return value is unused, but i changed as a side effect
            
            var nThings = 0;
            function Thing() { nThings += 1; }
            new Thing(); // constructed object is unused, but nThings changed as a side effect

            This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

            Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

            Options

            This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

            • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
            • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
            • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

            These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

            Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

            /*eslint no-unused-expressions: "error"*/
            
            0
            
            if(0) 0
            
            {0}
            
            f(0), {}
            
            a && b()
            
            a, b()
            
            c = a, b;
            
            a() && function namedFunctionInExpressionContext () {f();}
            
            (function anIncompleteIIFE () {});
            
            injectGlobal`body{ color: red; }`

            Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

            "use strict";
            "use asm"
            "use stricter";
            "use babel"
            "any other strings like this in the prologue";

            Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

            /*eslint no-unused-expressions: "error"*/
            
            {} // In this context, this is a block statement, not an object literal
            
            {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
            
            function namedFunctionDeclaration () {}
            
            (function aGenuineIIFE () {}());
            
            f()
            
            a = 0
            
            new C
            
            delete a.b
            
            void a

            allowShortCircuit

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

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
            
            a || b

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

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
            
            a && b()
            a() || (b = c)

            allowTernary

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

            /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
            
            a ? b : 0
            a ? b : c()

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

            /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
            
            a ? b() : c()
            a ? (b = c) : d()

            allowShortCircuit and allowTernary

            Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
            
            a ? b() || (c = d) : e()

            allowTaggedTemplates

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

            /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
            
            `some untagged template string`;

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

            /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
            
            tag`some tagged template string`;

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

            'opts' is already defined.
            Open

                var opts = opts || {},

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Expected an assignment or function call and instead saw an expression.
            Open

                    i++, j++

            Disallow Unused Expressions (no-unused-expressions)

            An unused expression which has no effect on the state of the program indicates a logic error.

            For example, n + 1; is not a syntax error, but it might be a typing mistake where a programmer meant an assignment statement n += 1; instead.

            Rule Details

            This rule aims to eliminate unused expressions which have no effect on the state of the program.

            This rule does not apply to function calls or constructor calls with the new operator, because they could have side effects on the state of the program.

            var i = 0;
            function increment() { i += 1; }
            increment(); // return value is unused, but i changed as a side effect
            
            var nThings = 0;
            function Thing() { nThings += 1; }
            new Thing(); // constructed object is unused, but nThings changed as a side effect

            This rule does not apply to directives (which are in the form of literal string expressions such as "use strict"; at the beginning of a script, module, or function).

            Sequence expressions (those using a comma, such as a = 1, b = 2) are always considered unused unless their return value is assigned or used in a condition evaluation, or a function call is made with the sequence expression value.

            Options

            This rule, in its default state, does not require any arguments. If you would like to enable one or more of the following you may pass an object with the options set as follows:

            • allowShortCircuit set to true will allow you to use short circuit evaluations in your expressions (Default: false).
            • allowTernary set to true will enable you to use ternary operators in your expressions similarly to short circuit evaluations (Default: false).
            • allowTaggedTemplates set to true will enable you to use tagged template literals in your expressions (Default: false).

            These options allow unused expressions only if all of the code paths either directly change the state (for example, assignment statement) or could have side effects (for example, function call).

            Examples of incorrect code for the default { "allowShortCircuit": false, "allowTernary": false } options:

            /*eslint no-unused-expressions: "error"*/
            
            0
            
            if(0) 0
            
            {0}
            
            f(0), {}
            
            a && b()
            
            a, b()
            
            c = a, b;
            
            a() && function namedFunctionInExpressionContext () {f();}
            
            (function anIncompleteIIFE () {});
            
            injectGlobal`body{ color: red; }`

            Note that one or more string expression statements (with or without semi-colons) will only be considered as unused if they are not in the beginning of a script, module, or function (alone and uninterrupted by other statements). Otherwise, they will be treated as part of a "directive prologue", a section potentially usable by JavaScript engines. This includes "strict mode" directives.

            "use strict";
            "use asm"
            "use stricter";
            "use babel"
            "any other strings like this in the prologue";

            Examples of correct code for the default { "allowShortCircuit": false, "allowTernary": false } options:

            /*eslint no-unused-expressions: "error"*/
            
            {} // In this context, this is a block statement, not an object literal
            
            {myLabel: someVar} // In this context, this is a block statement with a label and expression, not an object literal
            
            function namedFunctionDeclaration () {}
            
            (function aGenuineIIFE () {}());
            
            f()
            
            a = 0
            
            new C
            
            delete a.b
            
            void a

            allowShortCircuit

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

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
            
            a || b

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

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true }]*/
            
            a && b()
            a() || (b = c)

            allowTernary

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

            /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
            
            a ? b : 0
            a ? b : c()

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

            /*eslint no-unused-expressions: ["error", { "allowTernary": true }]*/
            
            a ? b() : c()
            a ? (b = c) : d()

            allowShortCircuit and allowTernary

            Examples of correct code for the { "allowShortCircuit": true, "allowTernary": true } options:

            /*eslint no-unused-expressions: ["error", { "allowShortCircuit": true, "allowTernary": true }]*/
            
            a ? b() || (c = d) : e()

            allowTaggedTemplates

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

            /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
            
            `some untagged template string`;

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

            /*eslint no-unused-expressions: ["error", { "allowTaggedTemplates": true }]*/
            
            tag`some tagged template string`;

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

            'emitEvent' is already defined.
            Open

                    emitEvent = emitEvent === undefined ? true : emitEvent

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Return statement should not contain assignment.
            Open

                return this._idfCache[cacheKey] = idf

            Disallow Assignment in return Statement (no-return-assign)

            One of the interesting, and sometimes confusing, aspects of JavaScript is that assignment can happen at almost any point. Because of this, an errant equals sign can end up causing assignment when the true intent was to do a comparison. This is especially true when using a return statement. For example:

            function doSomething() {
                return foo = bar + 2;
            }

            It is difficult to tell the intent of the return statement here. It's possible that the function is meant to return the result of bar + 2, but then why is it assigning to foo? It's also possible that the intent was to use a comparison operator such as == and that this code is an error.

            Because of this ambiguity, it's considered a best practice to not use assignment in return statements.

            Rule Details

            This rule aims to eliminate assignments from return statements. As such, it will warn whenever an assignment is found as part of return.

            Options

            The rule takes one option, a string, which must contain one of the following values:

            • except-parens (default): Disallow assignments unless they are enclosed in parentheses.
            • always: Disallow all assignments.

            except-parens

            This is the default option. It disallows assignments unless they are enclosed in parentheses.

            Examples of incorrect code for the default "except-parens" option:

            /*eslint no-return-assign: "error"*/
            
            function doSomething() {
                return foo = bar + 2;
            }
            
            function doSomething() {
                return foo += 2;
            }

            Examples of correct code for the default "except-parens" option:

            /*eslint no-return-assign: "error"*/
            
            function doSomething() {
                return foo == bar + 2;
            }
            
            function doSomething() {
                return foo === bar + 2;
            }
            
            function doSomething() {
                return (foo = bar + 2);
            }

            always

            This option disallows all assignments in return statements. All assignments are treated as problems.

            Examples of incorrect code for the "always" option:

            /*eslint no-return-assign: ["error", "always"]*/
            
            function doSomething() {
                return foo = bar + 2;
            }
            
            function doSomething() {
                return foo += 2;
            }
            
            function doSomething() {
                return (foo = bar + 2);
            }

            Examples of correct code for the "always" option:

            /*eslint no-return-assign: ["error", "always"]*/
            
            function doSomething() {
                return foo == bar + 2;
            }
            
            function doSomething() {
                return foo === bar + 2;
            }

            When Not To Use It

            If you want to allow the use of assignment operators in a return statement, then you can safely disable this rule. Source: http://eslint.org/docs/rules/

            'fp' is already defined.
            Open

                    var fp = re.exec(w);

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            'root' is already defined.
            Open

                var root = root || this.root,

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Expected '===' and instead saw '=='.
            Open

                  if (firstch == "y") {

            Require === and !== (eqeqeq)

            It is considered good practice to use the type-safe equality operators === and !== instead of their regular counterparts == and !=.

            The reason for this is that == and != do type coercion which follows the rather obscure Abstract Equality Comparison Algorithm. For instance, the following statements are all considered true:

            • [] == false
            • [] == ![]
            • 3 == "03"

            If one of those occurs in an innocent-looking statement such as a == b the actual problem is very difficult to spot.

            Rule Details

            This rule is aimed at eliminating the type-unsafe equality operators.

            Examples of incorrect code for this rule:

            /*eslint eqeqeq: "error"*/
            
            if (x == 42) { }
            
            if ("" == text) { }
            
            if (obj.getStuff() != undefined) { }

            The --fix option on the command line automatically fixes some problems reported by this rule. A problem is only fixed if one of the operands is a typeof expression, or if both operands are literals with the same type.

            Options

            always

            The "always" option (default) enforces the use of === and !== in every situation (except when you opt-in to more specific handling of null [see below]).

            Examples of incorrect code for the "always" option:

            /*eslint eqeqeq: ["error", "always"]*/
            
            a == b
            foo == true
            bananas != 1
            value == undefined
            typeof foo == 'undefined'
            'hello' != 'world'
            0 == 0
            true == true
            foo == null

            Examples of correct code for the "always" option:

            /*eslint eqeqeq: ["error", "always"]*/
            
            a === b
            foo === true
            bananas !== 1
            value === undefined
            typeof foo === 'undefined'
            'hello' !== 'world'
            0 === 0
            true === true
            foo === null

            This rule optionally takes a second argument, which should be an object with the following supported properties:

            • "null": Customize how this rule treats null literals. Possible values:
              • always (default) - Always use === or !==.
              • never - Never use === or !== with null.
              • ignore - Do not apply this rule to null.

            smart

            The "smart" option enforces the use of === and !== except for these cases:

            • Comparing two literal values
            • Evaluating the value of typeof
            • Comparing against null

            Examples of incorrect code for the "smart" option:

            /*eslint eqeqeq: ["error", "smart"]*/
            
            // comparing two variables requires ===
            a == b
            
            // only one side is a literal
            foo == true
            bananas != 1
            
            // comparing to undefined requires ===
            value == undefined

            Examples of correct code for the "smart" option:

            /*eslint eqeqeq: ["error", "smart"]*/
            
            typeof foo == 'undefined'
            'hello' != 'world'
            0 == 0
            true == true
            foo == null

            allow-null

            Deprecated: Instead of using this option use "always" and pass a "null" option property with value "ignore". This will tell eslint to always enforce strict equality except when comparing with the null literal.

            ["error", "always", {"null": "ignore"}]

            When Not To Use It

            If you don't want to enforce a style for using equality operators, then it's safe to disable this rule. Source: http://eslint.org/docs/rules/

            'fp' is already defined.
            Open

                    var fp = re.exec(w);

            disallow variable redeclaration (no-redeclare)

            In JavaScript, it's possible to redeclare the same variable name using var. This can lead to confusion as to where the variable is actually declared and initialized.

            Rule Details

            This rule is aimed at eliminating variables that have multiple declarations in the same scope.

            Examples of incorrect code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            var a = 10;

            Examples of correct code for this rule:

            /*eslint no-redeclare: "error"*/
            
            var a = 3;
            // ...
            a = 10;

            Options

            This rule takes one optional argument, an object with a boolean property "builtinGlobals". It defaults to false. If set to true, this rule also checks redeclaration of built-in globals, such as Object, Array, Number...

            builtinGlobals

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

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            
            var Object = 0;

            Examples of incorrect code for the { "builtinGlobals": true } option and the browser environment:

            /*eslint no-redeclare: ["error", { "builtinGlobals": true }]*/
            /*eslint-env browser*/
            
            var top = 0;

            The browser environment has many built-in global variables (for example, top). Some of built-in global variables cannot be redeclared. Source: http://eslint.org/docs/rules/

            Expected 'undefined' and instead saw 'void'.
            Open

                  if (token !== void 0) out.push(token)

            Disallow use of the void operator. (no-void)

            The void operator takes an operand and returns undefined: void expression will evaluate expression and return undefined. It can be used to ignore any side effects expression may produce:

            The common case of using void operator is to get a "pure" undefined value as prior to ES5 the undefined variable was mutable:

            // will always return undefined
            (function(){
                return void 0;
            })();
            
            // will return 1 in ES3 and undefined in ES5+
            (function(){
                undefined = 1;
                return undefined;
            })();
            
            // will throw TypeError in ES5+
            (function(){
                'use strict';
                undefined = 1;
            })();

            Another common case is to minify code as void 0 is shorter than undefined:

            foo = void 0;
            foo = undefined;

            When used with IIFE (immediately-invoked function expression), void can be used to force the function keyword to be treated as an expression instead of a declaration:

            var foo = 1;
            void function(){ foo = 1; }() // will assign foo a value of 1
            +function(){ foo = 1; }() // same as above
            function(){ foo = 1; }() // will throw SyntaxError

            Some code styles prohibit void operator, marking it as non-obvious and hard to read.

            Rule Details

            This rule aims to eliminate use of void operator.

            Examples of incorrect code for this rule:

            /*eslint no-void: "error"*/
            
            void foo
            
            var foo = void bar();

            When Not To Use It

            If you intentionally use the void operator then you can disable this rule.

            Further Reading

            Related Rules

            Expected 'undefined' and instead saw 'void'.
            Open

                    if (token === void 0) break

            Disallow use of the void operator. (no-void)

            The void operator takes an operand and returns undefined: void expression will evaluate expression and return undefined. It can be used to ignore any side effects expression may produce:

            The common case of using void operator is to get a "pure" undefined value as prior to ES5 the undefined variable was mutable:

            // will always return undefined
            (function(){
                return void 0;
            })();
            
            // will return 1 in ES3 and undefined in ES5+
            (function(){
                undefined = 1;
                return undefined;
            })();
            
            // will throw TypeError in ES5+
            (function(){
                'use strict';
                undefined = 1;
            })();

            Another common case is to minify code as void 0 is shorter than undefined:

            foo = void 0;
            foo = undefined;

            When used with IIFE (immediately-invoked function expression), void can be used to force the function keyword to be treated as an expression instead of a declaration:

            var foo = 1;
            void function(){ foo = 1; }() // will assign foo a value of 1
            +function(){ foo = 1; }() // same as above
            function(){ foo = 1; }() // will throw SyntaxError

            Some code styles prohibit void operator, marking it as non-obvious and hard to read.

            Rule Details

            This rule aims to eliminate use of void operator.

            Examples of incorrect code for this rule:

            /*eslint no-void: "error"*/
            
            void foo
            
            var foo = void bar();

            When Not To Use It

            If you intentionally use the void operator then you can disable this rule.

            Further Reading

            Related Rules

            Move the invocation into the parens that contain the function.
            Open

              lunr.utils.warn = (function (global) {

            Require IIFEs to be Wrapped (wrap-iife)

            You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

            // function expression could be unwrapped
            var x = function () { return { y: 1 };}();
            
            // function declaration must be wrapped
            function () { /* side effects */ }(); // SyntaxError

            Rule Details

            This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

            Options

            This rule has two options, a string option and an object option.

            String option:

            • "outside" enforces always wrapping the call expression. The default is "outside".
            • "inside" enforces always wrapping the function expression.
            • "any" enforces always wrapping, but allows either style.

            Object option:

            • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

            outside

            Examples of incorrect code for the default "outside" option:

            /*eslint wrap-iife: ["error", "outside"]*/
            
            var x = function () { return { y: 1 };}(); // unwrapped
            var x = (function () { return { y: 1 };})(); // wrapped function expression

            Examples of correct code for the default "outside" option:

            /*eslint wrap-iife: ["error", "outside"]*/
            
            var x = (function () { return { y: 1 };}()); // wrapped call expression

            inside

            Examples of incorrect code for the "inside" option:

            /*eslint wrap-iife: ["error", "inside"]*/
            
            var x = function () { return { y: 1 };}(); // unwrapped
            var x = (function () { return { y: 1 };}()); // wrapped call expression

            Examples of correct code for the "inside" option:

            /*eslint wrap-iife: ["error", "inside"]*/
            
            var x = (function () { return { y: 1 };})(); // wrapped function expression

            any

            Examples of incorrect code for the "any" option:

            /*eslint wrap-iife: ["error", "any"]*/
            
            var x = function () { return { y: 1 };}(); // unwrapped

            Examples of correct code for the "any" option:

            /*eslint wrap-iife: ["error", "any"]*/
            
            var x = (function () { return { y: 1 };}()); // wrapped call expression
            var x = (function () { return { y: 1 };})(); // wrapped function expression

            functionPrototypeMethods

            Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

            /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
            
            var x = function(){ foo(); }()
            var x = (function(){ foo(); }())
            var x = function(){ foo(); }.call(bar)
            var x = (function(){ foo(); }.call(bar))

            Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

            /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
            
            var x = (function(){ foo(); })()
            var x = (function(){ foo(); }).call(bar)

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

            Move the invocation into the parens that contain the function.
            Open

              lunr.stemmer = (function(){

            Require IIFEs to be Wrapped (wrap-iife)

            You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

            // function expression could be unwrapped
            var x = function () { return { y: 1 };}();
            
            // function declaration must be wrapped
            function () { /* side effects */ }(); // SyntaxError

            Rule Details

            This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

            Options

            This rule has two options, a string option and an object option.

            String option:

            • "outside" enforces always wrapping the call expression. The default is "outside".
            • "inside" enforces always wrapping the function expression.
            • "any" enforces always wrapping, but allows either style.

            Object option:

            • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

            outside

            Examples of incorrect code for the default "outside" option:

            /*eslint wrap-iife: ["error", "outside"]*/
            
            var x = function () { return { y: 1 };}(); // unwrapped
            var x = (function () { return { y: 1 };})(); // wrapped function expression

            Examples of correct code for the default "outside" option:

            /*eslint wrap-iife: ["error", "outside"]*/
            
            var x = (function () { return { y: 1 };}()); // wrapped call expression

            inside

            Examples of incorrect code for the "inside" option:

            /*eslint wrap-iife: ["error", "inside"]*/
            
            var x = function () { return { y: 1 };}(); // unwrapped
            var x = (function () { return { y: 1 };}()); // wrapped call expression

            Examples of correct code for the "inside" option:

            /*eslint wrap-iife: ["error", "inside"]*/
            
            var x = (function () { return { y: 1 };})(); // wrapped function expression

            any

            Examples of incorrect code for the "any" option:

            /*eslint wrap-iife: ["error", "any"]*/
            
            var x = function () { return { y: 1 };}(); // unwrapped

            Examples of correct code for the "any" option:

            /*eslint wrap-iife: ["error", "any"]*/
            
            var x = (function () { return { y: 1 };}()); // wrapped call expression
            var x = (function () { return { y: 1 };})(); // wrapped function expression

            functionPrototypeMethods

            Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

            /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
            
            var x = function(){ foo(); }()
            var x = (function(){ foo(); }())
            var x = function(){ foo(); }.call(bar)
            var x = (function(){ foo(); }.call(bar))

            Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

            /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
            
            var x = (function(){ foo(); })()
            var x = (function(){ foo(); }).call(bar)

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

            Move the invocation into the parens that contain the function.
            Open

            (function(){

            Require IIFEs to be Wrapped (wrap-iife)

            You can immediately invoke function expressions, but not function declarations. A common technique to create an immediately-invoked function expression (IIFE) is to wrap a function declaration in parentheses. The opening parentheses causes the contained function to be parsed as an expression, rather than a declaration.

            // function expression could be unwrapped
            var x = function () { return { y: 1 };}();
            
            // function declaration must be wrapped
            function () { /* side effects */ }(); // SyntaxError

            Rule Details

            This rule requires all immediately-invoked function expressions to be wrapped in parentheses.

            Options

            This rule has two options, a string option and an object option.

            String option:

            • "outside" enforces always wrapping the call expression. The default is "outside".
            • "inside" enforces always wrapping the function expression.
            • "any" enforces always wrapping, but allows either style.

            Object option:

            • "functionPrototypeMethods": true additionally enforces wrapping function expressions invoked using .call and .apply. The default is false.

            outside

            Examples of incorrect code for the default "outside" option:

            /*eslint wrap-iife: ["error", "outside"]*/
            
            var x = function () { return { y: 1 };}(); // unwrapped
            var x = (function () { return { y: 1 };})(); // wrapped function expression

            Examples of correct code for the default "outside" option:

            /*eslint wrap-iife: ["error", "outside"]*/
            
            var x = (function () { return { y: 1 };}()); // wrapped call expression

            inside

            Examples of incorrect code for the "inside" option:

            /*eslint wrap-iife: ["error", "inside"]*/
            
            var x = function () { return { y: 1 };}(); // unwrapped
            var x = (function () { return { y: 1 };}()); // wrapped call expression

            Examples of correct code for the "inside" option:

            /*eslint wrap-iife: ["error", "inside"]*/
            
            var x = (function () { return { y: 1 };})(); // wrapped function expression

            any

            Examples of incorrect code for the "any" option:

            /*eslint wrap-iife: ["error", "any"]*/
            
            var x = function () { return { y: 1 };}(); // unwrapped

            Examples of correct code for the "any" option:

            /*eslint wrap-iife: ["error", "any"]*/
            
            var x = (function () { return { y: 1 };}()); // wrapped call expression
            var x = (function () { return { y: 1 };})(); // wrapped function expression

            functionPrototypeMethods

            Examples of incorrect code for this rule with the "inside", { "functionPrototypeMethods": true } options:

            /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
            
            var x = function(){ foo(); }()
            var x = (function(){ foo(); }())
            var x = function(){ foo(); }.call(bar)
            var x = (function(){ foo(); }.call(bar))

            Examples of correct code for this rule with the "inside", { "functionPrototypeMethods": true } options:

            /* eslint wrap-iife: [2, "inside", { functionPrototypeMethods: true }] */
            
            var x = (function(){ foo(); })()
            var x = (function(){ foo(); }).call(bar)

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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  if (re.test(w)) {
                    var fp = re.exec(w);
                    stem = fp[1];
                    suffix = fp[2];
                    re = re_mgr0;
            Severity: Major
            Found in docs/v3/source/javascripts/lib/_lunr.js and 1 other location - About 2 hrs to fix
            docs/v3/source/javascripts/lib/_lunr.js on lines 1442..1450

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 91.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  if (re.test(w)) {
                    var fp = re.exec(w);
                    stem = fp[1];
                    suffix = fp[2];
                    re = re_mgr0;
            Severity: Major
            Found in docs/v3/source/javascripts/lib/_lunr.js and 1 other location - About 2 hrs to fix
            docs/v3/source/javascripts/lib/_lunr.js on lines 1454..1462

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 91.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                var start = start || 0,
                    end = end || this.elements.length,
                    sectionLength = end - start,
                    pivot = start + Math.floor(sectionLength / 2),
                    pivotElem = this.elements[pivot]
            Severity: Major
            Found in docs/v3/source/javascripts/lib/_lunr.js and 1 other location - About 1 hr to fix
            docs/v3/source/javascripts/lib/_lunr.js on lines 646..650

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 71.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                var start = start || 0,
                    end = end || this.elements.length,
                    sectionLength = end - start,
                    pivot = start + Math.floor(sectionLength / 2),
                    pivotElem = this.elements[pivot]
            Severity: Major
            Found in docs/v3/source/javascripts/lib/_lunr.js and 1 other location - About 1 hr to fix
            docs/v3/source/javascripts/lib/_lunr.js on lines 681..685

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 71.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              lunr.SortedSet.prototype.forEach = function (fn, ctx) {
                return this.elements.forEach(fn, ctx)
              }
            Severity: Minor
            Found in docs/v3/source/javascripts/lib/_lunr.js and 2 other locations - About 35 mins to fix
            docs/v3/source/javascripts/lib/_lunr.js on lines 614..616
            docs/v3/source/javascripts/lib/_lunr.js on lines 830..832

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 46.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              lunr.Index.prototype.off = function (name, fn) {
                return this.eventEmitter.removeListener(name, fn)
              }
            Severity: Minor
            Found in docs/v3/source/javascripts/lib/_lunr.js and 2 other locations - About 35 mins to fix
            docs/v3/source/javascripts/lib/_lunr.js on lines 614..616
            docs/v3/source/javascripts/lib/_lunr.js on lines 629..631

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 46.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              lunr.SortedSet.prototype.map = function (fn, ctx) {
                return this.elements.map(fn, ctx)
              }
            Severity: Minor
            Found in docs/v3/source/javascripts/lib/_lunr.js and 2 other locations - About 35 mins to fix
            docs/v3/source/javascripts/lib/_lunr.js on lines 629..631
            docs/v3/source/javascripts/lib/_lunr.js on lines 830..832

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 46.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status