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

Possible Problems

These rules relate to possible logic errors in code:

array-callback-return

Enforce return statements in callbacks of array methods

Categories:

💡 Suggestions

constructor-super

Require super() calls in constructors

Categories:

Extends

for-direction

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

Categories:

Extends

getter-return

Enforce return statements in getters

Categories:

Extends

no-async-promise-executor

Disallow using an async function as a Promise executor

Categories:

Extends

no-await-in-loop

Disallow await inside of loops

Categories:
no-class-assign

Disallow reassigning class members

Categories:

Extends

no-compare-neg-zero

Disallow comparing against -0

Categories:

Extends

no-cond-assign

Disallow assignment operators in conditional expressions

Categories:

Extends

no-const-assign

Disallow reassigning const variables

Categories:

Extends

no-constant-binary-expression

Disallow expressions where the operation doesn’t affect the value

Categories:

Extends

no-constant-condition

Disallow constant expressions in conditions

Categories:

Extends

no-constructor-return

Disallow returning value from constructor

Categories:
no-control-regex

Disallow control characters in regular expressions

Categories:

Extends

no-debugger

Disallow the use of debugger

Categories:

Extends

no-dupe-args

Disallow duplicate arguments in function definitions

Categories:

Extends

no-dupe-class-members

Disallow duplicate class members

Categories:

Extends

no-dupe-else-if

Disallow duplicate conditions in if-else-if chains

Categories:

Extends

no-dupe-keys

Disallow duplicate keys in object literals

Categories:

Extends

no-duplicate-case

Disallow duplicate case labels

Categories:

Extends

no-duplicate-imports

Disallow duplicate module imports

Categories:
no-empty-character-class

Disallow empty character classes in regular expressions

Categories:

Extends

no-empty-pattern

Disallow empty destructuring patterns

Categories:

Extends

no-ex-assign

Disallow reassigning exceptions in catch clauses

Categories:

Extends

no-fallthrough

Disallow fallthrough of case statements

Categories:

Extends

no-func-assign

Disallow reassigning function declarations

Categories:

Extends

no-import-assign

Disallow assigning to imported bindings

Categories:

Extends

no-inner-declarations

Disallow variable or function declarations in nested blocks

Categories:
no-invalid-regexp

Disallow invalid regular expression strings in RegExp constructors

Categories:

Extends

no-loss-of-precision

Disallow literal numbers that lose precision

Categories:

Extends

no-misleading-character-class

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

Categories:

Extends

💡 Suggestions

no-new-native-nonconstructor

Disallow new operators with global non-constructor functions

Categories:

Extends

no-obj-calls

Disallow calling global object properties as functions

Categories:

Extends

no-promise-executor-return

Disallow returning values from Promise executor functions

Categories:

💡 Suggestions

no-prototype-builtins

Disallow calling some Object.prototype methods directly on objects

Categories:

Extends

💡 Suggestions

no-self-assign

Disallow assignments where both sides are exactly the same

Categories:

Extends

no-self-compare

Disallow comparisons where both sides are exactly the same

Categories:
no-setter-return

Disallow returning values from setters

Categories:

Extends

no-sparse-arrays

Disallow sparse arrays

Categories:

Extends

no-template-curly-in-string

Disallow template literal placeholder syntax in regular strings

Categories:
no-this-before-super

Disallow this/super before calling super() in constructors

Categories:

Extends

no-undef

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

Categories:

Extends

no-unexpected-multiline

Disallow confusing multiline expressions

Categories:

Extends

no-unreachable

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

Categories:

Extends

no-unreachable-loop

Disallow loops with a body that allows only one iteration

Categories:
no-unsafe-finally

Disallow control flow statements in finally blocks

Categories:

Extends

no-unsafe-negation

Disallow negating the left operand of relational operators

Categories:

Extends

💡 Suggestions

no-unsafe-optional-chaining

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

Categories:

Extends

no-unused-vars

Disallow unused variables

Categories:

Extends

no-use-before-define

Disallow the use of variables before they are defined

Categories:
no-useless-assignment

Disallow variable assignments when the value is not used

Categories:
no-useless-backreference

Disallow useless backreferences in regular expressions

Categories:

Extends

require-atomic-updates

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

Categories:
use-isnan

Require calls to isNaN() when checking for NaN

Categories:

Extends

💡 Suggestions

valid-typeof

Enforce comparing typeof expressions against valid strings

Categories:

Extends

💡 Suggestions

Suggestions

These rules suggest alternate ways of doing things:

accessor-pairs

Enforce getter and setter pairs in objects and classes

Categories:
arrow-body-style

Require braces around arrow function bodies

Categories:

🔧 Fix

block-scoped-var

Enforce the use of variables within the scope they are defined

Categories:
camelcase

Enforce camelcase naming convention

Categories:
capitalized-comments

Enforce or disallow capitalization of the first letter of a comment

Categories:

🔧 Fix

class-methods-use-this

Enforce that class methods utilize this

Categories:
complexity

Enforce a maximum cyclomatic complexity allowed in a program

Categories:
consistent-return

Require return statements to either always or never specify values

Categories:
consistent-this

Enforce consistent naming when capturing the current execution context

Categories:
curly

Enforce consistent brace style for all control statements

Categories:

🔧 Fix

default-case

Require default cases in switch statements

Categories:
default-case-last

Enforce default clauses in switch statements to be last

Categories:
default-param-last

Enforce default parameters to be last

Categories:
dot-notation

Enforce dot notation whenever possible

Categories:

🔧 Fix

eqeqeq

Require the use of === and !==

Categories:

🔧 Fix

func-name-matching

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

Categories:
func-names

Require or disallow named function expressions

Categories:
func-style

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

Categories:
grouped-accessor-pairs

Require grouped accessor pairs in object literals and classes

Categories:
guard-for-in

Require for-in loops to include an if statement

Categories:
id-denylist

Disallow specified identifiers

Categories:
id-length

Enforce minimum and maximum identifier lengths

Categories:
id-match

Require identifiers to match a specified regular expression

Categories:
init-declarations

Require or disallow initialization in variable declarations

Categories:
max-classes-per-file

Enforce a maximum number of classes per file

Categories:
max-depth

Enforce a maximum depth that blocks can be nested

Categories:
max-lines

Enforce a maximum number of lines per file

Categories:
max-lines-per-function

Enforce a maximum number of lines of code in a function

Categories:
max-nested-callbacks

Enforce a maximum depth that callbacks can be nested

Categories:
max-params

Enforce a maximum number of parameters in function definitions

Categories:
max-statements

Enforce a maximum number of statements allowed in function blocks

Categories:
new-cap

Require constructor names to begin with a capital letter

Categories:
no-alert

Disallow the use of alert, confirm, and prompt

Categories:
no-array-constructor

Disallow Array constructors

Categories:

💡 Suggestions

no-bitwise

Disallow bitwise operators

Categories:
no-caller

Disallow the use of arguments.caller or arguments.callee

Categories:
no-case-declarations

Disallow lexical declarations in case clauses

Categories:

Extends

💡 Suggestions

no-console

Disallow the use of console

Categories:

💡 Suggestions

no-continue

Disallow continue statements

Categories:
no-delete-var

Disallow deleting variables

Categories:

Extends

no-div-regex

Disallow equal signs explicitly at the beginning of regular expressions

Categories:

🔧 Fix

no-else-return

Disallow else blocks after return statements in if statements

Categories:

🔧 Fix

no-empty

Disallow empty block statements

Categories:

Extends

💡 Suggestions

no-empty-function

Disallow empty functions

Categories:
no-eq-null

Disallow null comparisons without type-checking operators

Categories:
no-eval

Disallow the use of eval()

Categories:
no-extend-native

Disallow extending native types

Categories:
no-extra-bind

Disallow unnecessary calls to .bind()

Categories:

🔧 Fix

no-extra-boolean-cast

Disallow unnecessary boolean casts

Categories:

Extends

🔧 Fix

no-extra-label

Disallow unnecessary labels

Categories:

🔧 Fix

no-global-assign

Disallow assignments to native objects or read-only global variables

Categories:

Extends

no-implicit-coercion

Disallow shorthand type conversions

Categories:

🔧 Fix

💡 Suggestions

no-implicit-globals

Disallow declarations in the global scope

Categories:
no-implied-eval

Disallow the use of eval()-like methods

Categories:
no-inline-comments

Disallow inline comments after code

Categories:
no-invalid-this

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

Categories:
no-iterator

Disallow the use of the __iterator__ property

Categories:
no-label-var

Disallow labels that share a name with a variable

Categories:
no-labels

Disallow labeled statements

Categories:
no-lone-blocks

Disallow unnecessary nested blocks

Categories:
no-lonely-if

Disallow if statements as the only statement in else blocks

Categories:

🔧 Fix

no-loop-func

Disallow function declarations that contain unsafe references inside loop statements

Categories:
no-magic-numbers

Disallow magic numbers

Categories:
no-multi-assign

Disallow use of chained assignment expressions

Categories:
no-multi-str

Disallow multiline strings

Categories:
no-negated-condition

Disallow negated conditions

Categories:
no-nested-ternary

Disallow nested ternary expressions

Categories:
no-new

Disallow new operators outside of assignments or comparisons

Categories:
no-new-func

Disallow new operators with the Function object

Categories:
no-new-wrappers

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

Categories:
no-nonoctal-decimal-escape

Disallow \8 and \9 escape sequences in string literals

Categories:

Extends

💡 Suggestions

no-object-constructor

Disallow calls to the Object constructor without an argument

Categories:

💡 Suggestions

no-octal

Disallow octal literals

Categories:

Extends

no-octal-escape

Disallow octal escape sequences in string literals

Categories:
no-param-reassign

Disallow reassigning function parameters

Categories:
no-plusplus

Disallow the unary operators ++ and --

Categories:
no-proto

Disallow the use of the __proto__ property

Categories:
no-redeclare

Disallow variable redeclaration

Categories:

Extends

no-regex-spaces

Disallow multiple spaces in regular expressions

Categories:

Extends

🔧 Fix

no-restricted-exports

Disallow specified names in exports

Categories:
no-restricted-globals

Disallow specified global variables

Categories:
no-restricted-imports

Disallow specified modules when loaded by import

Categories:
no-restricted-properties

Disallow certain properties on certain objects

Categories:
no-return-assign

Disallow assignment operators in return statements

Categories:
no-script-url

Disallow javascript: urls

Categories:
no-sequences

Disallow comma operators

Categories:
no-shadow

Disallow variable declarations from shadowing variables declared in the outer scope

Categories:
no-shadow-restricted-names

Disallow identifiers from shadowing restricted names

Categories:

Extends

no-ternary

Disallow ternary operators

Categories:
no-throw-literal

Disallow throwing literals as exceptions

Categories:
no-undef-init

Disallow initializing variables to undefined

Categories:

🔧 Fix

no-undefined

Disallow the use of undefined as an identifier

Categories:
no-underscore-dangle

Disallow dangling underscores in identifiers

Categories:
no-unneeded-ternary

Disallow ternary operators when simpler alternatives exist

Categories:

🔧 Fix

no-unused-labels

Disallow unused labels

Categories:

Extends

🔧 Fix

no-useless-call

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

Categories:
no-useless-catch

Disallow unnecessary catch clauses

Categories:

Extends

no-useless-computed-key

Disallow unnecessary computed property keys in objects and classes

Categories:

🔧 Fix

no-useless-concat

Disallow unnecessary concatenation of literals or template literals

Categories:
no-useless-escape

Disallow unnecessary escape characters

Categories:

Extends

💡 Suggestions

no-useless-rename

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

Categories:

🔧 Fix

no-useless-return

Disallow redundant return statements

Categories:

🔧 Fix

no-var

Require let or const instead of var

Categories:

🔧 Fix

no-void

Disallow void operators

Categories:
no-warning-comments

Disallow specified warning terms in comments

Categories:
no-with

Disallow with statements

Categories:

Extends

object-shorthand

Require or disallow method and property shorthand syntax for object literals

Categories:

🔧 Fix

one-var

Enforce variables to be declared either together or separately in functions

Categories:

🔧 Fix

operator-assignment

Require or disallow assignment operator shorthand where possible

Categories:

🔧 Fix

prefer-arrow-callback

Require using arrow functions for callbacks

Categories:

🔧 Fix

prefer-const

Require const declarations for variables that are never reassigned after declared

Categories:

🔧 Fix

prefer-destructuring

Require destructuring from arrays and/or objects

Categories:

🔧 Fix

prefer-named-capture-group

Enforce using named capture group in regular expression

Categories:

💡 Suggestions

prefer-numeric-literals

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

Categories:

🔧 Fix

prefer-object-has-own

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

Categories:

🔧 Fix

prefer-object-spread

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

Categories:

🔧 Fix

prefer-regex-literals

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

Categories:

💡 Suggestions

prefer-rest-params

Require rest parameters instead of arguments

Categories:
prefer-spread

Require spread operators instead of .apply()

Categories:
prefer-template

Require template literals instead of string concatenation

Categories:

🔧 Fix

radix

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

Categories:

💡 Suggestions

require-await

Disallow async functions which have no await expression

Categories:

💡 Suggestions

require-unicode-regexp

Enforce the use of u or v flag on RegExp

Categories:

💡 Suggestions

require-yield

Require generator functions to contain yield

Categories:

Extends

sort-imports

Enforce sorted import declarations within modules

Categories:

🔧 Fix

sort-keys

Require object keys to be sorted

Categories:
sort-vars

Require variables within the same declaration block to be sorted

Categories:

🔧 Fix

strict

Require or disallow strict mode directives

Categories:

🔧 Fix

symbol-description

Require symbol descriptions

Categories:
vars-on-top

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

Categories:
yoda

Require or disallow “Yoda” conditions

Categories:

🔧 Fix

Layout & Formatting

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

unicode-bom

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