codenautas/self-explain

View on GitHub

Showing 254 of 254 total issues

Avoid too many return statements within this function.
Open

            return ".class: "+constructorName(a)+' != '+constructorName(b);
Severity: Major
Found in lib/self-explain.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return selfExplain.assert.differences(a.split(opts.split), b.split(opts.split), opts, prefix+".split(" + opts.split + ")");
    Severity: Major
    Found in lib/self-explain.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return loaderCache[id];
      Severity: Major
      Found in dist/escodegen.browser.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                  return '\\0';
        Severity: Major
        Found in dist/escodegen.browser.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                    return cmp;
          Severity: Major
          Found in dist/escodegen.browser.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return loaderCache[id];
            Severity: Major
            Found in dist/escodegen.browser.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return format(a-b, prefix);
              Severity: Major
              Found in lib/self-explain.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return format(selfExplain.assert.stringify(a)+' != '+selfExplain.assert.stringify(b), prefix);
                Severity: Major
                Found in lib/self-explain.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return code === 40 || esutils.code.isWhiteSpace(code) || code === 42 || esutils.code.isLineTerminator(code);
                  Severity: Major
                  Found in dist/escodegen.browser.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                              return '\\u2029';
                    Severity: Major
                    Found in dist/escodegen.browser.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return expr.value ? 'true' : 'false';
                      Severity: Major
                      Found in dist/escodegen.browser.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return strcmp(mappingA.name, mappingB.name);
                        Severity: Major
                        Found in dist/escodegen.browser.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return loaderCache[id];
                          Severity: Major
                          Found in dist/escodegen.browser.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return result.length ? result.join("\n") : null;
                            Severity: Major
                            Found in lib/self-explain.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      if(Math.abs(a-b)<delta) { return null; }
                              Severity: Major
                              Found in lib/self-explain.js - About 30 mins to fix

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

                                    return {}.hasOwnProperty.call(require.modules, file) ? require.modules[file] : void 0;
                                Severity: Minor
                                Found in dist/escodegen.browser.js by eslint

                                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

                                Unnecessary semicolon.
                                Open

                                      ;
                                Severity: Minor
                                Found in dist/escodegen.browser.js by eslint

                                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

                                Use the global form of 'use strict'.
                                Open

                                    'use strict';
                                Severity: Minor
                                Found in dist/escodegen.browser.js by eslint

                                require or disallow strict mode directives (strict)

                                A strict mode directive is a "use strict" literal at the beginning of a script or function body. It enables strict mode semantics.

                                When a directive occurs in global scope, strict mode applies to the entire script:

                                "use strict";
                                
                                // strict mode
                                
                                function foo() {
                                    // strict mode
                                }

                                When a directive occurs at the beginning of a function body, strict mode applies only to that function, including all contained functions:

                                function foo() {
                                    "use strict";
                                    // strict mode
                                }
                                
                                function foo2() {
                                    // not strict mode
                                };
                                
                                (function() {
                                    "use strict";
                                    function bar() {
                                        // strict mode
                                    }
                                }());

                                In the CommonJS module system, a hidden function wraps each module and limits the scope of a "global" strict mode directive.

                                In ECMAScript modules, which always have strict mode semantics, the directives are unnecessary.

                                Rule Details

                                This rule requires or disallows strict mode directives.

                                This rule disallows strict mode directives, no matter which option is specified, if ESLint configuration specifies either of the following as [parser options](../user-guide/configuring#specifying-parser-options):

                                • "sourceType": "module" that is, files are ECMAScript modules
                                • "impliedStrict": true property in the ecmaFeatures object

                                This rule disallows strict mode directives, no matter which option is specified, in functions with non-simple parameter lists (for example, parameter lists with default parameter values) because that is a syntax error in ECMAScript 2016 and later. See the examples of the function option.

                                Options

                                This rule has a string option:

                                • "safe" (default) corresponds either of the following options:
                                  • "global" if ESLint considers a file to be a CommonJS module
                                  • "function" otherwise
                                • "global" requires one strict mode directive in the global scope (and disallows any other strict mode directives)
                                • "function" requires one strict mode directive in each top-level function declaration or expression (and disallows any other strict mode directives)
                                • "never" disallows strict mode directives

                                safe

                                The "safe" option corresponds to the "global" option if ESLint considers a file to be a Node.js or CommonJS module because the configuration specifies either of the following:

                                • node or commonjs [environments](../user-guide/configuring#specifying-environments)
                                • "globalReturn": true property in the ecmaFeatures object of [parser options](../user-guide/configuring#specifying-parser-options)

                                Otherwise the "safe" option corresponds to the "function" option.

                                global

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

                                /*eslint strict: ["error", "global"]*/
                                
                                function foo() {
                                }
                                /*eslint strict: ["error", "global"]*/
                                
                                function foo() {
                                    "use strict";
                                }
                                /*eslint strict: ["error", "global"]*/
                                
                                "use strict";
                                
                                function foo() {
                                    "use strict";
                                }

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

                                /*eslint strict: ["error", "global"]*/
                                
                                "use strict";
                                
                                function foo() {
                                }

                                function

                                This option ensures that all function bodies are strict mode code, while global code is not. Particularly if a build step concatenates multiple scripts, a strict mode directive in global code of one script could unintentionally enable strict mode in another script that was not intended to be strict code.

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

                                /*eslint strict: ["error", "function"]*/
                                
                                "use strict";
                                
                                function foo() {
                                }
                                /*eslint strict: ["error", "function"]*/
                                
                                function foo() {
                                }
                                
                                (function() {
                                    function bar() {
                                        "use strict";
                                    }
                                }());
                                /*eslint strict: ["error", "function"]*/
                                /*eslint-env es6*/
                                
                                // Illegal "use strict" directive in function with non-simple parameter list.
                                // This is a syntax error since ES2016.
                                function foo(a = 1) {
                                    "use strict";
                                }
                                
                                // We cannot write "use strict" directive in this function.
                                // So we have to wrap this function with a function with "use strict" directive.
                                function foo(a = 1) {
                                }

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

                                /*eslint strict: ["error", "function"]*/
                                
                                function foo() {
                                    "use strict";
                                }
                                
                                (function() {
                                    "use strict";
                                
                                    function bar() {
                                    }
                                
                                    function baz(a = 1) {
                                    }
                                }());
                                
                                var foo = (function() {
                                    "use strict";
                                
                                    return function foo(a = 1) {
                                    };
                                }());

                                never

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

                                /*eslint strict: ["error", "never"]*/
                                
                                "use strict";
                                
                                function foo() {
                                }
                                /*eslint strict: ["error", "never"]*/
                                
                                function foo() {
                                    "use strict";
                                }

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

                                /*eslint strict: ["error", "never"]*/
                                
                                function foo() {
                                }

                                earlier default (removed)

                                (removed) The default option (that is, no string option specified) for this rule was removed in ESLint v1.0. The "function" option is most similar to the removed option.

                                This option ensures that all functions are executed in strict mode. A strict mode directive must be present in global code or in every top-level function declaration or expression. It does not concern itself with unnecessary strict mode directives in nested functions that are already strict, nor with multiple strict mode directives at the same level.

                                Examples of incorrect code for this rule with the earlier default option which has been removed:

                                // "strict": "error"
                                
                                function foo() {
                                }
                                // "strict": "error"
                                
                                (function() {
                                    function bar() {
                                        "use strict";
                                    }
                                }());

                                Examples of correct code for this rule with the earlier default option which has been removed:

                                // "strict": "error"
                                
                                "use strict";
                                
                                function foo() {
                                }
                                // "strict": "error"
                                
                                function foo() {
                                    "use strict";
                                }
                                // "strict": "error"
                                
                                (function() {
                                    "use strict";
                                    function bar() {
                                        "use strict";
                                    }
                                }());

                                When Not To Use It

                                In a codebase that has both strict and non-strict code, either turn this rule off, or selectively disable it where necessary. For example, functions referencing arguments.callee are invalid in strict mode. A full list of strict mode differences is available on MDN. Source: http://eslint.org/docs/rules/

                                Use the global form of 'use strict'.
                                Open

                                (function (global) {
                                Severity: Minor
                                Found in dist/escodegen.browser.js by eslint

                                require or disallow strict mode directives (strict)

                                A strict mode directive is a "use strict" literal at the beginning of a script or function body. It enables strict mode semantics.

                                When a directive occurs in global scope, strict mode applies to the entire script:

                                "use strict";
                                
                                // strict mode
                                
                                function foo() {
                                    // strict mode
                                }

                                When a directive occurs at the beginning of a function body, strict mode applies only to that function, including all contained functions:

                                function foo() {
                                    "use strict";
                                    // strict mode
                                }
                                
                                function foo2() {
                                    // not strict mode
                                };
                                
                                (function() {
                                    "use strict";
                                    function bar() {
                                        // strict mode
                                    }
                                }());

                                In the CommonJS module system, a hidden function wraps each module and limits the scope of a "global" strict mode directive.

                                In ECMAScript modules, which always have strict mode semantics, the directives are unnecessary.

                                Rule Details

                                This rule requires or disallows strict mode directives.

                                This rule disallows strict mode directives, no matter which option is specified, if ESLint configuration specifies either of the following as [parser options](../user-guide/configuring#specifying-parser-options):

                                • "sourceType": "module" that is, files are ECMAScript modules
                                • "impliedStrict": true property in the ecmaFeatures object

                                This rule disallows strict mode directives, no matter which option is specified, in functions with non-simple parameter lists (for example, parameter lists with default parameter values) because that is a syntax error in ECMAScript 2016 and later. See the examples of the function option.

                                Options

                                This rule has a string option:

                                • "safe" (default) corresponds either of the following options:
                                  • "global" if ESLint considers a file to be a CommonJS module
                                  • "function" otherwise
                                • "global" requires one strict mode directive in the global scope (and disallows any other strict mode directives)
                                • "function" requires one strict mode directive in each top-level function declaration or expression (and disallows any other strict mode directives)
                                • "never" disallows strict mode directives

                                safe

                                The "safe" option corresponds to the "global" option if ESLint considers a file to be a Node.js or CommonJS module because the configuration specifies either of the following:

                                • node or commonjs [environments](../user-guide/configuring#specifying-environments)
                                • "globalReturn": true property in the ecmaFeatures object of [parser options](../user-guide/configuring#specifying-parser-options)

                                Otherwise the "safe" option corresponds to the "function" option.

                                global

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

                                /*eslint strict: ["error", "global"]*/
                                
                                function foo() {
                                }
                                /*eslint strict: ["error", "global"]*/
                                
                                function foo() {
                                    "use strict";
                                }
                                /*eslint strict: ["error", "global"]*/
                                
                                "use strict";
                                
                                function foo() {
                                    "use strict";
                                }

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

                                /*eslint strict: ["error", "global"]*/
                                
                                "use strict";
                                
                                function foo() {
                                }

                                function

                                This option ensures that all function bodies are strict mode code, while global code is not. Particularly if a build step concatenates multiple scripts, a strict mode directive in global code of one script could unintentionally enable strict mode in another script that was not intended to be strict code.

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

                                /*eslint strict: ["error", "function"]*/
                                
                                "use strict";
                                
                                function foo() {
                                }
                                /*eslint strict: ["error", "function"]*/
                                
                                function foo() {
                                }
                                
                                (function() {
                                    function bar() {
                                        "use strict";
                                    }
                                }());
                                /*eslint strict: ["error", "function"]*/
                                /*eslint-env es6*/
                                
                                // Illegal "use strict" directive in function with non-simple parameter list.
                                // This is a syntax error since ES2016.
                                function foo(a = 1) {
                                    "use strict";
                                }
                                
                                // We cannot write "use strict" directive in this function.
                                // So we have to wrap this function with a function with "use strict" directive.
                                function foo(a = 1) {
                                }

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

                                /*eslint strict: ["error", "function"]*/
                                
                                function foo() {
                                    "use strict";
                                }
                                
                                (function() {
                                    "use strict";
                                
                                    function bar() {
                                    }
                                
                                    function baz(a = 1) {
                                    }
                                }());
                                
                                var foo = (function() {
                                    "use strict";
                                
                                    return function foo(a = 1) {
                                    };
                                }());

                                never

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

                                /*eslint strict: ["error", "never"]*/
                                
                                "use strict";
                                
                                function foo() {
                                }
                                /*eslint strict: ["error", "never"]*/
                                
                                function foo() {
                                    "use strict";
                                }

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

                                /*eslint strict: ["error", "never"]*/
                                
                                function foo() {
                                }

                                earlier default (removed)

                                (removed) The default option (that is, no string option specified) for this rule was removed in ESLint v1.0. The "function" option is most similar to the removed option.

                                This option ensures that all functions are executed in strict mode. A strict mode directive must be present in global code or in every top-level function declaration or expression. It does not concern itself with unnecessary strict mode directives in nested functions that are already strict, nor with multiple strict mode directives at the same level.

                                Examples of incorrect code for this rule with the earlier default option which has been removed:

                                // "strict": "error"
                                
                                function foo() {
                                }
                                // "strict": "error"
                                
                                (function() {
                                    function bar() {
                                        "use strict";
                                    }
                                }());

                                Examples of correct code for this rule with the earlier default option which has been removed:

                                // "strict": "error"
                                
                                "use strict";
                                
                                function foo() {
                                }
                                // "strict": "error"
                                
                                function foo() {
                                    "use strict";
                                }
                                // "strict": "error"
                                
                                (function() {
                                    "use strict";
                                    function bar() {
                                        "use strict";
                                    }
                                }());

                                When Not To Use It

                                In a codebase that has both strict and non-strict code, either turn this rule off, or selectively disable it where necessary. For example, functions referencing arguments.callee are invalid in strict mode. A full list of strict mode differences is available on MDN. Source: http://eslint.org/docs/rules/

                                Wrap only the function expression in parens.
                                Open

                                    (function () {
                                Severity: Minor
                                Found in dist/escodegen.browser.js by eslint

                                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/

                                Severity
                                Category
                                Status
                                Source
                                Language