Rules in ESLint are grouped by category to help you understand their purpose.
No rules are enabled by default. The "extends": "eslint:recommended"
property in a configuration file enables rules that report common problems, which have a check mark below.
The --fix
option on the command line automatically fixes problems (currently mostly whitespace) reported by rules which have a wrench below.
These rules relate to possible syntax or logic errors in JavaScript code:
enforce “for” loop update clause moving the counter in the right direction. | |
enforce | |
disallow using an async function as a Promise executor | |
disallow | |
disallow comparing against -0 | |
disallow assignment operators in conditional expressions | |
disallow the use of | |
disallow constant expressions in conditions | |
disallow control characters in regular expressions | |
disallow the use of | |
disallow duplicate arguments in | |
disallow duplicate keys in object literals | |
disallow duplicate case labels | |
disallow empty block statements | |
disallow empty character classes in regular expressions | |
disallow reassigning exceptions in | |
disallow unnecessary boolean casts | |
disallow unnecessary parentheses | |
disallow unnecessary semicolons | |
disallow reassigning | |
disallow variable or | |
disallow invalid regular expression strings in | |
disallow irregular whitespace outside of strings and comments | |
disallow characters which are made with multiple code points in character class syntax | |
disallow calling global object properties as functions | |
disallow calling some | |
disallow multiple spaces in regular expressions | |
disallow sparse arrays | |
disallow template literal placeholder syntax in regular strings | |
disallow confusing multiline expressions | |
disallow unreachable code after | |
disallow control flow statements in | |
disallow negating the left operand of relational operators | |
disallow assignments that can lead to race conditions due to usage of | |
require calls to | |
enforce valid JSDoc comments | |
enforce comparing |
These rules relate to better ways of doing things to help you avoid problems:
enforce getter and setter pairs in objects | |
enforce | |
enforce the use of variables within the scope they are defined | |
enforce that class methods utilize | |
enforce a maximum cyclomatic complexity allowed in a program | |
require | |
enforce consistent brace style for all control statements | |
require | |
enforce consistent newlines before and after dots | |
enforce dot notation whenever possible | |
require the use of | |
require | |
enforce a maximum number of classes per file | |
disallow the use of | |
disallow the use of | |
disallow lexical declarations in case clauses | |
disallow division operators explicitly at the beginning of regular expressions | |
disallow | |
disallow empty functions | |
disallow empty destructuring patterns | |
disallow | |
disallow the use of | |
disallow extending native types | |
disallow unnecessary calls to | |
disallow unnecessary labels | |
disallow fallthrough of | |
disallow leading or trailing decimal points in numeric literals | |
disallow assignments to native objects or read-only global variables | |
disallow shorthand type conversions | |
disallow variable and | |
disallow the use of | |
disallow | |
disallow the use of the | |
disallow labeled statements | |
disallow unnecessary nested blocks | |
disallow | |
disallow magic numbers | |
disallow multiple spaces | |
disallow multiline strings | |
disallow | |
disallow | |
disallow | |
disallow octal literals | |
disallow octal escape sequences in string literals | |
disallow reassigning | |
disallow the use of the | |
disallow variable redeclaration | |
disallow certain properties on certain objects | |
disallow assignment operators in | |
disallow unnecessary | |
disallow | |
disallow assignments where both sides are exactly the same | |
disallow comparisons where both sides are exactly the same | |
disallow comma operators | |
disallow throwing literals as exceptions | |
disallow unmodified loop conditions | |
disallow unused expressions | |
disallow unused labels | |
disallow unnecessary calls to | |
disallow unnecessary concatenation of literals or template literals | |
disallow unnecessary escape characters | |
disallow redundant return statements | |
disallow | |
disallow specified warning terms in comments | |
disallow | |
require using Error objects as Promise rejection reasons | |
enforce the consistent use of the radix argument when using | |
disallow async functions which have no | |
enforce the use of | |
require | |
require parentheses around immediate | |
require or disallow “Yoda” conditions |
These rules relate to strict mode directives:
require or disallow strict mode directives |
These rules relate to variable declarations:
require or disallow initialization in variable declarations | |
disallow deleting variables | |
disallow labels that share a name with a variable | |
disallow specified global variables | |
disallow variable declarations from shadowing variables declared in the outer scope | |
disallow identifiers from shadowing restricted names | |
disallow the use of undeclared variables unless mentioned in | |
disallow initializing variables to | |
disallow the use of | |
disallow unused variables | |
disallow the use of variables before they are defined |
These rules relate to code running in Node.js, or in browsers with CommonJS:
require | |
require | |
require error handling in callbacks | |
disallow use of the | |
disallow | |
disallow | |
disallow string concatenation with | |
disallow the use of | |
disallow the use of | |
disallow specified modules when loaded by | |
disallow synchronous methods |
These rules relate to style guidelines, and are therefore quite subjective:
enforce linebreaks after opening and before closing array brackets | |
enforce consistent spacing inside array brackets | |
enforce line breaks after each array element | |
disallow or enforce spaces inside of blocks after opening block and before closing block | |
enforce consistent brace style for blocks | |
enforce camelcase naming convention | |
enforce or disallow capitalization of the first letter of a comment | |
require or disallow trailing commas | |
enforce consistent spacing before and after commas | |
enforce consistent comma style | |
enforce consistent spacing inside computed property brackets | |
enforce consistent naming when capturing the current execution context | |
require or disallow newline at the end of files | |
require or disallow spacing between function identifiers and their invocations | |
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 | |
enforce consistent line breaks inside function parentheses | |
disallow specified identifiers | |
enforce minimum and maximum identifier lengths | |
require identifiers to match a specified regular expression | |
enforce the location of arrow function bodies | |
enforce consistent indentation | |
enforce the consistent use of either double or single quotes in JSX attributes | |
enforce consistent spacing between keys and values in object literal properties | |
enforce consistent spacing before and after keywords | |
enforce position of line comments | |
enforce consistent linebreak style | |
require empty lines around comments | |
require or disallow an empty line between class members | |
enforce a maximum depth that blocks can be nested | |
enforce a maximum line length | |
enforce a maximum number of lines per file | |
enforce a maximum number of line 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 maximum number of statements allowed per line | |
enforce a particular style for multiline comments | |
enforce newlines between operands of ternary expressions | |
require constructor names to begin with a capital letter | |
require parentheses when invoking a constructor with no arguments | |
require a newline after each call in a method chain | |
disallow | |
disallow bitwise operators | |
disallow | |
disallow inline comments after code | |
disallow | |
disallow mixed binary operators | |
disallow mixed spaces and tabs for indentation | |
disallow use of chained assignment expressions | |
disallow multiple empty lines | |
disallow negated conditions | |
disallow nested ternary expressions | |
disallow | |
disallow the unary operators | |
disallow specified syntax | |
disallow all tabs | |
disallow ternary operators | |
disallow trailing whitespace at the end of lines | |
disallow dangling underscores in identifiers | |
disallow ternary operators when simpler alternatives exist | |
disallow whitespace before properties | |
enforce the location of single-line statements | |
enforce consistent line breaks inside braces | |
enforce consistent spacing inside braces | |
enforce placing object properties on separate lines | |
enforce variables to be declared either together or separately in functions | |
require or disallow newlines around variable declarations | |
require or disallow assignment operator shorthand where possible | |
enforce consistent linebreak style for operators | |
require or disallow padding within blocks | |
require or disallow padding lines between statements | |
disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead. | |
require quotes around object literal property names | |
enforce the consistent use of either backticks, double, or single quotes | |
require JSDoc comments | |
require or disallow semicolons instead of ASI | |
enforce consistent spacing before and after semicolons | |
enforce location of semicolons | |
require object keys to be sorted | |
require variables within the same declaration block to be sorted | |
enforce consistent spacing before blocks | |
enforce consistent spacing before | |
enforce consistent spacing inside parentheses | |
require spacing around infix operators | |
enforce consistent spacing before or after unary operators | |
enforce consistent spacing after the | |
enforce spacing around colons of switch statements | |
require or disallow spacing between template tags and their literals | |
require or disallow Unicode byte order mark (BOM) | |
require parenthesis around regex literals |
These rules relate to ES6, also known as ES2015:
require braces around arrow function bodies | |
require parentheses around arrow function arguments | |
enforce consistent spacing before and after the arrow in arrow functions | |
require | |
enforce consistent spacing around | |
disallow reassigning class members | |
disallow arrow functions where they could be confused with comparisons | |
disallow reassigning | |
disallow duplicate class members | |
disallow duplicate module imports | |
disallow | |
disallow specified modules when loaded by | |
disallow | |
disallow unnecessary computed property keys in object literals | |
disallow unnecessary constructors | |
disallow renaming import, export, and destructured assignments to the same name | |
require | |
require or disallow method and property shorthand syntax for object literals | |
require using arrow functions for callbacks | |
require | |
require destructuring from arrays and/or objects | |
disallow | |
require rest parameters instead of | |
require spread operators instead of | |
require template literals instead of string concatenation | |
require generator functions to contain | |
enforce spacing between rest and spread operators and their expressions | |
enforce sorted import declarations within modules | |
require symbol descriptions | |
require or disallow spacing around embedded expressions of template strings | |
require or disallow spacing around the |
These rules have been deprecated in accordance with the deprecation policy, and replaced by newer rules:
Deprecated rule | Replaced by |
---|---|
(no replacement) |
These rules from older versions of ESLint (before the deprecation policy existed) have been replaced by newer rules:
Removed rule | Replaced by |
---|---|
© JS Foundation and other contributors
Licensed under the MIT License.
https://eslint.org/docs/rules/