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 changes.
These rules relate to possible logic errors in code: Enforce
💡 Suggestions
Require
✅ Extends
Enforce
✅ Extends
Enforce
✅ Extends
Disallow using an async function as a Promise executor
✅ Extends
Disallow Disallow reassigning class members
✅ Extends
Disallow comparing against
✅ Extends
Disallow assignment operators in conditional expressions
✅ Extends
Disallow reassigning
✅ 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
✅ Extends
Disallow duplicate arguments in
✅ 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
✅ Extends
Disallow fallthrough of
✅ Extends
Disallow reassigning
✅ Extends
Disallow assigning to imported bindings
✅ Extends
Disallow variable or Disallow invalid regular expression strings in
✅ 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
✅ Extends
Disallow calling global object properties as functions
✅ Extends
Disallow returning values from Promise executor functions
💡 Suggestions
Disallow calling some
✅ 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
✅ Extends
Disallow the use of undeclared variables unless mentioned in
✅ Extends
Disallow confusing multiline expressions
✅ Extends
Disallow unmodified loop conditions Disallow unreachable code after
✅ Extends
Disallow loops with a body that allows only one iteration Disallow control flow statements in
✅ Extends
Disallow negating the left operand of relational operators
✅ Extends
💡 Suggestions
Disallow use of optional chaining in contexts where the
✅ 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 Require calls to
✅ Extends
💡 Suggestions
Enforce comparing
✅ Extends
💡 Suggestions
return
statements in callbacks of array methodssuper()
calls in constructorsfor
loop update clause moving the counter in the right directionreturn
statements in gettersawait
inside of loops-0
const
variablesdebugger
function
definitionscatch
clausescase
statementsfunction
declarationsfunction
declarations in nested blocksRegExp
constructorsnew
operators with global non-constructor functionsObject.prototype
methods directly on objectsthis
/super
before calling super()
in constructors/*global */
commentsreturn
, throw
, continue
, and break
statementsfinally
blocksundefined
value is not allowedawait
or yield
isNaN()
when checking for NaN
typeof
expressions against valid strings
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 Enforce a maximum cyclomatic complexity allowed in a program Require ❄️ Frozen Enforce consistent naming when capturing the current execution context ❄️ Frozen Enforce consistent brace style for all control statements
🔧 Fix
Require Enforce ❄️ Frozen Enforce default parameters to be last ❄️ Frozen Enforce dot notation whenever possible
🔧 Fix
Require the use of
🔧 Fix
❄️ Frozen Require function names to match the name of the variable or property to which they are assigned Require or disallow named ❄️ Frozen Enforce the consistent use of either Require grouped accessor pairs in object literals and classes Require ❄️ 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 Disallow
💡 Suggestions
Disallow bitwise operators Disallow the use of Disallow lexical declarations in case clauses
✅ Extends
💡 Suggestions
Disallow the use of
💡 Suggestions
❄️ Frozen Disallow Disallow deleting variables
✅ Extends
❄️ Frozen Disallow equal signs explicitly at the beginning of regular expressions
🔧 Fix
❄️ Frozen Disallow
🔧 Fix
Disallow empty block statements
✅ Extends
💡 Suggestions
Disallow empty functions Disallow empty static blocks
✅ Extends
Disallow Disallow the use of Disallow extending native types Disallow unnecessary calls to
🔧 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 ❄️ Frozen Disallow inline comments after code Disallow use of Disallow the use of the ❄️ Frozen Disallow labels that share a name with a variable ❄️ Frozen Disallow labeled statements Disallow unnecessary nested blocks ❄️ Frozen Disallow
🔧 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 Disallow Disallow Disallow
✅ Extends
💡 Suggestions
Disallow calls to the
💡 Suggestions
Disallow octal literals
✅ Extends
Disallow octal escape sequences in string literals Disallow reassigning function parameters ❄️ Frozen Disallow the unary operators Disallow the use of the 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 Disallow certain properties on certain objects Disallow specified syntax Disallow assignment operators in Disallow 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
🔧 Fix
❄️ Frozen Disallow the use of ❄️ 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 Disallow unnecessary
✅ 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
🔧 Fix
❄️ Frozen Disallow ❄️ Frozen Disallow specified warning terms in comments Disallow
✅ 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
🔧 Fix
❄️ Frozen Require destructuring from arrays and/or objects
🔧 Fix
❄️ Frozen Disallow the use of
🔧 Fix
Enforce using named capture group in regular expression
💡 Suggestions
❄️ Frozen Disallow
🔧 Fix
Disallow use of
🔧 Fix
❄️ Frozen Disallow using
🔧 Fix
Require using Error objects as Promise rejection reasons Disallow use of the
💡 Suggestions
Require rest parameters instead of ❄️ Frozen Require spread operators instead of ❄️ Frozen Require template literals instead of string concatenation
🔧 Fix
Enforce the consistent use of the radix argument when using
💡 Suggestions
Disallow async functions which have no
💡 Suggestions
Enforce the use of
💡 Suggestions
Require generator functions to contain
✅ 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 ❄️ Frozen Require or disallow “Yoda” conditions
🔧 Fix
this
return
statements to either always or never specify valuesdefault
cases in switch
statementsdefault
clauses in switch statements to be last===
and !==
function
expressionsfunction
declarations or expressions assigned to variablesfor-in
loops to include an if
statementalert
, confirm
, and prompt
Array
constructorsarguments.caller
or arguments.callee
console
continue
statementselse
blocks after return
statements in if
statementsnull
comparisons without type-checking operatorseval()
.bind()
eval()
-like methodsthis
in contexts where the value of this
is undefined
__iterator__
propertyif
statements as the only statement in else
blocksnew
operators outside of assignments or comparisonsnew
operators with the Function
objectnew
operators with the String
, Number
, and Boolean
objects\8
and \9
escape sequences in string literalsObject
constructor without an argument++
and --
__proto__
propertyimport
return
statementsjavascript:
URLsundefined
undefined
as an identifier.call()
and .apply()
catch
clauseslet
or const
instead of var
void
operatorswith
statementsconst
declarations for variables that are never reassigned after declaredMath.pow
in favor of the **
operatorparseInt()
and Number.parseInt()
in favor of binary, octal, and hexadecimal literalsObject.prototype.hasOwnProperty.call()
and prefer use of Object.hasOwn()
Object.assign
with an object literal as the first argument and prefer the use of object spread insteadRegExp
constructor in favor of regular expression literalsarguments
.apply()
parseInt()
await
expressionu
or v
flag on regular expressionsyield
var
declarations be placed at the top of their containing scope
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
❌
🔧 Fix
array-bracket-spacing
deprecated
❌
🔧 Fix
array-element-newline
deprecated
❌
🔧 Fix
arrow-parens
deprecated
❌
🔧 Fix
arrow-spacing
deprecated
❌
🔧 Fix
block-spacing
deprecated
❌
🔧 Fix
brace-style
deprecated
❌
🔧 Fix
callback-return
deprecated
❌
comma-dangle
deprecated
❌
🔧 Fix
comma-spacing
deprecated
❌
🔧 Fix
comma-style
deprecated
❌
🔧 Fix
computed-property-spacing
deprecated
❌
🔧 Fix
dot-location
deprecated
❌
🔧 Fix
eol-last
deprecated
❌
🔧 Fix
func-call-spacing
deprecated
❌
🔧 Fix
function-call-argument-newline
deprecated
❌
🔧 Fix
function-paren-newline
deprecated
❌
🔧 Fix
generator-star-spacing
deprecated
❌
🔧 Fix
global-require
deprecated
❌
handle-callback-err
deprecated
❌
id-blacklist
deprecated
Replaced by ❌
implicit-arrow-linebreak
deprecated
❌
🔧 Fix
indent
deprecated
❌
🔧 Fix
indent-legacy
deprecated
Replaced by ❌
🔧 Fix
jsx-quotes
deprecated
❌
🔧 Fix
key-spacing
deprecated
❌
🔧 Fix
keyword-spacing
deprecated
❌
🔧 Fix
line-comment-position
deprecated
❌
linebreak-style
deprecated
❌
🔧 Fix
lines-around-comment
deprecated
❌
🔧 Fix
lines-around-directive
deprecated
Replaced by ❌
🔧 Fix
lines-between-class-members
deprecated
❌
🔧 Fix
max-len
deprecated
❌
max-statements-per-line
deprecated
❌
multiline-comment-style
deprecated
❌
🔧 Fix
multiline-ternary
deprecated
❌
🔧 Fix
new-parens
deprecated
❌
🔧 Fix
newline-after-var
deprecated
Replaced by ❌
🔧 Fix
newline-before-return
deprecated
Replaced by ❌
🔧 Fix
newline-per-chained-call
deprecated
❌
🔧 Fix
no-buffer-constructor
deprecated
❌
no-catch-shadow
deprecated
Replaced by ❌
no-confusing-arrow
deprecated
❌
🔧 Fix
no-extra-parens
deprecated
❌
🔧 Fix
no-extra-semi
deprecated
❌
🔧 Fix
no-floating-decimal
deprecated
❌
🔧 Fix
no-mixed-operators
deprecated
❌
no-mixed-requires
deprecated
❌
no-mixed-spaces-and-tabs
deprecated
❌
no-multi-spaces
deprecated
❌
🔧 Fix
no-multiple-empty-lines
deprecated
❌
🔧 Fix
no-native-reassign
deprecated
Replaced by ❌
no-negated-in-lhs
deprecated
Replaced by ❌
no-new-object
deprecated
Replaced by ❌
no-new-require
deprecated
❌
no-new-symbol
deprecated
Replaced by ❌
no-path-concat
deprecated
❌
no-process-env
deprecated
❌
no-process-exit
deprecated
❌
no-restricted-modules
deprecated
❌
no-return-await
deprecated
❌
💡 Suggestions
no-spaced-func
deprecated
Replaced by ❌
🔧 Fix
no-sync
deprecated
❌
no-tabs
deprecated
❌
no-trailing-spaces
deprecated
❌
🔧 Fix
no-whitespace-before-property
deprecated
❌
🔧 Fix
nonblock-statement-body-position
deprecated
❌
🔧 Fix
object-curly-newline
deprecated
❌
🔧 Fix
object-curly-spacing
deprecated
❌
🔧 Fix
object-property-newline
deprecated
❌
🔧 Fix
one-var-declaration-per-line
deprecated
❌
🔧 Fix
operator-linebreak
deprecated
❌
🔧 Fix
padded-blocks
deprecated
❌
🔧 Fix
padding-line-between-statements
deprecated
❌
🔧 Fix
prefer-reflect
deprecated
❌
quote-props
deprecated
❌
🔧 Fix
quotes
deprecated
❌
🔧 Fix
rest-spread-spacing
deprecated
❌
🔧 Fix
semi
deprecated
❌
🔧 Fix
semi-spacing
deprecated
❌
🔧 Fix
semi-style
deprecated
❌
🔧 Fix
space-before-blocks
deprecated
❌
🔧 Fix
space-before-function-paren
deprecated
❌
🔧 Fix
space-in-parens
deprecated
❌
🔧 Fix
space-infix-ops
deprecated
❌
🔧 Fix
space-unary-ops
deprecated
❌
🔧 Fix
spaced-comment
deprecated
❌
🔧 Fix
switch-colon-spacing
deprecated
❌
🔧 Fix
template-curly-spacing
deprecated
❌
🔧 Fix
template-tag-spacing
deprecated
❌
🔧 Fix
wrap-iife
deprecated
❌
🔧 Fix
wrap-regex
deprecated
❌
🔧 Fix
yield-star-spacing
deprecated
❌
🔧 Fix
id-denylist
indent
padding-line-between-statements
padding-line-between-statements
padding-line-between-statements
no-shadow
no-global-assign
no-unsafe-negation
no-object-constructor
no-new-native-nonconstructor
func-call-spacing
These rules from older versions of ESLint (before the deprecation policy existed) have been replaced by newer rules:
generator-star
removed
Replaced by
global-strict
removed
Replaced by
no-arrow-condition
removed
Replaced by
no-comma-dangle
removed
Replaced by
no-empty-class
removed
Replaced by
no-empty-label
removed
Replaced by
no-extra-strict
removed
Replaced by
no-reserved-keys
removed
Replaced by
no-space-before-semi
removed
Replaced by
no-wrap-func
removed
Replaced by
space-after-function-name
removed
Replaced by
space-after-keywords
removed
Replaced by
space-before-function-parentheses
removed
Replaced by
space-before-keywords
removed
Replaced by
space-in-brackets
removed
Replaced by
space-return-throw-case
removed
Replaced by
space-unary-word-ops
removed
Replaced by
spaced-line-comment
removed
Replaced by
valid-jsdoc
removed
Replaced by
require-jsdoc
removed
Replaced by generator-star-spacing
strict
no-confusing-arrow
no-constant-condition
comma-dangle
no-empty-character-class
no-labels
strict
quote-props
semi-spacing
no-extra-parens
space-before-function-paren
keyword-spacing
space-before-function-paren
keyword-spacing
object-curly-spacing
array-bracket-spacing
keyword-spacing
space-unary-ops
spaced-comment