Rules

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

if theΒ "extends": "eslint:recommended"Β property in aΒ configuration fileΒ enables the rule

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-binary-expressiondisallow expressions where the operation doesn't affect the value
βœ“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 use of `this` in contexts where the value of `this` is `undefined`
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-has-owndisallow use of `Object.prototype.hasOwnProperty.call()` and prefer use of `Object.hasOwn()`
πŸ”§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:

Deprecated ruleReplaced by
callback-return
global-require
handle-callback-err
id-blacklistid-denylist
indent-legacyindent
lines-around-directivepadding-line-between-statements
newline-after-varpadding-line-between-statements
newline-before-returnpadding-line-between-statements
no-buffer-constructor
no-catch-shadowno-shadow
no-mixed-requires
no-native-reassignno-global-assign
no-negated-in-lhsno-unsafe-negation
no-new-require
no-path-concat
no-process-env
no-process-exit
no-restricted-modules
no-spaced-funcfunc-call-spacing
no-sync
prefer-reflect
require-jsdoc
valid-jsdoc

Removed

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

Removed ruleReplaced by
generator-stargenerator-star-spacing
global-strictstrict
no-arrow-conditionno-confusing-arrowΒ no-constant-condition
no-comma-danglecomma-dangle
no-empty-classno-empty-character-class
no-empty-labelno-labels
no-extra-strictstrict
no-reserved-keysquote-props
no-space-before-semisemi-spacing
no-wrap-funcno-extra-parens
space-after-function-namespace-before-function-paren
space-after-keywordskeyword-spacing
space-before-function-parenthesesspace-before-function-paren
space-before-keywordskeyword-spacing
space-in-bracketsobject-curly-spacingΒ array-bracket-spacing
space-return-throw-casekeyword-spacing
space-unary-word-opsspace-unary-ops
spaced-line-commentspaced-comment