Rules in ESLint are divided into several categories to help you better understand their value. Additionally, not all rules are enabled by default. Those that are not enabled by default are marked as being off.
The following rules point out areas where you might have made mistakes.
- no-console - disallow use of
console
- no-comma-dangle - disallow trailing commas in object literals
- no-debugger - disallow use of
debugger
- no-empty - disallow empty statements
- no-obj-calls - disallow the use of object properties of the global object (
Math
andJSON
) as functions - no-unreachable - disallow unreachable statements after a return, throw, continue, or break statement
- use-isnan - disallow comparisons with the value
NaN
- no-dupe-keys - disallow duplicate keys when creating object literals
- no-empty-class - disallow the use of empty character classes in regular expressions
- no-func-assign - disallow overwriting functions written as FunctionDeclarations
- no-control-regex - disallow control characters in regular expressions
These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns.
- no-caller - disallow use of
arguments.caller
orarguments.callee
- curly - require curly brace for all control statements
- eqeqeq - require the use of
===
and!==
- dot-notation - encourages use of dot notation whenever possible
- no-catch-shadow - disallow the catch clause parameter name being the same as a variable in the outer scope
- no-eval - disallow use of
eval()
- no-with - disallow use of the
with
statement - no-undef - disallow use of undeclared variables unless mentioned in a
/*global */
block - [no-undef-init] - disallow use of undefined when initializing variables
- [no-floating-decimal] - disallow the use of leading or trailing decimal points in numeric literals
- [no-octal] - disallow use of octal literals
- [no-octal-escape] - disallow use of octal escape sequences in string literals, such as
var foo = "Copyright \251";
- no-new - disallow use of new operator when not part of the assignment or comparison
- [no-new-func] - disallow use of new operator for
Function
object - [no-native-reassign] - disallow reassignments of native objects
- no-delete-var - disallow deletion of variables
- [no-return-assign] - disallow use of assignment in return statement
- no-label-var - disallow labels that share a name with a variable
- wrap-iife - require immediate function invocation to be wrapped in parentheses
- [no-self-compare] - disallow comparisons where both sides are exactly the same
- no-eq-null - disallow comparisons to null without a type-checking operator
- no-multi-str - disallow use of multiline strings
- no-loop-func - disallow creation of functions within loops
- no-empty-label - disallow use of labels for anything other then loops and switches
- unnecessary-strict - disallow unnecessary use of
"use strict";
when already in strict mode - no-unused-expressions - disallow usage of expressions in statement position
- no-unused-vars - disallow declaration of variables that are not used in the code
- no-script-url - disallow use of javascript: urls.
- no-proto - disallow usage of
__proto__
property - no-iterator - disallow usage of
__iterator__
property - no-else-return - disallow
else
after areturn
in anif
. - no-shadow - disallow declaration of variables already declared in the outer scope
- no-alert - disallow the use of
alert
,confirm
, andprompt
- no-use-before-define - disallow use of variables before they are defined
- no-redeclare - disallow declaring the same variable more then once
- no-global-strict - disallow the
"use strict"
pragma in the global scope - strict - require that all functions are run in strict mode
- no-div-regex - disallow division operators explicitly at beginning of regular expression
These rules are purely matters of style and are quite subjective.
- camelcase - require camel case names
- new-cap - require a capital letter for constructors
- quote-props - require quotes around object literal property names
- [semi] - require use of semicolons instead of relying on ASI
- no-ternary - disallow the use of ternary operators
- consistent-this - enforces consistent naming when capturing the current execution context (off by default).
- one-var - disallow multiple variable declaration statements in a function scope
- no-mixed-requires - disallow mixing regular variable and require declarations
- no-wrap-func - disallow wrapping of none IIFE statements in parents
- complexity - specify the maximum cyclomatic complexity allowed in a program
- new-parens - disallow the omission of parentheses when invoking a contructor with no arguments
- no-spaced-func - disallow space between function identifier and application
- wrap-regex - require regex literals to be wrapped in parentheses
The following rules are included for compatibility with JSHint and JSLint. While the names of the rules may not match up with the JSHint/JSLint counterpart, the functionality is the same.
- no-plusplus - disallow use of unary operators,
++
and--
(off by default) - no-bitwise - disallow use of bitwise operators (off by default)
- guard-for-in - make sure
for-in
loops have anif
statement (off by default) - max-statements - specify the maximum number of statement allowed in a function (off by default)
- max-params - limits the number of parameters that can be used in the function declaration. (off by default)
- max-depth - specify the maximum depth that blocks can be nested (off by default)
- max-len - specify the maximum length of a line in your program (off by default)