Rules

Rules in ESLint are grouped by category to help you understand their purpose.

No rules are enabled by default. The `"extends": "eslint:recommended"` property in a configuration file enables rules that report common problems, which have a check mark below.

The `--fix` option on the command line automatically fixes problems (currently mostly whitespace) reported by rules which have a wrench 🔧 below.

Possible Errors

These rules relate to possible syntax or logic errors in JavaScript code:
for-directionenforce "for" loop update clause moving the counter in the right direction.
no-await-in-loopdisallow `await` inside of loops
no-compare-neg-zerodisallow comparing against -0
no-cond-assigndisallow assignment operators in conditional expressions
no-consoledisallow the use of `console`
no-constant-conditiondisallow constant expressions in conditions
no-control-regexdisallow control characters in regular expressions
🔧no-debuggerdisallow the use of `debugger`
no-dupe-argsdisallow duplicate arguments in `function` definitions
no-dupe-keysdisallow duplicate keys in object literals
no-duplicate-casedisallow duplicate case labels
no-emptydisallow empty block statements
no-empty-character-classdisallow empty character classes in regular expressions
no-ex-assigndisallow reassigning exceptions in `catch` clauses
🔧no-extra-boolean-castdisallow unnecessary boolean casts
🔧no-extra-parensdisallow unnecessary parentheses
🔧no-extra-semidisallow unnecessary semicolons
no-func-assigndisallow reassigning `function` declarations
no-inner-declarationsdisallow variable or `function` declarations in nested blocks
no-invalid-regexpdisallow invalid regular expression strings in `RegExp` constructors
no-irregular-whitespacedisallow irregular whitespace outside of strings and comments
no-obj-callsdisallow calling global object properties as functions
no-prototype-builtinsdisallow calling some `Object.prototype` methods directly on objects
🔧no-regex-spacesdisallow multiple spaces in regular expressions
no-sparse-arraysdisallow sparse arrays
no-template-curly-in-stringdisallow template literal placeholder syntax in regular strings
no-unexpected-multilinedisallow confusing multiline expressions
no-unreachabledisallow unreachable code after `return`, `throw`, `continue`, and `break` statements
no-unsafe-finallydisallow control flow statements in `finally` blocks
🔧no-unsafe-negationdisallow negating the left operand of relational operators
use-isnanrequire calls to `isNaN()` when checking for `NaN`
valid-jsdocenforce valid JSDoc comments
valid-typeofenforce comparing `typeof` expressions against valid strings

Best Practices

These rules relate to better ways of doing things to help you avoid problems:
accessor-pairsenforce getter and setter pairs in objects
array-callback-returnenforce `return` statements in callbacks of array methods
block-scoped-varenforce the use of variables within the scope they are defined
class-methods-use-thisenforce that class methods utilize `this`
complexityenforce a maximum cyclomatic complexity allowed in a program
consistent-returnrequire `return` statements to either always or never specify values
🔧curlyenforce consistent brace style for all control statements
default-caserequire `default` cases in `switch` statements
🔧dot-locationenforce consistent newlines before and after dots
🔧dot-notationenforce dot notation whenever possible
🔧eqeqeqrequire the use of `===` and `!==`
guard-for-inrequire `for-in` loops to include an `if` statement
no-alertdisallow the use of `alert`, `confirm`, and `prompt`
no-callerdisallow the use of `arguments.caller` or `arguments.callee`
no-case-declarationsdisallow lexical declarations in case clauses
no-div-regexdisallow division operators explicitly at the beginning of regular expressions
🔧no-else-returndisallow `else` blocks after `return` statements in `if` statements
no-empty-functiondisallow empty functions
no-empty-patterndisallow empty destructuring patterns
no-eq-nulldisallow `null` comparisons without type-checking operators
no-evaldisallow the use of `eval()`
no-extend-nativedisallow extending native types
🔧no-extra-binddisallow unnecessary calls to `.bind()`
🔧no-extra-labeldisallow unnecessary labels
no-fallthroughdisallow fallthrough of `case` statements
🔧no-floating-decimaldisallow leading or trailing decimal points in numeric literals
no-global-assigndisallow assignments to native objects or read-only global variables
🔧no-implicit-coerciondisallow shorthand type conversions
no-implicit-globalsdisallow variable and `function` declarations in the global scope
no-implied-evaldisallow the use of `eval()`-like methods
no-invalid-thisdisallow `this` keywords outside of classes or class-like objects
no-iteratordisallow the use of the `__iterator__` property
no-labelsdisallow labeled statements
no-lone-blocksdisallow unnecessary nested blocks
no-loop-funcdisallow `function` declarations and expressions inside loop statements
no-magic-numbersdisallow magic numbers
🔧no-multi-spacesdisallow multiple spaces
no-multi-strdisallow multiline strings
no-newdisallow `new` operators outside of assignments or comparisons
no-new-funcdisallow `new` operators with the `Function` object
no-new-wrappersdisallow `new` operators with the `String`, `Number`, and `Boolean` objects
no-octaldisallow octal literals
no-octal-escapedisallow octal escape sequences in string literals
no-param-reassigndisallow reassigning `function` parameters
no-protodisallow the use of the `__proto__` property
no-redeclaredisallow variable redeclaration
no-restricted-propertiesdisallow certain properties on certain objects
no-return-assigndisallow assignment operators in `return` statements
no-return-awaitdisallow unnecessary `return await`
no-script-urldisallow `javascript:` urls
no-self-assigndisallow assignments where both sides are exactly the same
no-self-comparedisallow comparisons where both sides are exactly the same
no-sequencesdisallow comma operators
no-throw-literaldisallow throwing literals as exceptions
no-unmodified-loop-conditiondisallow unmodified loop conditions
no-unused-expressionsdisallow unused expressions
🔧no-unused-labelsdisallow unused labels
no-useless-calldisallow unnecessary calls to `.call()` and `.apply()`
no-useless-concatdisallow unnecessary concatenation of literals or template literals
no-useless-escapedisallow unnecessary escape characters
🔧no-useless-returndisallow redundant return statements
no-voiddisallow `void` operators
no-warning-commentsdisallow specified warning terms in comments
no-withdisallow `with` statements
prefer-promise-reject-errorsrequire using Error objects as Promise rejection reasons
radixenforce the consistent use of the radix argument when using `parseInt()`
require-awaitdisallow async functions which have no `await` expression
vars-on-toprequire `var` declarations be placed at the top of their containing scope
🔧wrap-iiferequire parentheses around immediate `function` invocations
🔧yodarequire or disallow "Yoda" conditions

Strict Mode

These rules relate to strict mode directives:
🔧strictrequire or disallow strict mode directives

Variables

These rules relate to variable declarations:
init-declarationsrequire or disallow initialization in variable declarations
no-catch-shadowdisallow `catch` clause parameters from shadowing variables in the outer scope
no-delete-vardisallow deleting variables
no-label-vardisallow labels that share a name with a variable
no-restricted-globalsdisallow specified global variables
no-shadowdisallow variable declarations from shadowing variables declared in the outer scope
no-shadow-restricted-namesdisallow identifiers from shadowing restricted names
no-undefdisallow the use of undeclared variables unless mentioned in `/*global */` comments
🔧no-undef-initdisallow initializing variables to `undefined`
no-undefineddisallow the use of `undefined` as an identifier
no-unused-varsdisallow unused variables
no-use-before-definedisallow the use of variables before they are defined

Node.js and CommonJS

These rules relate to code running in Node.js, or in browsers with CommonJS:
callback-returnrequire `return` statements after callbacks
global-requirerequire `require()` calls to be placed at top-level module scope
handle-callback-errrequire error handling in callbacks
no-buffer-constructordisallow use of the Buffer() constructor
no-mixed-requiresdisallow `require` calls to be mixed with regular variable declarations
no-new-requiredisallow `new` operators with calls to `require`
no-path-concatdisallow string concatenation with `__dirname` and `__filename`
no-process-envdisallow the use of `process.env`
no-process-exitdisallow the use of `process.exit()`
no-restricted-modulesdisallow specified modules when loaded by `require`
no-syncdisallow synchronous methods

Stylistic Issues

These rules relate to style guidelines, and are therefore quite subjective:
🔧array-bracket-newlineenforce linebreaks after opening and before closing array brackets
🔧array-bracket-spacingenforce consistent spacing inside array brackets
🔧array-element-newlineenforce line breaks after each array element
🔧block-spacingenforce consistent spacing inside single-line blocks
🔧brace-styleenforce consistent brace style for blocks
camelcaseenforce camelcase naming convention
🔧capitalized-commentsenforce or disallow capitalization of the first letter of a comment
🔧comma-danglerequire or disallow trailing commas
🔧comma-spacingenforce consistent spacing before and after commas
🔧comma-styleenforce consistent comma style
🔧computed-property-spacingenforce consistent spacing inside computed property brackets
consistent-thisenforce consistent naming when capturing the current execution context
🔧eol-lastrequire or disallow newline at the end of files
🔧func-call-spacingrequire or disallow spacing between function identifiers and their invocations
func-name-matchingrequire function names to match the name of the variable or property to which they are assigned
func-namesrequire or disallow named `function` expressions
func-styleenforce the consistent use of either `function` declarations or expressions
id-blacklistdisallow specified identifiers
id-lengthenforce minimum and maximum identifier lengths
id-matchrequire identifiers to match a specified regular expression
🔧indentenforce consistent indentation
🔧jsx-quotesenforce the consistent use of either double or single quotes in JSX attributes
🔧key-spacingenforce consistent spacing between keys and values in object literal properties
🔧keyword-spacingenforce consistent spacing before and after keywords
line-comment-positionenforce position of line comments
🔧linebreak-styleenforce consistent linebreak style
🔧lines-around-commentrequire empty lines around comments
max-depthenforce a maximum depth that blocks can be nested
max-lenenforce a maximum line length
max-linesenforce a maximum number of lines per file
max-nested-callbacksenforce a maximum depth that callbacks can be nested
max-paramsenforce a maximum number of parameters in function definitions
max-statementsenforce a maximum number of statements allowed in function blocks
max-statements-per-lineenforce a maximum number of statements allowed per line
multiline-ternaryenforce newlines between operands of ternary expressions
new-caprequire constructor names to begin with a capital letter
🔧new-parensrequire parentheses when invoking a constructor with no arguments
newline-per-chained-callrequire a newline after each call in a method chain
no-array-constructordisallow `Array` constructors
no-bitwisedisallow bitwise operators
no-continuedisallow `continue` statements
no-inline-commentsdisallow inline comments after code
🔧no-lonely-ifdisallow `if` statements as the only statement in `else` blocks
no-mixed-operatorsdisallow mixed binary operators
no-mixed-spaces-and-tabsdisallow mixed spaces and tabs for indentation
no-multi-assigndisallow use of chained assignment expressions
🔧no-multiple-empty-linesdisallow multiple empty lines
no-negated-conditiondisallow negated conditions
no-nested-ternarydisallow nested ternary expressions
no-new-objectdisallow `Object` constructors
no-plusplusdisallow the unary operators `++` and `--`
no-restricted-syntaxdisallow specified syntax
no-tabsdisallow all tabs
no-ternarydisallow ternary operators
🔧no-trailing-spacesdisallow trailing whitespace at the end of lines
no-underscore-dangledisallow dangling underscores in identifiers
🔧no-unneeded-ternarydisallow ternary operators when simpler alternatives exist
🔧no-whitespace-before-propertydisallow whitespace before properties
🔧nonblock-statement-body-positionenforce the location of single-line statements
🔧object-curly-newlineenforce consistent line breaks inside braces
🔧object-curly-spacingenforce consistent spacing inside braces
🔧object-property-newlineenforce placing object properties on separate lines
one-varenforce variables to be declared either together or separately in functions
🔧one-var-declaration-per-linerequire or disallow newlines around variable declarations
🔧operator-assignmentrequire or disallow assignment operator shorthand where possible
🔧operator-linebreakenforce consistent linebreak style for operators
🔧padded-blocksrequire or disallow padding within blocks
🔧padding-line-between-statementsrequire or disallow padding lines between statements
🔧quote-propsrequire quotes around object literal property names
🔧quotesenforce the consistent use of either backticks, double, or single quotes
require-jsdocrequire JSDoc comments
🔧semirequire or disallow semicolons instead of ASI
🔧semi-spacingenforce consistent spacing before and after semicolons
🔧semi-styleenforce location of semicolons
sort-keysrequire object keys to be sorted
sort-varsrequire variables within the same declaration block to be sorted
🔧space-before-blocksenforce consistent spacing before blocks
🔧space-before-function-parenenforce consistent spacing before `function` definition opening parenthesis
🔧space-in-parensenforce consistent spacing inside parentheses
🔧space-infix-opsrequire spacing around infix operators
🔧space-unary-opsenforce consistent spacing before or after unary operators
🔧spaced-commentenforce consistent spacing after the `//` or `/*` in a comment
🔧switch-colon-spacingenforce spacing around colons of switch statements
🔧template-tag-spacingrequire or disallow spacing between template tags and their literals
🔧unicode-bomrequire or disallow Unicode byte order mark (BOM)
🔧wrap-regexrequire parenthesis around regex literals

ECMAScript 6

These rules relate to ES6, also known as ES2015:
🔧arrow-body-stylerequire braces around arrow function bodies
🔧arrow-parensrequire parentheses around arrow function arguments
🔧arrow-spacingenforce consistent spacing before and after the arrow in arrow functions
constructor-superrequire `super()` calls in constructors
🔧generator-star-spacingenforce consistent spacing around `*` operators in generator functions
no-class-assigndisallow reassigning class members
🔧no-confusing-arrowdisallow arrow functions where they could be confused with comparisons
no-const-assigndisallow reassigning `const` variables
no-dupe-class-membersdisallow duplicate class members
no-duplicate-importsdisallow duplicate module imports
no-new-symboldisallow `new` operators with the `Symbol` object
no-restricted-importsdisallow specified modules when loaded by `import`
no-this-before-superdisallow `this`/`super` before calling `super()` in constructors
🔧no-useless-computed-keydisallow unnecessary computed property keys in object literals
no-useless-constructordisallow unnecessary constructors
🔧no-useless-renamedisallow renaming import, export, and destructured assignments to the same name
🔧no-varrequire `let` or `const` instead of `var`
🔧object-shorthandrequire or disallow method and property shorthand syntax for object literals
🔧prefer-arrow-callbackrequire arrow functions as callbacks
🔧prefer-constrequire `const` declarations for variables that are never reassigned after declared
prefer-destructuringrequire destructuring from arrays and/or objects
🔧prefer-numeric-literalsdisallow `parseInt()` in favor of binary, octal, and hexadecimal literals
prefer-rest-paramsrequire rest parameters instead of `arguments`
🔧prefer-spreadrequire spread operators instead of `.apply()`
🔧prefer-templaterequire template literals instead of string concatenation
require-yieldrequire generator functions to contain `yield`
🔧rest-spread-spacingenforce spacing between rest and spread operators and their expressions
🔧sort-importsenforce sorted import declarations within modules
symbol-descriptionrequire symbol descriptions
🔧template-curly-spacingrequire or disallow spacing around embedded expressions of template strings
🔧yield-star-spacingrequire or disallow spacing around the `*` in `yield*` expressions

Deprecated

These rules have been deprecated in accordance with the deprecation policy, and replaced by newer rules:

Removed

These rules from older versions of ESLint (before the deprecation policy existed) have been replaced by newer rules: