Skip to content

Latest commit

 

History

History
483 lines (481 loc) · 9 KB

allDefault.md

File metadata and controls

483 lines (481 loc) · 9 KB

All Enabled Rules

Rule Description Snippet ESLint Default Link
comma-dangle Disallow or enforce trailing commas
 var foo = {
    bar: "baz",
    qux: "quux",
}; 
Error [Link](http://eslint.org/docs/rules/comma-dangle)
complexity Specify the maximum cyclomatic complexity allowed in a program
// complexity: [1, 2]
function a(x) {
    if (true) {
        return x;
    } else if (false) {
        return x+1;
    } else {
        return 4; // 3rd path
    }
}
Allowed between 0 and 11 levels of complexity [Link](http://eslint.org/docs/rules/complexity)
no-cond-assign Disallow assignment in conditional expressions
// Check the user's job title
if (user.jobTitle = "manager") {
    // user.jobTitle is now incorrect
}
Error except enclosed in extra parentheses [Link](http://eslint.org/docs/rules/no-cond-assign)
no-console Disallow use of console in the node environment
console.log("Made it here.");
console.error("That shouldn't have happened.");
Error [Link](http://eslint.org/docs/rules/no-console)
no-constant-condition Disallow use of constant expressions in conditions
if (false) {
    doSomethingUnfinished();
}
Error [Link](http://eslint.org/docs/rules/no-constant-condition)
no-control-regex Disallow control characters in regular expressions
var pattern1 = /\\x1f/;
var pattern2 = new RegExp("\x1f");
Error [Link](http://eslint.org/docs/rules/no-control-regex)
no-debugger Disallow use of debugger
debugger;
Error [Link](http://eslint.org/docs/rules/no-debugger)
no-delete-var Disallow deletion of variables
var x;
delete x;
Error [Link](http://eslint.org/docs/rules/no-delete-var)
no-dupe-args Disallow duplicate arguments in functions
function (a, b, a) {
    console.log("which a is it?", a);
}
Error [Link](http://eslint.org/docs/rules/no-dupe-args)
no-dupe-keys Disallow duplicate keys when creation object literals
var foo = {
    bar: "baz",
    bar: "qux"
};
Error [Link](http://eslint.org/docs/rules/no-dupe-keys)
no-duplicate-case Disallow a duplicate case label
var a = 1;

switch (a) { case 1: break; case 2: break; case 1: // duplicate literal 1 break; default: break; }

Error [Link](http://eslint.org/docs/rules/no-duplicate-case)
no-empty Disallow empty statements
if (foo) {
}
Error [Link](http://eslint.org/docs/rules/no-empty)
no-empty-character-class Disallow the use of empty character classes in regular expressions
var foo = /^abc[]/;
Error [Link](http://eslint.org/docs/rules/no-empty-character-class)
no-ex-assign Disallow assigning to the exception in a catch block
try {
    // code
} catch (e) {
    e = 10;
}
Error [Link](http://eslint.org/docs/rules/no-ex-assign)
no-extra-boolean-cast Disallow double-negation boolean casts in a boolean context
if (!!foo) {
    // ...
}
Error [Link](http://eslint.org/docs/rules/no-extra-boolean-cast)
no-extra-semi Disallow unnecessary semicolons
var x = 5;;
Error [Link](http://eslint.org/docs/rules/no-extra-semi)
no-fallthrough Disallow fallthrough of `case` statements
// Bad
switch(foo) {
    case 1:
        doSomething();
    case 2:
        doSomethingElse();
}
// Good
switch(foo) {
    case 1:
        doSomething();
        break;
    case 2:
        doSomethingElse();
}
Error [Link](http://eslint.org/docs/rules/no-fallthrough)
no-func-assign Disallow overwriting functions written as function declarations
function foo() {}
foo = bar;
Error [Link](http://eslint.org/docs/rules/no-func-assign)
no-inner-declarations Disallow function or variable declarations in nested blocks
if (test) {
    function doSomethingElse () { }
}

function anotherThing() { var fn; if (test) { // Good fn = function expression() { }; // Bad function declaration() { } } }

Error in functions [Link](http://eslint.org/docs/rules/no-inner-declarations)
no-invalid-regexp Disallow invalid regular expression strings in the RegExp constructor
RegExp('['])
RegExp('.', 'z') // invalid flags
new RegExp('\\')
Error [Link](http://eslint.org/docs/rules/no-invalid-regexp)
no-irregular-whitespace Disallow irregular whitespace outside of strings and comments
function thing(){  return 'test'; }
function thing(){  return 'test'; }
function thing(){  return 'test'; }
function thing(){  return 'test'; }
function thing() {  return 'test'; }
function thing() {  return 'test'; }
Error [Link](http://eslint.org/docs/rules/no-irregular-whitespace)
no-mixed-spaces-and-tabs Disallow mixed spaces and tabs for indentation
function main() {
--->var x = 5,
--->....y = 7;
}
Error [Link](http://eslint.org/docs/rules/no-mixed-spaces-and-tabs)
no-negated-in-lhs Disallow negation of the left operand of an in expression
// Bad
if(!a in b) // do something
// Good
if(('' + !a) in b) // do something
Error [Link](http://eslint.org/docs/rules/no-negated-in-lhs)
no-obj-calls Disallow the use of object properties of the global object (Math and JSON) as functions
var x = Math();
var y = JSON();
Error [Link](http://eslint.org/docs/rules/no-obj-calls)
no-octal Disallow use of octal literals
var num = 071;      // 57
Error [Link](http://eslint.org/docs/rules/no-octal)
no-redeclare Disallow declaring the same variable more than once
var a = 3;
var a = 10; // redeclared
Error [Link](http://eslint.org/docs/rules/no-redeclare)
no-regex-spaces Disallow multiple spaces in a regular expression literal
// Bad
var re = /foo   bar/;
// Good
var re = /foo {3}bar/;
Error [Link](http://eslint.org/docs/rules/no-regex-spaces)
no-sparse-arrays Disallow sparse arrays
var colors = [ "red",, "blue" ];
Error [Link](http://eslint.org/docs/rules/no-sparse-arrays)
no-undef Disallow use of undeclared variables unless mentioned in a `/*global */` block
var a = someFunction();  // 'someFunction' is not defined.
b = 10;                  // 'b' is not defined.
Error [Link](http://eslint.org/docs/rules/no-undef)
no-unreachable Disallow uinreachable statements after a return, throw, continue, or break statement
function fn() {
    x = 1;
    return x;
    x = 3; // this will never execute
}
Error [Link](http://eslint.org/docs/rules/no-unreachable)
no-unused-vars Disallow declaration of variables that are not used in the code
var y = 10;
y = 5;
// By default, unused arguments cause warnings.
(function(foo) {
    return 5;
})();
Error [Link](http://eslint.org/docs/rules/no-unused-vars)
use-isnan Disallow comparisons with the value NaN
if (foo == NaN) {
    // ...
}
if (foo != NaN) {
    // ...
}
Error [Link](http://eslint.org/docs/rules/use-isnan)
valid-typeof Ensure that the results of typeof are compared against a valid string
typeof foo === "strnig"
typeof foo == "undefimed"
typeof bar != "nunber"
typeof bar !== "fucntion"
Error [Link](http://eslint.org/docs/rules/valid-typeof)