Enforce return statements in callbacks of array methods
đĄ Suggestions
Results will be shown and updated as you type.
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
đĄ 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
â
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
â
Extends
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-0const, using, and await using variablesdebuggerfunction 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 constructorslet or var variables that are read but never assigned/*global */ commentsreturn, throw, continue, and break statementsfinally blocksundefined value is not allowedawait or yieldisNaN() when checking for NaNtypeof 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
đĄ Suggestions
âī¸ 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
đ§ Fix
đĄ 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
đĄ Suggestions
Disallow empty static blocks
â
Extends
đĄ Suggestions
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
Disallow losing originally caught error when re-throwing custom errors
â
Extends
đĄ Suggestions
Enforce the 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
đ§ 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
thisreturn 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 promptArray constructorsarguments.caller or arguments.calleeconsolecontinue 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__ propertyimportreturn statementsjavascript: URLsundefinedundefined as an identifier.call() and .apply()catch clauseslet or const instead of varvoid 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 expressionsyieldimport declarations within modulesvar 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
Replaced by
â
đ§ Fix
array-bracket-spacing
deprecated
Replaced by
â
đ§ Fix
array-element-newline
deprecated
Replaced by
â
đ§ Fix
arrow-parens
deprecated
Replaced by
â
đ§ Fix
arrow-spacing
deprecated
Replaced by
â
đ§ Fix
block-spacing
deprecated
Replaced by
â
đ§ Fix
brace-style
deprecated
Replaced by
â
đ§ Fix
callback-return
deprecated
Replaced by
â
comma-dangle
deprecated
Replaced by
â
đ§ Fix
comma-spacing
deprecated
Replaced by
â
đ§ Fix
comma-style
deprecated
Replaced by
â
đ§ Fix
computed-property-spacing
deprecated
Replaced by
â
đ§ Fix
dot-location
deprecated
Replaced by
â
đ§ Fix
eol-last
deprecated
Replaced by
â
đ§ Fix
func-call-spacing
deprecated
Replaced by
â
đ§ Fix
function-call-argument-newline
deprecated
Replaced by
â
đ§ Fix
function-paren-newline
deprecated
Replaced by
â
đ§ Fix
generator-star-spacing
deprecated
Replaced by
â
đ§ Fix
global-require
deprecated
Replaced by
â
handle-callback-err
deprecated
Replaced by
â
id-blacklist
deprecated
Replaced by
â
implicit-arrow-linebreak
deprecated
Replaced by
â
đ§ Fix
indent
deprecated
Replaced by
â
đ§ Fix
indent-legacy
deprecated
Replaced by
â
đ§ Fix
jsx-quotes
deprecated
Replaced by
â
đ§ Fix
key-spacing
deprecated
Replaced by
â
đ§ Fix
keyword-spacing
deprecated
Replaced by
â
đ§ Fix
line-comment-position
deprecated
Replaced by
â
linebreak-style
deprecated
Replaced by
â
đ§ Fix
lines-around-comment
deprecated
Replaced by
â
đ§ Fix
lines-around-directive
deprecated
Replaced by
â
đ§ Fix
lines-between-class-members
deprecated
Replaced by
â
đ§ Fix
max-len
deprecated
Replaced by
â
max-statements-per-line
deprecated
Replaced by
â
multiline-comment-style
deprecated
Replaced by
â
đ§ Fix
multiline-ternary
deprecated
Replaced by
â
đ§ Fix
new-parens
deprecated
Replaced by
â
đ§ Fix
newline-after-var
deprecated
Replaced by
â
đ§ Fix
newline-before-return
deprecated
Replaced by
â
đ§ Fix
newline-per-chained-call
deprecated
Replaced by
â
đ§ Fix
no-buffer-constructor
deprecated
Replaced by
â
no-catch-shadow
deprecated
Replaced by
â
no-confusing-arrow
deprecated
Replaced by
â
đ§ Fix
no-extra-parens
deprecated
Replaced by
â
đ§ Fix
no-extra-semi
deprecated
Replaced by
â
đ§ Fix
no-floating-decimal
deprecated
Replaced by
â
đ§ Fix
no-mixed-operators
deprecated
Replaced by
â
no-mixed-requires
deprecated
Replaced by
â
no-mixed-spaces-and-tabs
deprecated
Replaced by
â
no-multi-spaces
deprecated
Replaced by
â
đ§ Fix
no-multiple-empty-lines
deprecated
Replaced by
â
đ§ Fix
no-native-reassign
deprecated
Replaced by
â
no-negated-in-lhs
deprecated
Replaced by
â
no-new-object
deprecated
Replaced by
â
no-new-require
deprecated
Replaced by
â
no-new-symbol
deprecated
Replaced by
â
no-path-concat
deprecated
Replaced by
â
no-process-env
deprecated
Replaced by
â
no-process-exit
deprecated
Replaced by
â
no-restricted-modules
deprecated
Replaced by
â
no-return-await
deprecated
â
đĄ Suggestions
no-spaced-func
deprecated
Replaced by
â
đ§ Fix
no-sync
deprecated
Replaced by
â
no-tabs
deprecated
Replaced by
â
no-trailing-spaces
deprecated
Replaced by
â
đ§ Fix
no-whitespace-before-property
deprecated
Replaced by
â
đ§ Fix
nonblock-statement-body-position
deprecated
Replaced by
â
đ§ Fix
object-curly-newline
deprecated
Replaced by
â
đ§ Fix
object-curly-spacing
deprecated
Replaced by
â
đ§ Fix
object-property-newline
deprecated
Replaced by
â
đ§ Fix
one-var-declaration-per-line
deprecated
Replaced by
â
đ§ Fix
operator-linebreak
deprecated
Replaced by
â
đ§ Fix
padded-blocks
deprecated
Replaced by
â
đ§ Fix
padding-line-between-statements
deprecated
Replaced by
â
đ§ Fix
prefer-reflect
deprecated
â
quote-props
deprecated
Replaced by
â
đ§ Fix
quotes
deprecated
Replaced by
â
đ§ Fix
rest-spread-spacing
deprecated
Replaced by
â
đ§ Fix
semi
deprecated
Replaced by
â
đ§ Fix
semi-spacing
deprecated
Replaced by
â
đ§ Fix
semi-style
deprecated
Replaced by
â
đ§ Fix
space-before-blocks
deprecated
Replaced by
â
đ§ Fix
space-before-function-paren
deprecated
Replaced by
â
đ§ Fix
space-in-parens
deprecated
Replaced by
â
đ§ Fix
space-infix-ops
deprecated
Replaced by
â
đ§ Fix
space-unary-ops
deprecated
Replaced by
â
đ§ Fix
spaced-comment
deprecated
Replaced by
â
đ§ Fix
switch-colon-spacing
deprecated
Replaced by
â
đ§ Fix
template-curly-spacing
deprecated
Replaced by
â
đ§ Fix
template-tag-spacing
deprecated
Replaced by
â
đ§ Fix
wrap-iife
deprecated
Replaced by
â
đ§ Fix
wrap-regex
deprecated
Replaced by
â
đ§ Fix
yield-star-spacing
deprecated
Replaced by
â
đ§ Fix
array-bracket-newline
in @stylistic/eslint-plugin array-bracket-spacing
in @stylistic/eslint-plugin array-element-newline
in @stylistic/eslint-plugin arrow-parens
in @stylistic/eslint-plugin arrow-spacing
in @stylistic/eslint-plugin block-spacing
in @stylistic/eslint-plugin brace-style
in @stylistic/eslint-plugin callback-return
in eslint-plugin-n comma-dangle
in @stylistic/eslint-plugin comma-spacing
in @stylistic/eslint-plugin comma-style
in @stylistic/eslint-plugin computed-property-spacing
in @stylistic/eslint-plugin dot-location
in @stylistic/eslint-plugin eol-last
in @stylistic/eslint-plugin function-call-spacing
in @stylistic/eslint-plugin function-call-argument-newline
in @stylistic/eslint-plugin function-paren-newline
in @stylistic/eslint-plugin generator-star-spacing
in @stylistic/eslint-plugin global-require
in eslint-plugin-n handle-callback-err
in eslint-plugin-n id-denylist
implicit-arrow-linebreak
in @stylistic/eslint-plugin indent
in @stylistic/eslint-plugin indent
in @stylistic/eslint-plugin jsx-quotes
in @stylistic/eslint-plugin key-spacing
in @stylistic/eslint-plugin keyword-spacing
in @stylistic/eslint-plugin line-comment-position
in @stylistic/eslint-plugin linebreak-style
in @stylistic/eslint-plugin lines-around-comment
in @stylistic/eslint-plugin padding-line-between-statements
in @stylistic/eslint-plugin lines-between-class-members
in @stylistic/eslint-plugin max-len
in @stylistic/eslint-plugin max-statements-per-line
in @stylistic/eslint-plugin multiline-comment-style
in @stylistic/eslint-plugin multiline-ternary
in @stylistic/eslint-plugin new-parens
in @stylistic/eslint-plugin padding-line-between-statements
in @stylistic/eslint-plugin padding-line-between-statements
in @stylistic/eslint-plugin newline-per-chained-call
in @stylistic/eslint-plugin no-deprecated-api
in eslint-plugin-n no-shadow
no-confusing-arrow
in @stylistic/eslint-plugin no-extra-parens
in @stylistic/eslint-plugin no-extra-semi
in @stylistic/eslint-plugin no-floating-decimal
in @stylistic/eslint-plugin no-mixed-operators
in @stylistic/eslint-plugin no-mixed-requires
in eslint-plugin-n no-mixed-spaces-and-tabs
in @stylistic/eslint-plugin no-multi-spaces
in @stylistic/eslint-plugin no-multiple-empty-lines
in @stylistic/eslint-plugin no-global-assign
no-unsafe-negation
no-object-constructor
no-new-require
in eslint-plugin-n no-new-native-nonconstructor
no-path-concat
in eslint-plugin-n no-process-env
in eslint-plugin-n no-process-exit
in eslint-plugin-n no-restricted-require
in eslint-plugin-n function-call-spacing
in @stylistic/eslint-plugin no-sync
in eslint-plugin-n no-tabs
in @stylistic/eslint-plugin no-trailing-spaces
in @stylistic/eslint-plugin no-whitespace-before-property
in @stylistic/eslint-plugin nonblock-statement-body-position
in @stylistic/eslint-plugin object-curly-newline
in @stylistic/eslint-plugin object-curly-spacing
in @stylistic/eslint-plugin object-property-newline
in @stylistic/eslint-plugin one-var-declaration-per-line
in @stylistic/eslint-plugin operator-linebreak
in @stylistic/eslint-plugin padded-blocks
in @stylistic/eslint-plugin padding-line-between-statements
in @stylistic/eslint-plugin quote-props
in @stylistic/eslint-plugin quotes
in @stylistic/eslint-plugin rest-spread-spacing
in @stylistic/eslint-plugin semi
in @stylistic/eslint-plugin semi-spacing
in @stylistic/eslint-plugin semi-style
in @stylistic/eslint-plugin space-before-blocks
in @stylistic/eslint-plugin space-before-function-paren
in @stylistic/eslint-plugin space-in-parens
in @stylistic/eslint-plugin space-infix-ops
in @stylistic/eslint-plugin space-unary-ops
in @stylistic/eslint-plugin spaced-comment
in @stylistic/eslint-plugin switch-colon-spacing
in @stylistic/eslint-plugin template-curly-spacing
in @stylistic/eslint-plugin template-tag-spacing
in @stylistic/eslint-plugin wrap-iife
in @stylistic/eslint-plugin wrap-regex
in @stylistic/eslint-plugin yield-star-spacing
in @stylistic/eslint-plugin
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
require-jsdoc
removed
generator-star-spacing
strict
no-confusing-arrow
or
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
or
array-bracket-spacing
or
computed-property-spacing
keyword-spacing
space-unary-ops
spaced-comment