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:
The "extends": "eslint:recommended"
property 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
These rules relate to possible logic errors in code: Enforce
๐ก Suggestions
Require
โ
Extends
Enforce โforโ loop update clause moving the counter in the right direction
โ
Extends
Enforce
โ
Extends
Disallow using an async function as a Promise executor
โ
Extends
Disallow Disallow reassigning class members
โ
Extends
Disallow comparing against -0
โ
Extends
Disallow assignment operators in conditional expressions
โ
Extends
Disallow reassigning
โ
Extends
Disallow expressions where the operation doesnโt affect the value 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
โ
Extends
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 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 Disallow unused variables
โ
Extends
Disallow the use of variables before they are defined Disallow useless backreferences in regular expressions
โ
Extends
Disallow assignments that can lead to race conditions due to usage of Require calls to
โ
Extends
Enforce comparing
โ
Extends
๐ก Suggestions
return
statements in callbacks of array methodssuper()
calls in constructorsreturn
statements in gettersawait
inside of loopsconst
variablesdebugger
function
definitionscatch
clausescase
statementsfunction
declarationsfunction
declarations in nested blocksRegExp
constructorsnew
operators with global non-constructor functionsnew
operators with the Symbol
objectObject.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 Require braces around arrow function bodies
๐ง Fix
Enforce the use of variables within the scope they are defined Enforce camelcase naming convention 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 Enforce consistent naming when capturing the current execution context Enforce consistent brace style for all control statements
๐ง Fix
Require Enforce default clauses in switch statements to be last Enforce default parameters to be last Enforce dot notation whenever possible
๐ง Fix
Require the use of
๐ง Fix
Require function names to match the name of the variable or property to which they are assigned Require or disallow named Enforce the consistent use of either Require grouped accessor pairs in object literals and classes Require Disallow specified identifiers Enforce minimum and maximum identifier lengths Require identifiers to match a specified regular expression Require or disallow initialization in variable declarations 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 Enforce a particular style for multiline comments
๐ง Fix
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
Disallow the use of
๐ก Suggestions
Disallow Disallow deleting variables
โ
Extends
Disallow equal signs explicitly at the beginning of regular expressions
๐ง Fix
Disallow
๐ง Fix
Disallow empty block statements
โ
Extends
๐ก Suggestions
Disallow empty functions Disallow empty static blocks Disallow Disallow the use of Disallow extending native types Disallow unnecessary calls to
๐ง Fix
Disallow unnecessary boolean casts
โ
Extends
๐ง Fix
Disallow unnecessary labels
๐ง Fix
Disallow assignments to native objects or read-only global variables
โ
Extends
Disallow shorthand type conversions
๐ง Fix
Disallow declarations in the global scope Disallow the use of Disallow inline comments after code Disallow use of Disallow the use of the Disallow labels that share a name with a variable Disallow labeled statements Disallow unnecessary nested blocks Disallow
๐ง Fix
Disallow function declarations that contain unsafe references inside loop statements Disallow magic numbers Disallow use of chained assignment expressions Disallow multiline strings Disallow negated conditions 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 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
Disallow ternary operators Disallow throwing literals as exceptions Disallow initializing variables to
๐ง Fix
Disallow the use of Disallow dangling underscores in identifiers Disallow ternary operators when simpler alternatives exist
๐ง Fix
Disallow unused expressions Disallow unused labels
โ
Extends
๐ง Fix
Disallow unnecessary calls to Disallow unnecessary
โ
Extends
Disallow unnecessary computed property keys in objects and classes
๐ง Fix
Disallow unnecessary concatenation of literals or template literals Disallow unnecessary constructors 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
Disallow Disallow specified warning terms in comments Disallow
โ
Extends
Require or disallow method and property shorthand syntax for object literals
๐ง Fix
Enforce variables to be declared either together or separately in functions
๐ง Fix
Require or disallow assignment operator shorthand where possible
๐ง Fix
Require using arrow functions for callbacks
๐ง Fix
Require
๐ง Fix
Require destructuring from arrays and/or objects
๐ง Fix
Disallow the use of
๐ง Fix
Enforce using named capture group in regular expression
๐ก Suggestions
Disallow
๐ง Fix
Disallow use of
๐ง Fix
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
๐ก Suggestions
Require rest parameters instead of Require spread operators instead of 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 Enforce the use of
๐ก Suggestions
Require generator functions to contain
โ
Extends
Enforce sorted import declarations within modules
๐ง Fix
Require object keys to be sorted Require variables within the same declaration block to be sorted
๐ง Fix
Require or disallow strict mode directives
๐ง Fix
Require symbol descriptions Require Require or disallow โYodaโ conditions
๐ง Fix
this
return
statements to either always or never specify valuesdefault
cases in switch
statements===
and !==
function
expressionsfunction
declarations or expressionsfor-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 argumentfunction
parameters++
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()
RegExp
constructor in favor of regular expression literalsarguments
.apply()
parseInt()
await
expressionu
or v
flag on RegExpyield
var
declarations be placed at the top of their containing scope
These rules care about how the code looks rather than how it executes: Enforce position of line comments 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
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-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-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
require-jsdoc
deprecated
โ
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
valid-jsdoc
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
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 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