Versions

Rules Reference

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

Recommended

Using the recommended config from @eslint/js in a configuration file enables this rule

🔧 Fixable

Some problems reported by this rule are automatically fixable by the --fix command line option

💡 hasSuggestions

Some problems reported by this rule are manually fixable by editor suggestions

❄️ Frozen

This rule is currently frozen and is not accepting changes.

Possible Problems

These rules relate to possible logic errors in code:

Enforce return statements in callbacks of array methods

Categories:

💡 Suggestions

Require super() calls in constructors

Categories:

Extends

Enforce for loop update clause moving the counter in the right direction

Categories:

Extends

Enforce return statements in getters

Categories:

Extends

Disallow using an async function as a Promise executor

Categories:

Extends

Disallow await inside of loops

Categories:

Disallow reassigning class members

Categories:

Extends

Disallow comparing against -0

Categories:

Extends

Disallow assignment operators in conditional expressions

Categories:

Extends

Disallow reassigning const variables

Categories:

Extends

Disallow expressions where the operation doesn’t affect the value

Categories:

Extends

Disallow constant expressions in conditions

Categories:

Extends

Disallow returning value from constructor

Categories:

Disallow control characters in regular expressions

Categories:

Extends

Disallow the use of debugger

Categories:

Extends

Disallow duplicate arguments in function definitions

Categories:

Extends

Disallow duplicate class members

Categories:

Extends

Disallow duplicate conditions in if-else-if chains

Categories:

Extends

Disallow duplicate keys in object literals

Categories:

Extends

Disallow duplicate case labels

Categories:

Extends

Disallow duplicate module imports

Categories:

Disallow empty character classes in regular expressions

Categories:

Extends

Disallow empty destructuring patterns

Categories:

Extends

Disallow reassigning exceptions in catch clauses

Categories:

Extends

Disallow fallthrough of case statements

Categories:

Extends

Disallow reassigning function declarations

Categories:

Extends

Disallow assigning to imported bindings

Categories:

Extends

Disallow variable or function declarations in nested blocks

Categories:

Disallow invalid regular expression strings in RegExp constructors

Categories:

Extends

Disallow literal numbers that lose precision

Categories:

Extends

Disallow characters which are made with multiple code points in character class syntax

Categories:

Extends

💡 Suggestions

Disallow new operators with global non-constructor functions

Categories:

Extends

Disallow calling global object properties as functions

Categories:

Extends

Disallow returning values from Promise executor functions

Categories:

💡 Suggestions

Disallow calling some Object.prototype methods directly on objects

Categories:

Extends

💡 Suggestions

Disallow assignments where both sides are exactly the same

Categories:

Extends

Disallow comparisons where both sides are exactly the same

Categories:

Disallow returning values from setters

Categories:

Extends

Disallow sparse arrays

Categories:

Extends

Disallow template literal placeholder syntax in regular strings

Categories:

Disallow this/super before calling super() in constructors

Categories:

Extends

Disallow the use of undeclared variables unless mentioned in /*global */ comments

Categories:

Extends

Disallow confusing multiline expressions

Categories:

Extends

Disallow unreachable code after return, throw, continue, and break statements

Categories:

Extends

Disallow loops with a body that allows only one iteration

Categories:

Disallow control flow statements in finally blocks

Categories:

Extends

Disallow negating the left operand of relational operators

Categories:

Extends

💡 Suggestions

Disallow use of optional chaining in contexts where the undefined value is not allowed

Categories:

Extends

Disallow unused variables

Categories:

Extends

💡 Suggestions

Disallow the use of variables before they are defined

Categories:

Disallow variable assignments when the value is not used

Categories:

Disallow useless backreferences in regular expressions

Categories:

Extends

Disallow assignments that can lead to race conditions due to usage of await or yield

Categories:

Require calls to isNaN() when checking for NaN

Categories:

Extends

💡 Suggestions

Enforce comparing typeof expressions against valid strings

Categories:

Extends

💡 Suggestions

Suggestions

These rules suggest alternate ways of doing things:

Enforce getter and setter pairs in objects and classes

Categories:
arrow-body-style

❄️ Frozen

Require braces around arrow function bodies

Categories:

🔧 Fix

Enforce the use of variables within the scope they are defined

Categories:
camelcase

❄️ Frozen

Enforce camelcase naming convention

Categories:
capitalized-comments

❄️ Frozen

Enforce or disallow capitalization of the first letter of a comment

Categories:

🔧 Fix

Enforce that class methods utilize this

Categories:

Enforce a maximum cyclomatic complexity allowed in a program

Categories:

Require return statements to either always or never specify values

Categories:
consistent-this

❄️ Frozen

Enforce consistent naming when capturing the current execution context

Categories:
curly

❄️ Frozen

Enforce consistent brace style for all control statements

Categories:

🔧 Fix

Require default cases in switch statements

Categories:

Enforce default clauses in switch statements to be last

Categories:
default-param-last

❄️ Frozen

Enforce default parameters to be last

Categories:
dot-notation

❄️ Frozen

Enforce dot notation whenever possible

Categories:

🔧 Fix

Require the use of === and !==

Categories:

🔧 Fix

func-name-matching

❄️ Frozen

Require function names to match the name of the variable or property to which they are assigned

Categories:

Require or disallow named function expressions

Categories:
func-style

❄️ Frozen

Enforce the consistent use of either function declarations or expressions assigned to variables

Categories:

Require grouped accessor pairs in object literals and classes

Categories:

Require for-in loops to include an if statement

Categories:
id-denylist

❄️ Frozen

Disallow specified identifiers

Categories:
id-length

❄️ Frozen

Enforce minimum and maximum identifier lengths

Categories:
id-match

❄️ Frozen

Require identifiers to match a specified regular expression

Categories:
init-declarations

❄️ Frozen

Require or disallow initialization in variable declarations

Categories:

Require or disallow logical assignment operator shorthand

Categories:

🔧 Fix

💡 Suggestions

Enforce a maximum number of classes per file

Categories:

Enforce a maximum depth that blocks can be nested

Categories:

Enforce a maximum number of lines per file

Categories:

Enforce a maximum number of lines of code in a function

Categories:

Enforce a maximum depth that callbacks can be nested

Categories:

Enforce a maximum number of parameters in function definitions

Categories:

Enforce a maximum number of statements allowed in function blocks

Categories:

Require constructor names to begin with a capital letter

Categories:

Disallow the use of alert, confirm, and prompt

Categories:

Disallow Array constructors

Categories:

💡 Suggestions

Disallow bitwise operators

Categories:

Disallow the use of arguments.caller or arguments.callee

Categories:

Disallow lexical declarations in case clauses

Categories:

Extends

💡 Suggestions

Disallow the use of console

Categories:

💡 Suggestions

no-continue

❄️ Frozen

Disallow continue statements

Categories:

Disallow deleting variables

Categories:

Extends

no-div-regex

❄️ Frozen

Disallow equal signs explicitly at the beginning of regular expressions

Categories:

🔧 Fix

no-else-return

❄️ Frozen

Disallow else blocks after return statements in if statements

Categories:

🔧 Fix

Disallow empty block statements

Categories:

Extends

💡 Suggestions

Disallow empty functions

Categories:

Disallow null comparisons without type-checking operators

Categories:

Disallow the use of eval()

Categories:

Disallow extending native types

Categories:

Disallow unnecessary calls to .bind()

Categories:

🔧 Fix

no-extra-boolean-cast

❄️ Frozen

Disallow unnecessary boolean casts

Categories:

Extends

🔧 Fix

no-extra-label

❄️ Frozen

Disallow unnecessary labels

Categories:

🔧 Fix

Disallow assignments to native objects or read-only global variables

Categories:

Extends

no-implicit-coercion

❄️ Frozen

Disallow shorthand type conversions

Categories:

🔧 Fix

💡 Suggestions

Disallow declarations in the global scope

Categories:

Disallow the use of eval()-like methods

Categories:
no-inline-comments

❄️ Frozen

Disallow inline comments after code

Categories:

Disallow use of this in contexts where the value of this is undefined

Categories:

Disallow the use of the __iterator__ property

Categories:
no-label-var

❄️ Frozen

Disallow labels that share a name with a variable

Categories:
no-labels

❄️ Frozen

Disallow labeled statements

Categories:

Disallow unnecessary nested blocks

Categories:
no-lonely-if

❄️ Frozen

Disallow if statements as the only statement in else blocks

Categories:

🔧 Fix

Disallow function declarations that contain unsafe references inside loop statements

Categories:
no-magic-numbers

❄️ Frozen

Disallow magic numbers

Categories:

Disallow use of chained assignment expressions

Categories:
no-multi-str

❄️ Frozen

Disallow multiline strings

Categories:
no-negated-condition

❄️ Frozen

Disallow negated conditions

Categories:
no-nested-ternary

❄️ Frozen

Disallow nested ternary expressions

Categories:

Disallow new operators outside of assignments or comparisons

Categories:

Disallow new operators with the Function object

Categories:

Disallow new operators with the String, Number, and Boolean objects

Categories:

Disallow \8 and \9 escape sequences in string literals

Categories:

Extends

💡 Suggestions

Disallow calls to the Object constructor without an argument

Categories:

💡 Suggestions

Disallow octal literals

Categories:

Extends

Disallow octal escape sequences in string literals

Categories:

Disallow reassigning function parameters

Categories:
no-plusplus

❄️ Frozen

Disallow the unary operators ++ and --

Categories:

Disallow the use of the __proto__ property

Categories:

Disallow variable redeclaration

Categories:

Extends

Disallow multiple spaces in regular expressions

Categories:

Extends

🔧 Fix

Disallow specified names in exports

Categories:

Disallow specified global variables

Categories:

Disallow specified modules when loaded by import

Categories:

Disallow certain properties on certain objects

Categories:

Disallow assignment operators in return statements

Categories:

Disallow javascript: URLs

Categories:

Disallow comma operators

Categories:

Disallow variable declarations from shadowing variables declared in the outer scope

Categories:

Disallow identifiers from shadowing restricted names

Categories:

Extends

no-ternary

❄️ Frozen

Disallow ternary operators

Categories:

Disallow throwing literals as exceptions

Categories:
no-undef-init

❄️ Frozen

Disallow initializing variables to undefined

Categories:

🔧 Fix

no-undefined

❄️ Frozen

Disallow the use of undefined as an identifier

Categories:
no-underscore-dangle

❄️ Frozen

Disallow dangling underscores in identifiers

Categories:
no-unneeded-ternary

❄️ Frozen

Disallow ternary operators when simpler alternatives exist

Categories:

🔧 Fix

Disallow unused labels

Categories:

Extends

🔧 Fix

Disallow unnecessary calls to .call() and .apply()

Categories:

Disallow unnecessary catch clauses

Categories:

Extends

Disallow unnecessary computed property keys in objects and classes

Categories:

🔧 Fix

no-useless-concat

❄️ Frozen

Disallow unnecessary concatenation of literals or template literals

Categories:

Disallow unnecessary escape characters

Categories:

Extends

💡 Suggestions

Disallow renaming import, export, and destructured assignments to the same name

Categories:

🔧 Fix

Disallow redundant return statements

Categories:

🔧 Fix

Require let or const instead of var

Categories:

🔧 Fix

no-void

❄️ Frozen

Disallow void operators

Categories:
no-warning-comments

❄️ Frozen

Disallow specified warning terms in comments

Categories:

Disallow with statements

Categories:

Extends

object-shorthand

❄️ Frozen

Require or disallow method and property shorthand syntax for object literals

Categories:

🔧 Fix

one-var

❄️ Frozen

Enforce variables to be declared either together or separately in functions

Categories:

🔧 Fix

operator-assignment

❄️ Frozen

Require or disallow assignment operator shorthand where possible

Categories:

🔧 Fix

prefer-arrow-callback

❄️ Frozen

Require using arrow functions for callbacks

Categories:

🔧 Fix

Require const declarations for variables that are never reassigned after declared

Categories:

🔧 Fix

prefer-destructuring

❄️ Frozen

Require destructuring from arrays and/or objects

Categories:

🔧 Fix

Disallow the use of Math.pow in favor of the ** operator

Categories:

🔧 Fix

Enforce using named capture group in regular expression

Categories:

💡 Suggestions

Disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals

Categories:

🔧 Fix

Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn()

Categories:

🔧 Fix

prefer-object-spread

❄️ Frozen

Disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead

Categories:

🔧 Fix

Disallow use of the RegExp constructor in favor of regular expression literals

Categories:

💡 Suggestions

Require rest parameters instead of arguments

Categories:
prefer-spread

❄️ Frozen

Require spread operators instead of .apply()

Categories:
prefer-template

❄️ Frozen

Require template literals instead of string concatenation

Categories:

🔧 Fix

Enforce the consistent use of the radix argument when using parseInt()

Categories:

💡 Suggestions

Disallow async functions which have no await expression

Categories:

💡 Suggestions

Enforce the use of u or v flag on regular expressions

Categories:

💡 Suggestions

Require generator functions to contain yield

Categories:

Extends

sort-imports

❄️ Frozen

Enforce sorted import declarations within modules

Categories:

🔧 Fix

sort-keys

❄️ Frozen

Require object keys to be sorted

Categories:
sort-vars

❄️ Frozen

Require variables within the same declaration block to be sorted

Categories:

🔧 Fix

Require or disallow strict mode directives

Categories:

🔧 Fix

Require symbol descriptions

Categories:
vars-on-top

❄️ Frozen

Require var declarations be placed at the top of their containing scope

Categories:
yoda

❄️ Frozen

Require or disallow “Yoda” conditions

Categories:

🔧 Fix

Layout & Formatting

These rules care about how the code looks rather than how it executes:

Require or disallow Unicode byte order mark (BOM)

Categories:

🔧 Fix

Deprecated

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

array-bracket-newline deprecated

Categories:

🔧 Fix

array-bracket-spacing deprecated

Categories:

🔧 Fix

array-element-newline deprecated

Categories:

🔧 Fix

arrow-parens deprecated

Categories:

🔧 Fix

arrow-spacing deprecated

Categories:

🔧 Fix

block-spacing deprecated

Categories:

🔧 Fix

brace-style deprecated

Categories:

🔧 Fix

callback-return deprecated

Categories:

comma-dangle deprecated

Categories:

🔧 Fix

comma-spacing deprecated

Categories:

🔧 Fix

comma-style deprecated

Categories:

🔧 Fix

computed-property-spacing deprecated

Categories:

🔧 Fix

dot-location deprecated

Categories:

🔧 Fix

eol-last deprecated

Categories:

🔧 Fix

func-call-spacing deprecated

Categories:

🔧 Fix

function-call-argument-newline deprecated

Categories:

🔧 Fix

function-paren-newline deprecated

Categories:

🔧 Fix

generator-star-spacing deprecated

Categories:

🔧 Fix

global-require deprecated

Categories:

handle-callback-err deprecated

Categories:

id-blacklist deprecated

Replaced by id-denylist

Categories:

implicit-arrow-linebreak deprecated

Categories:

🔧 Fix

indent deprecated

Categories:

🔧 Fix

indent-legacy deprecated

Replaced by indent

Categories:

🔧 Fix

jsx-quotes deprecated

Categories:

🔧 Fix

key-spacing deprecated

Categories:

🔧 Fix

keyword-spacing deprecated

Categories:

🔧 Fix

line-comment-position deprecated

Categories:

linebreak-style deprecated

Categories:

🔧 Fix

lines-around-comment deprecated

Categories:

🔧 Fix

lines-between-class-members deprecated

Categories:

🔧 Fix

max-len deprecated

Categories:

max-statements-per-line deprecated

Categories:

multiline-comment-style deprecated

Categories:

🔧 Fix

multiline-ternary deprecated

Categories:

🔧 Fix

new-parens deprecated

Categories:

🔧 Fix

newline-per-chained-call deprecated

Categories:

🔧 Fix

no-buffer-constructor deprecated

Categories:

no-catch-shadow deprecated

Replaced by no-shadow

Categories:

no-confusing-arrow deprecated

Categories:

🔧 Fix

no-extra-parens deprecated

Categories:

🔧 Fix

no-extra-semi deprecated

Categories:

🔧 Fix

no-floating-decimal deprecated

Categories:

🔧 Fix

no-mixed-operators deprecated

Categories:

no-mixed-requires deprecated

Categories:

no-mixed-spaces-and-tabs deprecated

Categories:

no-multi-spaces deprecated

Categories:

🔧 Fix

no-multiple-empty-lines deprecated

Categories:

🔧 Fix

no-native-reassign deprecated

Replaced by no-global-assign

Categories:

no-negated-in-lhs deprecated

Replaced by no-unsafe-negation

Categories:

no-new-require deprecated

Categories:

no-path-concat deprecated

Categories:

no-process-env deprecated

Categories:

no-process-exit deprecated

Categories:

no-restricted-modules deprecated

Categories:

no-return-await deprecated

Categories:

💡 Suggestions

no-spaced-func deprecated

Replaced by func-call-spacing

Categories:

🔧 Fix

no-sync deprecated

Categories:

no-tabs deprecated

Categories:

no-trailing-spaces deprecated

Categories:

🔧 Fix

no-whitespace-before-property deprecated

Categories:

🔧 Fix

nonblock-statement-body-position deprecated

Categories:

🔧 Fix

object-curly-newline deprecated

Categories:

🔧 Fix

object-curly-spacing deprecated

Categories:

🔧 Fix

object-property-newline deprecated

Categories:

🔧 Fix

one-var-declaration-per-line deprecated

Categories:

🔧 Fix

operator-linebreak deprecated

Categories:

🔧 Fix

padded-blocks deprecated

Categories:

🔧 Fix

padding-line-between-statements deprecated

Categories:

🔧 Fix

prefer-reflect deprecated

Categories:

quote-props deprecated

Categories:

🔧 Fix

quotes deprecated

Categories:

🔧 Fix

rest-spread-spacing deprecated

Categories:

🔧 Fix

semi deprecated

Categories:

🔧 Fix

semi-spacing deprecated

Categories:

🔧 Fix

semi-style deprecated

Categories:

🔧 Fix

space-before-blocks deprecated

Categories:

🔧 Fix

space-before-function-paren deprecated

Categories:

🔧 Fix

space-in-parens deprecated

Categories:

🔧 Fix

space-infix-ops deprecated

Categories:

🔧 Fix

space-unary-ops deprecated

Categories:

🔧 Fix

spaced-comment deprecated

Categories:

🔧 Fix

switch-colon-spacing deprecated

Categories:

🔧 Fix

template-curly-spacing deprecated

Categories:

🔧 Fix

template-tag-spacing deprecated

Categories:

🔧 Fix

wrap-iife deprecated

Categories:

🔧 Fix

wrap-regex deprecated

Categories:

🔧 Fix

yield-star-spacing deprecated

Categories:

🔧 Fix

Removed

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

global-strict removed

Replaced by strict

no-empty-label removed

Replaced by no-labels

no-extra-strict removed

Replaced by strict

valid-jsdoc removed

Replaced by

require-jsdoc removed

Replaced by

Change Language