Enforce return
statements in callbacks of array methods
💡 Suggestions
Rules in ESLint are grouped by type to help you understand their purpose. Each rule has emojis denoting:
Using the recommended
config from @eslint/js
in a configuration file
enables this rule
Some problems reported by this rule are automatically fixable by the --fix
command line option
Some problems reported by this rule are manually fixable by editor suggestions
This rule is currently frozen and is not accepting feature requests.
These rules relate to possible logic errors in code:
Enforce return
statements in callbacks of array methods
💡 Suggestions
Require super()
calls in constructors
✅ Extends
Enforce for
loop update clause moving the counter in the right direction
✅ Extends
Enforce return
statements in getters
✅ Extends
Disallow using an async function as a Promise executor
✅ Extends
Disallow await
inside of loops
Disallow reassigning class members
✅ Extends
Disallow comparing against -0
✅ Extends
Disallow assignment operators in conditional expressions
✅ Extends
Disallow reassigning const
variables
✅ Extends
Disallow expressions where the operation doesn’t affect the value
✅ Extends
Disallow constant expressions in conditions
✅ Extends
Disallow returning value from constructor
Disallow control characters in regular expressions
✅ Extends
Disallow the use of debugger
✅ Extends
Disallow duplicate arguments in function
definitions
✅ Extends
Disallow duplicate class members
✅ Extends
Disallow duplicate conditions in if-else-if chains
✅ Extends
Disallow duplicate keys in object literals
✅ Extends
Disallow duplicate case labels
✅ Extends
Disallow duplicate module imports
Disallow empty character classes in regular expressions
✅ Extends
Disallow empty destructuring patterns
✅ Extends
Disallow reassigning exceptions in catch
clauses
✅ Extends
Disallow fallthrough of case
statements
✅ Extends
Disallow reassigning function
declarations
✅ Extends
Disallow assigning to imported bindings
✅ Extends
Disallow variable or function
declarations in nested blocks
Disallow invalid regular expression strings in RegExp
constructors
✅ Extends
Disallow irregular whitespace
✅ Extends
Disallow literal numbers that lose precision
✅ Extends
Disallow characters which are made with multiple code points in character class syntax
✅ Extends
💡 Suggestions
Disallow new
operators with global non-constructor functions
✅ Extends
Disallow calling global object properties as functions
✅ Extends
Disallow returning values from Promise executor functions
💡 Suggestions
Disallow calling some Object.prototype
methods directly on objects
✅ Extends
💡 Suggestions
Disallow assignments where both sides are exactly the same
✅ Extends
Disallow comparisons where both sides are exactly the same
Disallow returning values from setters
✅ Extends
Disallow sparse arrays
✅ Extends
Disallow template literal placeholder syntax in regular strings
Disallow this
/super
before calling super()
in constructors
✅ Extends
Disallow the use of undeclared variables unless mentioned in /*global */
comments
✅ Extends
Disallow confusing multiline expressions
✅ Extends
Disallow unmodified loop conditions
Disallow unreachable code after return
, throw
, continue
, and break
statements
✅ Extends
Disallow loops with a body that allows only one iteration
Disallow control flow statements in finally
blocks
✅ Extends
Disallow negating the left operand of relational operators
✅ Extends
💡 Suggestions
Disallow use of optional chaining in contexts where the undefined
value is not allowed
✅ Extends
Disallow unused private class members
✅ Extends
Disallow unused variables
✅ Extends
💡 Suggestions
Disallow the use of variables before they are defined
Disallow variable assignments when the value is not used
Disallow useless backreferences in regular expressions
✅ Extends
Disallow assignments that can lead to race conditions due to usage of await
or yield
Require calls to isNaN()
when checking for NaN
✅ Extends
💡 Suggestions
Enforce comparing typeof
expressions against valid strings
✅ Extends
💡 Suggestions
These rules suggest alternate ways of doing things:
Enforce getter and setter pairs in objects and classes
❄️ Frozen
Require braces around arrow function bodies
🔧 Fix
Enforce the use of variables within the scope they are defined
❄️ Frozen
Enforce camelcase naming convention
❄️ Frozen
Enforce or disallow capitalization of the first letter of a comment
🔧 Fix
Enforce that class methods utilize this
Enforce a maximum cyclomatic complexity allowed in a program
Require return
statements to either always or never specify values
❄️ Frozen
Enforce consistent naming when capturing the current execution context
❄️ Frozen
Enforce consistent brace style for all control statements
🔧 Fix
Require default
cases in switch
statements
Enforce default
clauses in switch
statements to be last
❄️ Frozen
Enforce default parameters to be last
❄️ Frozen
Enforce dot notation whenever possible
🔧 Fix
Require the use of ===
and !==
🔧 Fix
❄️ Frozen
Require function names to match the name of the variable or property to which they are assigned
Require or disallow named function
expressions
❄️ Frozen
Enforce the consistent use of either function
declarations or expressions assigned to variables
Require grouped accessor pairs in object literals and classes
Require for-in
loops to include an if
statement
❄️ Frozen
Disallow specified identifiers
❄️ Frozen
Enforce minimum and maximum identifier lengths
❄️ Frozen
Require identifiers to match a specified regular expression
❄️ Frozen
Require or disallow initialization in variable declarations
❄️ Frozen
Require or disallow logical assignment operator shorthand
🔧 Fix
💡 Suggestions
Enforce a maximum number of classes per file
Enforce a maximum depth that blocks can be nested
Enforce a maximum number of lines per file
Enforce a maximum number of lines of code in a function
Enforce a maximum depth that callbacks can be nested
Enforce a maximum number of parameters in function definitions
Enforce a maximum number of statements allowed in function blocks
Require constructor names to begin with a capital letter
Disallow the use of alert
, confirm
, and prompt
Disallow Array
constructors
💡 Suggestions
Disallow bitwise operators
Disallow the use of arguments.caller
or arguments.callee
Disallow lexical declarations in case clauses
✅ Extends
💡 Suggestions
Disallow the use of console
💡 Suggestions
❄️ Frozen
Disallow continue
statements
Disallow deleting variables
✅ Extends
❄️ Frozen
Disallow equal signs explicitly at the beginning of regular expressions
🔧 Fix
❄️ Frozen
Disallow else
blocks after return
statements in if
statements
🔧 Fix
Disallow empty block statements
✅ Extends
💡 Suggestions
Disallow empty functions
Disallow empty static blocks
✅ Extends
Disallow null
comparisons without type-checking operators
Disallow the use of eval()
Disallow extending native types
Disallow unnecessary calls to .bind()
🔧 Fix
❄️ Frozen
Disallow unnecessary boolean casts
✅ Extends
🔧 Fix
❄️ Frozen
Disallow unnecessary labels
🔧 Fix
Disallow assignments to native objects or read-only global variables
✅ Extends
❄️ Frozen
Disallow shorthand type conversions
🔧 Fix
💡 Suggestions
Disallow declarations in the global scope
Disallow the use of eval()
-like methods
❄️ Frozen
Disallow inline comments after code
Disallow use of this
in contexts where the value of this
is undefined
Disallow the use of the __iterator__
property
❄️ Frozen
Disallow labels that share a name with a variable
❄️ Frozen
Disallow labeled statements
Disallow unnecessary nested blocks
❄️ Frozen
Disallow if
statements as the only statement in else
blocks
🔧 Fix
Disallow function declarations that contain unsafe references inside loop statements
❄️ Frozen
Disallow magic numbers
Disallow use of chained assignment expressions
❄️ Frozen
Disallow multiline strings
❄️ Frozen
Disallow negated conditions
❄️ Frozen
Disallow nested ternary expressions
Disallow new
operators outside of assignments or comparisons
Disallow new
operators with the Function
object
Disallow new
operators with the String
, Number
, and Boolean
objects
Disallow \8
and \9
escape sequences in string literals
✅ Extends
💡 Suggestions
Disallow calls to the Object
constructor without an argument
💡 Suggestions
Disallow octal literals
✅ Extends
Disallow octal escape sequences in string literals
Disallow reassigning function parameters
❄️ Frozen
Disallow the unary operators ++
and --
Disallow the use of the __proto__
property
Disallow variable redeclaration
✅ Extends
Disallow multiple spaces in regular expressions
✅ Extends
🔧 Fix
Disallow specified names in exports
Disallow specified global variables
Disallow specified modules when loaded by import
Disallow certain properties on certain objects
Disallow specified syntax
Disallow assignment operators in return
statements
Disallow javascript:
URLs
Disallow comma operators
Disallow variable declarations from shadowing variables declared in the outer scope
Disallow identifiers from shadowing restricted names
✅ Extends
❄️ Frozen
Disallow ternary operators
Disallow throwing literals as exceptions
❄️ Frozen
Disallow initializing variables to undefined
🔧 Fix
❄️ Frozen
Disallow the use of undefined
as an identifier
❄️ Frozen
Disallow dangling underscores in identifiers
❄️ Frozen
Disallow ternary operators when simpler alternatives exist
🔧 Fix
Disallow unused expressions
Disallow unused labels
✅ Extends
🔧 Fix
Disallow unnecessary calls to .call()
and .apply()
Disallow unnecessary catch
clauses
✅ Extends
❄️ Frozen
Disallow unnecessary computed property keys in objects and classes
🔧 Fix
❄️ Frozen
Disallow unnecessary concatenation of literals or template literals
Disallow unnecessary constructors
💡 Suggestions
Disallow unnecessary escape characters
✅ Extends
💡 Suggestions
Disallow renaming import, export, and destructured assignments to the same name
🔧 Fix
Disallow redundant return statements
🔧 Fix
Require let
or const
instead of var
🔧 Fix
❄️ Frozen
Disallow void
operators
❄️ Frozen
Disallow specified warning terms in comments
Disallow with
statements
✅ Extends
❄️ Frozen
Require or disallow method and property shorthand syntax for object literals
🔧 Fix
❄️ Frozen
Enforce variables to be declared either together or separately in functions
🔧 Fix
❄️ Frozen
Require or disallow assignment operator shorthand where possible
🔧 Fix
❄️ Frozen
Require using arrow functions for callbacks
🔧 Fix
Require const
declarations for variables that are never reassigned after declared
🔧 Fix
❄️ Frozen
Require destructuring from arrays and/or objects
🔧 Fix
❄️ Frozen
Disallow the use of Math.pow
in favor of the **
operator
🔧 Fix
Enforce using named capture group in regular expression
💡 Suggestions
❄️ Frozen
Disallow parseInt()
and Number.parseInt()
in favor of binary, octal, and hexadecimal literals
🔧 Fix
Disallow use of Object.prototype.hasOwnProperty.call()
and prefer use of Object.hasOwn()
🔧 Fix
❄️ Frozen
Disallow using Object.assign
with an object literal as the first argument and prefer the use of object spread instead
🔧 Fix
Require using Error objects as Promise rejection reasons
Disallow use of the RegExp
constructor in favor of regular expression literals
💡 Suggestions
Require rest parameters instead of arguments
❄️ Frozen
Require spread operators instead of .apply()
❄️ Frozen
Require template literals instead of string concatenation
🔧 Fix
Enforce the consistent use of the radix argument when using parseInt()
💡 Suggestions
Disallow async functions which have no await
expression
💡 Suggestions
Enforce the use of u
or v
flag on regular expressions
💡 Suggestions
Require generator functions to contain yield
✅ Extends
❄️ Frozen
Enforce sorted import
declarations within modules
🔧 Fix
❄️ Frozen
Require object keys to be sorted
❄️ Frozen
Require variables within the same declaration block to be sorted
🔧 Fix
Require or disallow strict mode directives
🔧 Fix
Require symbol descriptions
❄️ Frozen
Require var
declarations be placed at the top of their containing scope
❄️ Frozen
Require or disallow “Yoda” conditions
🔧 Fix
These rules care about how the code looks rather than how it executes:
Require or disallow Unicode byte order mark (BOM)
🔧 Fix
These rules have been deprecated in accordance with the deprecation policy, and replaced by newer rules:
array-bracket-newline deprecated
Replaced by
array-bracket-newline
in @stylistic/eslint-plugin-js
❌
🔧 Fix
array-bracket-spacing deprecated
Replaced by
array-bracket-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
array-element-newline deprecated
Replaced by
array-element-newline
in @stylistic/eslint-plugin-js
❌
🔧 Fix
arrow-parens deprecated
Replaced by
arrow-parens
in @stylistic/eslint-plugin-js
❌
🔧 Fix
arrow-spacing deprecated
Replaced by
arrow-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
block-spacing deprecated
Replaced by
block-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
brace-style deprecated
Replaced by
brace-style
in @stylistic/eslint-plugin-js
❌
🔧 Fix
callback-return deprecated
Replaced by
callback-return
in eslint-plugin-n
❌
comma-dangle deprecated
Replaced by
comma-dangle
in @stylistic/eslint-plugin-js
❌
🔧 Fix
comma-spacing deprecated
Replaced by
comma-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
comma-style deprecated
Replaced by
comma-style
in @stylistic/eslint-plugin-js
❌
🔧 Fix
computed-property-spacing deprecated
Replaced by
computed-property-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
dot-location deprecated
Replaced by
dot-location
in @stylistic/eslint-plugin-js
❌
🔧 Fix
eol-last deprecated
Replaced by
eol-last
in @stylistic/eslint-plugin-js
❌
🔧 Fix
func-call-spacing deprecated
Replaced by
function-call-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
function-call-argument-newline deprecated
Replaced by
function-call-argument-newline
in @stylistic/eslint-plugin-js
❌
🔧 Fix
function-paren-newline deprecated
Replaced by
function-paren-newline
in @stylistic/eslint-plugin-js
❌
🔧 Fix
generator-star-spacing deprecated
Replaced by
generator-star-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
global-require deprecated
Replaced by
global-require
in eslint-plugin-n
❌
handle-callback-err deprecated
Replaced by
handle-callback-err
in eslint-plugin-n
❌
id-blacklist deprecated
Replaced by
id-denylist
❌
implicit-arrow-linebreak deprecated
Replaced by
implicit-arrow-linebreak
in @stylistic/eslint-plugin-js
❌
🔧 Fix
indent deprecated
Replaced by
indent
in @stylistic/eslint-plugin-js
❌
🔧 Fix
indent-legacy deprecated
Replaced by
indent
in @stylistic/eslint-plugin-js
❌
🔧 Fix
jsx-quotes deprecated
Replaced by
jsx-quotes
in @stylistic/eslint-plugin-js
❌
🔧 Fix
key-spacing deprecated
Replaced by
key-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
keyword-spacing deprecated
Replaced by
keyword-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
line-comment-position deprecated
Replaced by
line-comment-position
in @stylistic/eslint-plugin-js
❌
linebreak-style deprecated
Replaced by
linebreak-style
in @stylistic/eslint-plugin-js
❌
🔧 Fix
lines-around-comment deprecated
Replaced by
lines-around-comment
in @stylistic/eslint-plugin-js
❌
🔧 Fix
lines-around-directive deprecated
Replaced by
padding-line-between-statements
in @stylistic/eslint-plugin-js
❌
🔧 Fix
lines-between-class-members deprecated
Replaced by
lines-between-class-members
in @stylistic/eslint-plugin-js
❌
🔧 Fix
max-len deprecated
Replaced by
max-len
in @stylistic/eslint-plugin-js
❌
max-statements-per-line deprecated
Replaced by
max-statements-per-line
in @stylistic/eslint-plugin-js
❌
multiline-comment-style deprecated
Replaced by
multiline-comment-style
in @stylistic/eslint-plugin-js
❌
🔧 Fix
multiline-ternary deprecated
Replaced by
multiline-ternary
in @stylistic/eslint-plugin-js
❌
🔧 Fix
new-parens deprecated
Replaced by
new-parens
in @stylistic/eslint-plugin-js
❌
🔧 Fix
newline-after-var deprecated
Replaced by
padding-line-between-statements
in @stylistic/eslint-plugin-js
❌
🔧 Fix
newline-before-return deprecated
Replaced by
padding-line-between-statements
in @stylistic/eslint-plugin-js
❌
🔧 Fix
newline-per-chained-call deprecated
Replaced by
newline-per-chained-call
in @stylistic/eslint-plugin-js
❌
🔧 Fix
no-buffer-constructor deprecated
Replaced by
no-deprecated-api
in eslint-plugin-n
❌
no-catch-shadow deprecated
Replaced by
no-shadow
❌
no-confusing-arrow deprecated
Replaced by
no-confusing-arrow
in @stylistic/eslint-plugin-js
❌
🔧 Fix
no-extra-parens deprecated
Replaced by
no-extra-parens
in @stylistic/eslint-plugin-js
❌
🔧 Fix
no-extra-semi deprecated
Replaced by
no-extra-semi
in @stylistic/eslint-plugin-js
❌
🔧 Fix
no-floating-decimal deprecated
Replaced by
no-floating-decimal
in @stylistic/eslint-plugin-js
❌
🔧 Fix
no-mixed-operators deprecated
Replaced by
no-mixed-operators
in @stylistic/eslint-plugin-js
❌
no-mixed-requires deprecated
Replaced by
no-mixed-requires
in eslint-plugin-n
❌
no-mixed-spaces-and-tabs deprecated
Replaced by
no-mixed-spaces-and-tabs
in @stylistic/eslint-plugin-js
❌
no-multi-spaces deprecated
Replaced by
no-multi-spaces
in @stylistic/eslint-plugin-js
❌
🔧 Fix
no-multiple-empty-lines deprecated
Replaced by
no-multiple-empty-lines
in @stylistic/eslint-plugin-js
❌
🔧 Fix
no-native-reassign deprecated
Replaced by
no-global-assign
❌
no-negated-in-lhs deprecated
Replaced by
no-unsafe-negation
❌
no-new-object deprecated
Replaced by
no-object-constructor
❌
no-new-require deprecated
Replaced by
no-new-require
in eslint-plugin-n
❌
no-new-symbol deprecated
Replaced by
no-new-native-nonconstructor
❌
no-path-concat deprecated
Replaced by
no-path-concat
in eslint-plugin-n
❌
no-process-env deprecated
Replaced by
no-process-env
in eslint-plugin-n
❌
no-process-exit deprecated
Replaced by
no-process-exit
in eslint-plugin-n
❌
no-restricted-modules deprecated
Replaced by
no-restricted-require
in eslint-plugin-n
❌
no-return-await deprecated
❌
💡 Suggestions
no-spaced-func deprecated
Replaced by
function-call-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
no-sync deprecated
Replaced by
no-sync
in eslint-plugin-n
❌
no-tabs deprecated
Replaced by
no-tabs
in @stylistic/eslint-plugin-js
❌
no-trailing-spaces deprecated
Replaced by
no-trailing-spaces
in @stylistic/eslint-plugin-js
❌
🔧 Fix
no-whitespace-before-property deprecated
Replaced by
no-whitespace-before-property
in @stylistic/eslint-plugin-js
❌
🔧 Fix
nonblock-statement-body-position deprecated
Replaced by
nonblock-statement-body-position
in @stylistic/eslint-plugin-js
❌
🔧 Fix
object-curly-newline deprecated
Replaced by
object-curly-newline
in @stylistic/eslint-plugin-js
❌
🔧 Fix
object-curly-spacing deprecated
Replaced by
object-curly-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
object-property-newline deprecated
Replaced by
object-property-newline
in @stylistic/eslint-plugin-js
❌
🔧 Fix
one-var-declaration-per-line deprecated
Replaced by
one-var-declaration-per-line
in @stylistic/eslint-plugin-js
❌
🔧 Fix
operator-linebreak deprecated
Replaced by
operator-linebreak
in @stylistic/eslint-plugin-js
❌
🔧 Fix
padded-blocks deprecated
Replaced by
padded-blocks
in @stylistic/eslint-plugin-js
❌
🔧 Fix
padding-line-between-statements deprecated
Replaced by
padding-line-between-statements
in @stylistic/eslint-plugin-js
❌
🔧 Fix
prefer-reflect deprecated
❌
quote-props deprecated
Replaced by
quote-props
in @stylistic/eslint-plugin-js
❌
🔧 Fix
quotes deprecated
Replaced by
quotes
in @stylistic/eslint-plugin-js
❌
🔧 Fix
rest-spread-spacing deprecated
Replaced by
rest-spread-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
semi deprecated
Replaced by
semi
in @stylistic/eslint-plugin-js
❌
🔧 Fix
semi-spacing deprecated
Replaced by
semi-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
semi-style deprecated
Replaced by
semi-style
in @stylistic/eslint-plugin-js
❌
🔧 Fix
space-before-blocks deprecated
Replaced by
space-before-blocks
in @stylistic/eslint-plugin-js
❌
🔧 Fix
space-before-function-paren deprecated
Replaced by
space-before-function-paren
in @stylistic/eslint-plugin-js
❌
🔧 Fix
space-in-parens deprecated
Replaced by
space-in-parens
in @stylistic/eslint-plugin-js
❌
🔧 Fix
space-infix-ops deprecated
Replaced by
space-infix-ops
in @stylistic/eslint-plugin-js
❌
🔧 Fix
space-unary-ops deprecated
Replaced by
space-unary-ops
in @stylistic/eslint-plugin-js
❌
🔧 Fix
spaced-comment deprecated
Replaced by
spaced-comment
in @stylistic/eslint-plugin-js
❌
🔧 Fix
switch-colon-spacing deprecated
Replaced by
switch-colon-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
template-curly-spacing deprecated
Replaced by
template-curly-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
template-tag-spacing deprecated
Replaced by
template-tag-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
wrap-iife deprecated
Replaced by
wrap-iife
in @stylistic/eslint-plugin-js
❌
🔧 Fix
wrap-regex deprecated
Replaced by
wrap-regex
in @stylistic/eslint-plugin-js
❌
🔧 Fix
yield-star-spacing deprecated
Replaced by
yield-star-spacing
in @stylistic/eslint-plugin-js
❌
🔧 Fix
These rules from older versions of ESLint (before the deprecation policy existed) have been replaced by newer rules:
generator-star removed
Replaced by
generator-star-spacing
global-strict removed
Replaced by
strict
no-arrow-condition removed
Replaced by
no-confusing-arrow
or
no-constant-condition
no-comma-dangle removed
Replaced by
comma-dangle
no-empty-class removed
Replaced by
no-empty-character-class
no-empty-label removed
Replaced by
no-labels
no-extra-strict removed
Replaced by
strict
no-reserved-keys removed
Replaced by
quote-props
no-space-before-semi removed
Replaced by
semi-spacing
no-wrap-func removed
Replaced by
no-extra-parens
space-after-function-name removed
Replaced by
space-before-function-paren
space-after-keywords removed
Replaced by
keyword-spacing
space-before-function-parentheses removed
Replaced by
space-before-function-paren
space-before-keywords removed
Replaced by
keyword-spacing
space-in-brackets removed
Replaced by
object-curly-spacing
or
array-bracket-spacing
space-return-throw-case removed
Replaced by
keyword-spacing
space-unary-word-ops removed
Replaced by
space-unary-ops
spaced-line-comment removed
Replaced by
spaced-comment
valid-jsdoc removed
require-jsdoc removed