Rules

Rules in ESLint are grouped by type to help you understand their purpose. Each rule has emojis denoting:

if some problems reported by the rule are automatically fixable by the --fix command line option

if some problems reported by the rule are manually fixable by editor suggestions

Possible Problems

These rules relate to possible logic errors in code:
array-callback-returnenforce `return` statements in callbacks of array methods
constructor-superrequire `super()` calls in constructors
for-directionenforce "for" loop update clause moving the counter in the right direction.
getter-returnenforce `return` statements in getters
no-async-promise-executordisallow using an async function as a Promise executor
no-await-in-loopdisallow `await` inside of loops
no-class-assigndisallow reassigning class members
no-compare-neg-zerodisallow comparing against -0
no-cond-assigndisallow assignment operators in conditional expressions
no-const-assigndisallow reassigning `const` variables
no-constant-conditiondisallow constant expressions in conditions
no-constructor-returndisallow returning value from constructor
no-control-regexdisallow control characters in regular expressions
no-debuggerdisallow the use of `debugger`
no-dupe-argsdisallow duplicate arguments in `function` definitions
no-dupe-class-membersdisallow duplicate class members
no-dupe-else-ifdisallow duplicate conditions in if-else-if chains
no-dupe-keysdisallow duplicate keys in object literals
no-duplicate-casedisallow duplicate case labels
no-duplicate-importsdisallow duplicate module imports
no-empty-character-classdisallow empty character classes in regular expressions
no-empty-patterndisallow empty destructuring patterns
no-ex-assigndisallow reassigning exceptions in `catch` clauses
no-fallthroughdisallow fallthrough of `case` statements
no-func-assigndisallow reassigning `function` declarations
no-import-assigndisallow assigning to imported bindings
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
no-loss-of-precisiondisallow literal numbers that lose precision
no-misleading-character-classdisallow characters which are made with multiple code points in character class syntax
no-new-symboldisallow `new` operators with the `Symbol` object
no-obj-callsdisallow calling global object properties as functions
no-promise-executor-returndisallow returning values from Promise executor functions
no-prototype-builtinsdisallow calling some `Object.prototype` methods directly on objects
no-self-assigndisallow assignments where both sides are exactly the same
no-self-comparedisallow comparisons where both sides are exactly the same
no-setter-returndisallow returning values from setters
no-sparse-arraysdisallow sparse arrays
no-template-curly-in-stringdisallow template literal placeholder syntax in regular strings
no-this-before-superdisallow `this`/`super` before calling `super()` in constructors
no-undefdisallow the use of undeclared variables unless mentioned in `/*global */` comments
no-unexpected-multilinedisallow confusing multiline expressions
no-unmodified-loop-conditiondisallow unmodified loop conditions
no-unreachabledisallow unreachable code after `return`, `throw`, `continue`, and `break` statements
no-unreachable-loopdisallow loops with a body that allows only one iteration
no-unsafe-finallydisallow control flow statements in `finally` blocks
💡no-unsafe-negationdisallow negating the left operand of relational operators
no-unsafe-optional-chainingdisallow use of optional chaining in contexts where the `undefined` value is not allowed
no-unused-private-class-membersdisallow unused private class members
no-unused-varsdisallow unused variables
no-use-before-definedisallow the use of variables before they are defined
no-useless-backreferencedisallow useless backreferences in regular expressions
require-atomic-updatesdisallow assignments that can lead to race conditions due to usage of `await` or `yield`
use-isnanrequire calls to `isNaN()` when checking for `NaN`
valid-typeofenforce comparing `typeof` expressions against valid strings

Suggestions

These rules suggest alternate ways of doing things:
accessor-pairsenforce getter and setter pairs in objects and classes
🔧arrow-body-stylerequire braces around arrow function bodies
block-scoped-varenforce the use of variables within the scope they are defined
camelcaseenforce camelcase naming convention
🔧capitalized-commentsenforce or disallow capitalization of the first letter of a comment
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
consistent-thisenforce consistent naming when capturing the current execution context
🔧curlyenforce consistent brace style for all control statements
default-caserequire `default` cases in `switch` statements
default-case-lastenforce default clauses in switch statements to be last
default-param-lastenforce default parameters to be last
🔧dot-notationenforce dot notation whenever possible
🔧eqeqeqrequire the use of `===` and `!==`
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
grouped-accessor-pairsrequire grouped accessor pairs in object literals and classes
guard-for-inrequire `for-in` loops to include an `if` statement
id-denylistdisallow specified identifiers
id-lengthenforce minimum and maximum identifier lengths
id-matchrequire identifiers to match a specified regular expression
init-declarationsrequire or disallow initialization in variable declarations
max-classes-per-fileenforce a maximum number of classes per file
max-depthenforce a maximum depth that blocks can be nested
max-linesenforce a maximum number of lines per file
max-lines-per-functionenforce a maximum number of lines of code in a function
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
🔧multiline-comment-styleenforce a particular style for multiline comments
new-caprequire constructor names to begin with a capital letter
no-alertdisallow the use of `alert`, `confirm`, and `prompt`
no-array-constructordisallow `Array` constructors
no-bitwisedisallow bitwise operators
no-callerdisallow the use of `arguments.caller` or `arguments.callee`
no-case-declarationsdisallow lexical declarations in case clauses
🔧no-confusing-arrowdisallow arrow functions where they could be confused with comparisons
no-consoledisallow the use of `console`
no-continuedisallow `continue` statements
no-delete-vardisallow deleting variables
🔧no-div-regexdisallow division operators explicitly at the beginning of regular expressions
🔧no-else-returndisallow `else` blocks after `return` statements in `if` statements
no-emptydisallow empty block statements
no-empty-functiondisallow empty functions
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-boolean-castdisallow unnecessary boolean casts
🔧no-extra-labeldisallow unnecessary labels
🔧no-extra-semidisallow unnecessary semicolons
🔧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 declarations in the global scope
no-implied-evaldisallow the use of `eval()`-like methods
no-inline-commentsdisallow inline comments after code
no-invalid-thisdisallow `this` keywords outside of classes or class-like objects
no-iteratordisallow the use of the `__iterator__` property
no-label-vardisallow labels that share a name with a variable
no-labelsdisallow labeled statements
no-lone-blocksdisallow unnecessary nested blocks
🔧no-lonely-ifdisallow `if` statements as the only statement in `else` blocks
no-loop-funcdisallow function declarations that contain unsafe references inside loop statements
no-magic-numbersdisallow magic numbers
no-mixed-operatorsdisallow mixed binary operators
no-multi-assigndisallow use of chained assignment expressions
no-multi-strdisallow multiline strings
no-negated-conditiondisallow negated conditions
no-nested-ternarydisallow nested ternary expressions
no-newdisallow `new` operators outside of assignments or comparisons
no-new-funcdisallow `new` operators with the `Function` object
no-new-objectdisallow `Object` constructors
no-new-wrappersdisallow `new` operators with the `String`, `Number`, and `Boolean` objects
💡no-nonoctal-decimal-escapedisallow `\8` and `\9` escape sequences in string literals
no-octaldisallow octal literals
no-octal-escapedisallow octal escape sequences in string literals
no-param-reassigndisallow reassigning `function` parameters
no-plusplusdisallow the unary operators `++` and `--`
no-protodisallow the use of the `__proto__` property
no-redeclaredisallow variable redeclaration
🔧no-regex-spacesdisallow multiple spaces in regular expressions
no-restricted-exportsdisallow specified names in exports
no-restricted-globalsdisallow specified global variables
no-restricted-importsdisallow specified modules when loaded by `import`
no-restricted-propertiesdisallow certain properties on certain objects
no-restricted-syntaxdisallow specified syntax
no-return-assigndisallow assignment operators in `return` statements
no-return-awaitdisallow unnecessary `return await`
no-script-urldisallow `javascript:` urls
no-sequencesdisallow comma operators
no-shadowdisallow variable declarations from shadowing variables declared in the outer scope
no-shadow-restricted-namesdisallow identifiers from shadowing restricted names
no-ternarydisallow ternary operators
no-throw-literaldisallow throwing literals as exceptions
🔧no-undef-initdisallow initializing variables to `undefined`
no-undefineddisallow the use of `undefined` as an identifier
no-underscore-dangledisallow dangling underscores in identifiers
🔧no-unneeded-ternarydisallow ternary operators when simpler alternatives exist
no-unused-expressionsdisallow unused expressions
🔧no-unused-labelsdisallow unused labels
no-useless-calldisallow unnecessary calls to `.call()` and `.apply()`
no-useless-catchdisallow unnecessary `catch` clauses
🔧no-useless-computed-keydisallow unnecessary computed property keys in objects and classes
no-useless-concatdisallow unnecessary concatenation of literals or template literals
no-useless-constructordisallow unnecessary constructors
💡no-useless-escapedisallow unnecessary escape characters
🔧no-useless-renamedisallow renaming import, export, and destructured assignments to the same name
🔧no-useless-returndisallow redundant return statements
🔧no-varrequire `let` or `const` instead of `var`
no-voiddisallow `void` operators
no-warning-commentsdisallow specified warning terms in comments
no-withdisallow `with` statements
🔧object-shorthandrequire or disallow method and property shorthand syntax for object literals
🔧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
🔧prefer-arrow-callbackrequire using arrow functions for callbacks
🔧prefer-constrequire `const` declarations for variables that are never reassigned after declared
🔧prefer-destructuringrequire destructuring from arrays and/or objects
🔧prefer-exponentiation-operatordisallow the use of `Math.pow` in favor of the `**` operator
prefer-named-capture-groupenforce using named capture group in regular expression
🔧prefer-numeric-literalsdisallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals
🔧prefer-object-spreaddisallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.
prefer-promise-reject-errorsrequire using Error objects as Promise rejection reasons
prefer-regex-literalsdisallow use of the `RegExp` constructor in favor of regular expression literals
prefer-rest-paramsrequire rest parameters instead of `arguments`
prefer-spreadrequire spread operators instead of `.apply()`
🔧prefer-templaterequire template literals instead of string concatenation
🔧quote-propsrequire quotes around object literal property names
💡radixenforce the consistent use of the radix argument when using `parseInt()`
require-awaitdisallow async functions which have no `await` expression
require-unicode-regexpenforce the use of `u` flag on RegExp
require-yieldrequire generator functions to contain `yield`
🔧sort-importsenforce sorted import declarations within modules
sort-keysrequire object keys to be sorted
🔧sort-varsrequire variables within the same declaration block to be sorted
🔧spaced-commentenforce consistent spacing after the `//` or `/*` in a comment
🔧strictrequire or disallow strict mode directives
symbol-descriptionrequire symbol descriptions
vars-on-toprequire `var` declarations be placed at the top of their containing scope
🔧yodarequire or disallow "Yoda" conditions

Layout & Formatting

These rules care about how the code looks rather than how it executes:
🔧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
🔧arrow-parensrequire parentheses around arrow function arguments
🔧arrow-spacingenforce consistent spacing before and after the arrow in arrow functions
🔧block-spacingdisallow or enforce spaces inside of blocks after opening block and before closing block
🔧brace-styleenforce consistent brace style for blocks
🔧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
🔧dot-locationenforce consistent newlines before and after dots
🔧eol-lastrequire or disallow newline at the end of files
🔧func-call-spacingrequire or disallow spacing between function identifiers and their invocations
🔧function-call-argument-newlineenforce line breaks between arguments of a function call
🔧function-paren-newlineenforce consistent line breaks inside function parentheses
🔧generator-star-spacingenforce consistent spacing around `*` operators in generator functions
🔧implicit-arrow-linebreakenforce the location of arrow function bodies
🔧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
🔧lines-between-class-membersrequire or disallow an empty line between class members
max-lenenforce a maximum line length
max-statements-per-lineenforce a maximum number of statements allowed per line
🔧multiline-ternaryenforce newlines between operands of ternary expressions
🔧new-parensenforce or disallow parentheses when invoking a constructor with no arguments
🔧newline-per-chained-callrequire a newline after each call in a method chain
🔧no-extra-parensdisallow unnecessary parentheses
no-mixed-spaces-and-tabsdisallow mixed spaces and tabs for indentation
🔧no-multi-spacesdisallow multiple spaces
🔧no-multiple-empty-linesdisallow multiple empty lines
no-tabsdisallow all tabs
🔧no-trailing-spacesdisallow trailing whitespace at the end of lines
🔧no-whitespace-before-propertydisallow whitespace before properties
🔧nonblock-statement-body-positionenforce the location of single-line statements
🔧object-curly-newlineenforce consistent line breaks after opening and before closing braces
🔧object-curly-spacingenforce consistent spacing inside braces
🔧object-property-newlineenforce placing object properties on separate lines
🔧operator-linebreakenforce consistent linebreak style for operators
🔧padded-blocksrequire or disallow padding within blocks
🔧padding-line-between-statementsrequire or disallow padding lines between statements
🔧quotesenforce the consistent use of either backticks, double, or single quotes
🔧rest-spread-spacingenforce spacing between rest and spread operators and their expressions
🔧semirequire or disallow semicolons instead of ASI
🔧semi-spacingenforce consistent spacing before and after semicolons
🔧semi-styleenforce location of semicolons
🔧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
🔧switch-colon-spacingenforce spacing around colons of switch statements
🔧template-curly-spacingrequire or disallow spacing around embedded expressions of template strings
🔧template-tag-spacingrequire or disallow spacing between template tags and their literals
🔧unicode-bomrequire or disallow Unicode byte order mark (BOM)
🔧wrap-iiferequire parentheses around immediate `function` invocations
🔧wrap-regexrequire parenthesis around regex literals
🔧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: