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) |
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-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; |
Error | [Link](http://eslint.org/docs/rules/no-duplicate-case) |
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-empty | Disallow empty statements |
if (foo) { } |
Error | [Link](http://eslint.org/docs/rules/no-empty) |
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-parens | Disallow unecessary parentheses |
a = (b * c) (a * b) + c typeof (a) |
Off | [Link](http://eslint.org/docs/rules/no-extra-parens) |
no-extra-semi | Disallow unnecessary semicolons |
var x = 5;; |
Error | [Link](http://eslint.org/docs/rules/no-extra-semi) |
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 () { } } |
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-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-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-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) |
use-isnan | Disallow comparisons with the value NaN |
if (foo == NaN) { // ... } if (foo != NaN) { // ... } |
Error | [Link](http://eslint.org/docs/rules/use-isnan) |
valid-jsdoc | Ensure JSDoc comments are valid |
// Good /** * Adds two numbers together. * @param {int} num1 The first number. * @param {int} num2 The second number. * @returns {int} The sum of the two numbers. */ function sum(num1, num2) { return num1 + num2; } |
Off | [Link](http://eslint.org/docs/rules/valid-jsdoc) |
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) |
no-unexpected-multiline | Avoid code that looks like two expressions but is actually one |
var foo = bar (1 || 2).baz(); |
Off | [Link](http://eslint.org/docs/rules/no-unexpected-multiline) |