Lint rules
Every rule built into bun lint
bun lint has 1,021 rules built in. Turn one on in bunfig.toml, or read about it in the terminal with bun lint --explain <rule>.
ESLint#
218 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
accessor-pairs | Require a getter for every setter in objects and classes | |||
array-callback-return | Require callbacks of array methods such as map and filter to return a value | suggestion | ||
arrow-body-style | Enforce one style for the braces around arrow function bodies | yes | ||
block-scoped-var | Disallow using a var outside the block it is declared in | |||
callback-return | Require return when calling a callback | |||
camelcase | Require camelCase names for variables, functions and properties | |||
capitalized-comments | Require comments to start with a capital letter, or forbid it | yes | ||
class-methods-use-this | Require class methods to use this | |||
complexity | Enforce a maximum number of branches in a function | |||
consistent-return | Require every return in a function to have a value, or none of them | |||
consistent-this | Enforce one name for variables that hold this | |||
constructor-super | Require super() to be called exactly once in the constructor of a derived class | error | ||
curly | Require braces around the bodies of if, else and loops | yes | ||
default-case | Require a default case in every switch | |||
default-case-last | Require default to be the last clause of a switch | |||
default-param-last | Require parameters with a default value to come after the required ones | |||
dot-notation | Require user.name instead of user["name"] | yes | ||
eqeqeq | Require === and !== instead of == and != | yes | ||
for-direction | Require the update clause of a for loop to move the counter toward the end of the loop | error | ||
func-name-matching | Require a function expression's name to match the variable or property it is assigned to | |||
func-names | Require or disallow names for function expressions | |||
func-style | Enforce one way to define functions: declarations, or expressions assigned to variables | |||
getter-return | Require getters to return a value | error | ||
global-require | Require require() calls to be at the top level of the module | |||
grouped-accessor-pairs | Require the getter and setter of a property to be next to each other | |||
guard-for-in | Require the body of a for...in loop to be guarded by an if | |||
handle-callback-err | Require callbacks to use their error parameter | |||
id-blacklist | Disallow the identifier names you list (old name of id-denylist) | |||
id-denylist | Disallow the identifier names you list | |||
id-length | Enforce a minimum and a maximum length for identifier names | |||
id-match | Require identifier names to match a regular expression | |||
init-declarations | Require or disallow a value in variable declarations | |||
logical-assignment-operators | Require or disallow the logical assignment operators ||=, &&= and ??= | yes | ||
max-classes-per-file | Enforce a maximum number of classes per file | |||
max-depth | Enforce a maximum depth that blocks can be nested | |||
max-lines | Enforce a maximum number of lines per file | |||
max-lines-per-function | Enforce a maximum number of lines in a function | |||
max-nested-callbacks | Enforce a maximum depth that callbacks can be nested | |||
max-params | Enforce a maximum number of parameters in function definitions | |||
max-statements | Enforce a maximum number of statements in a function | |||
new-cap | Require constructor names to begin with a capital letter | |||
no-alert | Disallow alert, confirm, and prompt | |||
no-array-constructor | Disallow Array constructors in favor of array literals | yes | ||
no-async-promise-executor | Disallow an async function as a Promise executor | error | ||
no-await-in-loop | Disallow await inside of loops | |||
no-bitwise | Disallow bitwise operators | |||
no-buffer-constructor | Disallow the deprecated Buffer() constructor | |||
no-caller | Disallow arguments.caller and arguments.callee | |||
no-case-declarations | Disallow let, const, function and class declarations directly in a case clause | warn | suggestion | |
no-catch-shadow | Disallow a catch parameter with the name of a variable in the scope around it | |||
no-class-assign | Disallow assigning to the name of a class | error | ||
no-compare-neg-zero | Disallow comparing against -0 | error | suggestion | |
no-cond-assign | Disallow assignments in the test of if, loops and ? : | warn | ||
no-console | Disallow the use of console | suggestion | ||
no-const-assign | Disallow reassigning const, using and await using variables | error | ||
no-constant-binary-expression | Disallow comparisons and &&, ||, ?? that always give the same result | error | ||
no-constant-condition | Disallow conditions that are always truthy or always falsy | warn | ||
no-constructor-return | Disallow returning a value from a constructor | |||
no-continue | Disallow continue statements | |||
no-control-regex | Disallow control characters in regular expressions | warn | ||
no-debugger | Disallow debugger statements | error | ||
no-delete-var | Disallow delete on variables | warn | ||
no-div-regex | Disallow regular expressions that start with = | yes | ||
no-dupe-args | Disallow two parameters with the same name in a function | error | ||
no-dupe-class-members | Disallow two class members with the same name | error | ||
no-dupe-else-if | Disallow an else if with a condition that an earlier branch already covers | error | ||
no-dupe-keys | Disallow two keys with the same name in an object literal | error | ||
no-duplicate-case | Disallow two case labels with the same test in a switch | error | ||
no-duplicate-imports | Disallow importing from the same module more than once in a file | |||
no-else-return | Disallow else after an if branch that always returns | yes | ||
no-empty | Disallow empty block statements | warn | suggestion | |
no-empty-character-class | Disallow empty character classes [] in regular expressions | warn | ||
no-empty-function | Disallow functions with an empty body | suggestion | ||
no-empty-pattern | Disallow destructuring patterns that bind nothing | warn | ||
no-empty-static-block | Disallow empty static {} blocks in classes | warn | suggestion | |
no-eq-null | Disallow comparing with null using == or != | |||
no-eval | Disallow eval() | |||
no-ex-assign | Disallow assigning to the error parameter of a catch clause | warn | ||
no-extend-native | Disallow adding properties to the prototypes of built-in objects | |||
no-extra-bind | Disallow .bind() on functions that do not use this | yes | ||
no-extra-boolean-cast | Disallow !! and Boolean() where the value is converted to a boolean anyway | warn | yes | |
no-extra-label | Disallow labels on break and continue that name the innermost loop or switch | yes | ||
no-fallthrough | Disallow case clauses that run on into the next one | error | ||
no-func-assign | Disallow assigning to the name of a function declaration | error | ||
no-global-assign | Disallow assigning to built-in and other read-only global variables | warn | ||
no-implicit-coercion | Require Boolean(), Number() and String() instead of operator tricks like !!x and +x | yes | ||
no-implicit-globals | Disallow declarations and assignments that create global variables by accident | |||
no-implied-eval | Disallow passing a string of code to setTimeout(), setInterval() or execScript() | |||
no-import-assign | Disallow assigning to imported bindings | error | ||
no-inline-comments | Disallow comments on the same line as code | |||
no-inner-declarations | Disallow function and, optionally, var declarations in nested blocks | |||
no-invalid-regexp | Disallow invalid patterns and flags in RegExp() and new RegExp() | error | ||
no-invalid-this | Disallow this where its value is undefined | |||
no-irregular-whitespace | Disallow whitespace characters other than the ordinary space, tab and line break | error | ||
no-iterator | Disallow the __iterator__ property | |||
no-label-var | Disallow labels that share a name with a variable | |||
no-labels | Disallow labeled statements | |||
no-lone-blocks | Disallow blocks that do nothing | |||
no-lonely-if | Require else if instead of an if alone in an else block | yes | ||
no-loop-func | Disallow functions in loops that use a variable the loop changes | |||
no-loss-of-precision | Disallow number literals that cannot be stored exactly as written | error | ||
no-magic-numbers | Require numbers to be given a name instead of being used directly | |||
no-misleading-character-class | Disallow characters made of several code points inside a regular expression character class | error | suggestion | |
no-mixed-requires | Disallow require calls mixed with other variables in one declaration | |||
no-multi-assign | Disallow chained assignments such as a = b = c | |||
no-multi-str | Disallow strings that continue on the next line with a backslash | |||
no-native-reassign | Disallow assignments to built-in and other read-only global variables | |||
no-negated-condition | Disallow negated conditions in if/else and in ternaries | |||
no-negated-in-lhs | Disallow negating the left operand of in | |||
no-nested-ternary | Disallow a ternary inside the branch of another ternary | |||
no-new | Disallow new when the created object is thrown away | |||
no-new-func | Disallow creating functions from strings with Function | |||
no-new-native-nonconstructor | Disallow new Symbol() and new BigInt() | error | ||
no-new-object | Disallow new Object() in favor of {} | |||
no-new-require | Disallow new require(..) | |||
no-new-symbol | Disallow new Symbol() | |||
no-new-wrappers | Disallow new String(), new Number() and new Boolean() | |||
no-nonoctal-decimal-escape | Disallow the \8 and \9 escapes in strings | warn | suggestion | |
no-obj-calls | Disallow calling Math, JSON, Reflect, Atomics, Intl and Temporal as functions | error | ||
no-object-constructor | Disallow Object() and new Object() without an argument | suggestion | ||
no-octal | Disallow number literals that start with 0 followed by a digit | warn | ||
no-octal-escape | Disallow octal escape sequences such as \251 in strings | |||
no-param-reassign | Disallow assigning to function parameters | |||
no-path-concat | Disallow building paths with + from __dirname or __filename | |||
no-plusplus | Disallow the ++ and -- operators | |||
no-process-env | Disallow process.env | |||
no-process-exit | Disallow calls to process.exit() | |||
no-promise-executor-return | Disallow returning a value from the function passed to new Promise | suggestion | ||
no-proto | Disallow the __proto__ property | |||
no-prototype-builtins | Disallow calling hasOwnProperty and other Object.prototype methods on the object itself | warn | suggestion | |
no-redeclare | Disallow declaring the same variable twice in one scope | warn | ||
no-regex-spaces | Disallow several spaces in a row in a regular expression | warn | yes | |
no-restricted-exports | Disallow the export names you list, or default exports | |||
no-restricted-globals | Disallow the global variables you list | |||
no-restricted-imports | Disallow importing the modules, or the names from them, that you list | |||
no-restricted-modules | Disallow loading the modules you list with require() | |||
no-restricted-properties | Disallow the object properties you list | |||
no-restricted-syntax | Disallow the syntax you describe with selectors | |||
no-return-assign | Disallow assignments in return statements | |||
no-return-await | Disallow return await where the await changes nothing for the caller | suggestion | ||
no-script-url | Disallow javascript: URLs | |||
no-self-assign | Disallow assigning a variable or a property to itself | warn | ||
no-self-compare | Disallow comparing a value with itself | |||
no-sequences | Disallow the comma operator | |||
no-setter-return | Disallow returning a value from a setter | warn | ||
no-shadow | Disallow a variable with the same name as one in an outer scope | |||
no-shadow-restricted-names | Disallow variables named undefined, NaN, Infinity, eval, arguments or globalThis | warn | ||
no-sparse-arrays | Disallow array literals with holes | error | ||
no-sync | Disallow methods with a name that ends in Sync | |||
no-template-curly-in-string | Disallow ${} placeholders in strings with ordinary quotes | |||
no-ternary | Disallow the ? : operator | |||
no-this-before-super | Disallow this and super.x before super() in a constructor | error | ||
no-throw-literal | Require throw to be given something that can be an Error | |||
no-unassigned-vars | Disallow let and var variables that are read but never assigned | warn | ||
no-undef | Disallow variables that are not declared anywhere | error | ||
no-undef-init | Disallow initializing a variable to undefined | yes | ||
no-undefined | Disallow the use of undefined as a variable | |||
no-underscore-dangle | Disallow names that start or end with an underscore | |||
no-unexpected-multiline | Disallow lines that look like a new statement but continue the previous one | error | ||
no-unmodified-loop-condition | Disallow loop conditions that test variables the loop never changes | |||
no-unneeded-ternary | Disallow ? : where the condition alone says the same | yes | ||
no-unreachable | Disallow code after return, throw, break, and continue that can never run | warn | ||
no-unreachable-loop | Disallow loops with a body that can only run once | |||
no-unsafe-finally | Disallow return, throw, break, and continue in finally blocks | error | ||
no-unsafe-negation | Disallow negating the left operand of in and instanceof | error | suggestion | |
no-unsafe-optional-chaining | Disallow optional chaining where undefined throws an error | error | ||
no-unused-expressions | Disallow statements that compute a value and throw it away | |||
no-unused-labels | Disallow labels that no break or continue refers to | warn | yes | |
no-unused-private-class-members | Disallow #private class members that are never used | warn | suggestion | |
no-unused-vars | Disallow variables, functions, imports, and parameters that are never used | warn | suggestion | |
no-use-before-define | Disallow using a variable, function, or class above the line that declares it | |||
no-useless-assignment | Disallow assigning a value to a variable that is never read afterwards | warn | ||
no-useless-backreference | Disallow regular expression backreferences that always match the empty string | warn | ||
no-useless-call | Disallow .call() and .apply() where a normal call does the same | |||
no-useless-catch | Disallow catch clauses that only rethrow the error | warn | ||
no-useless-computed-key | Disallow brackets around a property key that is a plain string or number | yes | ||
no-useless-concat | Disallow joining two string literals with + on the same line | |||
no-useless-constructor | Disallow constructors that do what the default constructor does | suggestion | ||
no-useless-escape | Disallow backslashes that do not change the meaning of a string or regular expression | warn | suggestion | |
no-useless-rename | Disallow renaming an import, export, or destructured value to the same name | yes | ||
no-useless-return | Disallow a return without a value where the function ends anyway | yes | ||
no-var | Require let or const instead of var | warn | yes | |
no-void | Disallow the void operator | |||
no-warning-comments | Disallow comments that start with TODO, FIXME, or another term you choose | |||
no-with | Disallow with statements | warn | ||
object-shorthand | Require or disallow the short forms { name } and { save() {} } in object literals | yes | ||
one-var | Require variables to be declared in one statement, or in one statement each | yes | ||
operator-assignment | Require or disallow shorthand assignment operators such as += | yes | ||
prefer-arrow-callback | Require arrow functions for callbacks | yes | ||
prefer-const | Require const for variables that are never reassigned | warn | yes | |
prefer-destructuring | Require destructuring to read a property or an element into a variable | yes | ||
prefer-exponentiation-operator | Require the ** operator instead of Math.pow() | yes | ||
prefer-named-capture-group | Require capture groups in regular expressions to have a name | suggestion | ||
prefer-numeric-literals | Require binary, octal and hexadecimal literals instead of parseInt() on a fixed string | yes | ||
prefer-object-has-own | Require Object.hasOwn() instead of Object.prototype.hasOwnProperty.call() | yes | ||
prefer-object-spread | Require object spread instead of Object.assign() into a new object | yes | ||
prefer-promise-reject-errors | Require an Error object as the reason of a promise rejection | |||
prefer-reflect | Require Reflect methods instead of their older Object and Function forms | |||
prefer-regex-literals | Require regular expression literals instead of RegExp() with a fixed pattern | suggestion | ||
prefer-rest-params | Require rest parameters instead of arguments | warn | ||
prefer-spread | Require spread syntax instead of .apply() to pass an array as arguments | warn | ||
prefer-template | Require template literals instead of string concatenation | yes | ||
preserve-caught-error | Require the caught error as the cause of a new error thrown in catch | warn | suggestion | |
radix | Require the radix argument of parseInt() | suggestion | ||
require-atomic-updates | Disallow assignments that use a value read before an await or a yield | |||
require-await | Disallow async functions that never use await | suggestion | ||
require-unicode-regexp | Require the u or v flag on regular expressions | suggestion | ||
require-yield | Require generator functions to contain yield | warn | ||
sort-imports | Enforce sorted import declarations and sorted names inside them | yes | ||
sort-keys | Require the keys of object literals to be sorted | |||
sort-vars | Require the variables of one declaration to be sorted | yes | ||
strict | Require or disallow "use strict" directives | yes | ||
symbol-description | Require a description when creating a Symbol | |||
unicode-bom | Require or disallow a Unicode byte order mark at the start of a file | yes | ||
use-isnan | Require Number.isNaN() instead of a comparison with NaN | error | suggestion | |
valid-typeof | Require typeof to be compared with a valid type name | error | suggestion | |
vars-on-top | Require var declarations at the top of their function or file | |||
yoda | Require or disallow comparisons with the literal on the left | yes |
typescript-eslint#
137 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
@typescript-eslint/adjacent-overload-signatures | Require the overloads of a function to be next to each other | |||
@typescript-eslint/array-type | Require either T[] or Array<T> for array types, consistently | yes | ||
@typescript-eslint/await-thenable | Disallow await on a value that is not a promise | suggestion | yes | |
@typescript-eslint/ban-ts-comment | Disallow @ts-ignore and @ts-nocheck, and require a reason after @ts-expect-error | warn | suggestion | |
@typescript-eslint/ban-tslint-comment | Disallow // tslint:disable and // tslint:enable comments | yes | ||
@typescript-eslint/ban-types | Disallow String, Number, Object, Function, {} and similar types | |||
@typescript-eslint/class-literal-property-style | Require constants on a class to be all readonly fields or all getters | suggestion | ||
@typescript-eslint/class-methods-use-this | Require class methods to use this | |||
@typescript-eslint/consistent-generic-constructors | Require type arguments on the constructor call or on the type annotation, consistently | yes | ||
@typescript-eslint/consistent-indexed-object-style | Require either Record<K, V> or an index signature, consistently | yes | ||
@typescript-eslint/consistent-return | Require every return in a function to return a value, or none of them | yes | ||
@typescript-eslint/consistent-type-assertions | Require one style of type assertion: value as T, <T>value, or none | yes | ||
@typescript-eslint/consistent-type-definitions | Require either interface or type for object types, consistently | yes | ||
@typescript-eslint/consistent-type-exports | Require export type for exports that are only types | yes | yes | |
@typescript-eslint/consistent-type-imports | Require import type for imports that are only used as types | yes | ||
@typescript-eslint/default-param-last | Require parameters with a default value, and optional parameters, to come last | |||
@typescript-eslint/dot-notation | Require user.name instead of user["name"] | yes | yes | |
@typescript-eslint/explicit-function-return-type | Require a return type on functions and class methods | |||
@typescript-eslint/explicit-member-accessibility | Require public, private or protected on class members | yes | ||
@typescript-eslint/explicit-module-boundary-types | Require parameter and return types on exported functions and the methods of exported classes | |||
@typescript-eslint/init-declarations | Require or disallow a value in variable declarations | |||
@typescript-eslint/max-params | Enforce a maximum number of parameters in function definitions | |||
@typescript-eslint/member-ordering | Require a consistent order for the members of classes, interfaces and type literals | |||
@typescript-eslint/method-signature-style | Enforce one way to write a method in an interface or type literal | yes | ||
@typescript-eslint/naming-convention | Enforce naming conventions for variables, functions, types, members and imports | |||
@typescript-eslint/no-array-constructor | Disallow Array() and new Array() in favor of array literals | warn | yes | |
@typescript-eslint/no-array-delete | Disallow delete on an element of an array | suggestion | yes | |
@typescript-eslint/no-base-to-string | Disallow turning an object into a string when the result is [object Object] | yes | ||
@typescript-eslint/no-confusing-non-null-assertion | Disallow a non-null assertion ! right before =, ==, ===, in or instanceof | suggestion | ||
@typescript-eslint/no-confusing-void-expression | Require expressions of type void to stand alone as statements | yes | yes | |
@typescript-eslint/no-deprecated | Disallow using code marked as @deprecated | yes | ||
@typescript-eslint/no-dupe-class-members | Disallow two class members with the same name | |||
@typescript-eslint/no-duplicate-enum-values | Disallow two enum members with the same value | warn | ||
@typescript-eslint/no-duplicate-type-constituents | Disallow the same type twice in a union or intersection | yes | yes | |
@typescript-eslint/no-dynamic-delete | Disallow delete with a computed property key | |||
@typescript-eslint/no-empty-function | Disallow functions with an empty body | suggestion | ||
@typescript-eslint/no-empty-interface | Disallow interfaces that declare no members | yes | ||
@typescript-eslint/no-empty-object-type | Disallow the {} type and empty interfaces | warn | suggestion | |
@typescript-eslint/no-explicit-any | Disallow the any type | warn | yes | |
@typescript-eslint/no-extra-non-null-assertion | Disallow a non-null assertion that has no effect | warn | yes | |
@typescript-eslint/no-extraneous-class | Disallow classes that are empty, only static, or only a constructor | |||
@typescript-eslint/no-floating-promises | Require promises to be awaited, returned, or handled | suggestion | yes | |
@typescript-eslint/no-for-in-array | Disallow for...in over an array | yes | ||
@typescript-eslint/no-generated-empty-object-type | Disallow type operations that produce the {} type | yes | ||
@typescript-eslint/no-implied-eval | Disallow passing code as a string to setTimeout, setInterval and new Function | yes | ||
@typescript-eslint/no-import-type-side-effects | Require import type when every name in an import is marked type | yes | ||
@typescript-eslint/no-inferrable-types | Disallow type annotations that repeat what the initial value already says | yes | ||
@typescript-eslint/no-invalid-this | Disallow this where its value is undefined | |||
@typescript-eslint/no-invalid-void-type | Disallow void outside of return types and generic type arguments | |||
@typescript-eslint/no-loop-func | Disallow functions in loops that use a variable the loop changes | |||
@typescript-eslint/no-loss-of-precision | Disallow number literals that cannot be stored exactly as written | |||
@typescript-eslint/no-magic-numbers | Disallow numbers that are used without a name | |||
@typescript-eslint/no-meaningless-void-operator | Disallow void in front of an expression that has no value to discard | yes | yes | |
@typescript-eslint/no-misused-new | Disallow new in a class and constructor in an interface | error | ||
@typescript-eslint/no-misused-promises | Disallow promises where the code around them cannot handle one | yes | ||
@typescript-eslint/no-misused-spread | Disallow ... on values that do not spread the way they look | suggestion | yes | |
@typescript-eslint/no-mixed-enums | Disallow enums that have both number and string members | yes | ||
@typescript-eslint/no-namespace | Disallow TypeScript namespace and module blocks | warn | ||
@typescript-eslint/no-non-null-asserted-nullish-coalescing | Disallow ! on the left side of ?? | suggestion | ||
@typescript-eslint/no-non-null-asserted-optional-chain | Disallow ! after an optional chain | warn | suggestion | |
@typescript-eslint/no-non-null-assertion | Disallow the non-null assertion value! | suggestion | ||
@typescript-eslint/no-redeclare | Disallow declaring the same name twice in one scope | |||
@typescript-eslint/no-redundant-type-constituents | Disallow members of unions and intersections that change nothing or swallow the rest | yes | ||
@typescript-eslint/no-require-imports | Disallow require() in favor of import | |||
@typescript-eslint/no-restricted-imports | Disallow imports of the modules you list, with an exception for type imports | |||
@typescript-eslint/no-restricted-types | Disallow the types you list | yes | ||
@typescript-eslint/no-shadow | Disallow a declaration that hides one with the same name in an outer scope | |||
@typescript-eslint/no-this-alias | Disallow storing this in a variable | warn | ||
@typescript-eslint/no-type-alias | Disallow type aliases, or allow only some kinds of them | |||
@typescript-eslint/no-unnecessary-boolean-literal-compare | Disallow comparing a boolean with true or false | yes | yes | |
@typescript-eslint/no-unnecessary-condition | Disallow conditions that the types say are always true or always false | suggestion | yes | |
@typescript-eslint/no-unnecessary-parameter-property-assignment | Disallow assigning a constructor parameter property to itself | |||
@typescript-eslint/no-unnecessary-qualifier | Disallow naming the enclosing namespace or enum where the short name works | yes | yes | |
@typescript-eslint/no-unnecessary-template-expression | Disallow ${} in a template literal where plain text or the value itself does the same | yes | yes | |
@typescript-eslint/no-unnecessary-type-arguments | Disallow a type argument that is the same as the default of its type parameter | yes | yes | |
@typescript-eslint/no-unnecessary-type-assertion | Disallow as, <T> and ! assertions that do not change the type | yes | yes | |
@typescript-eslint/no-unnecessary-type-constraint | Disallow extends any and extends unknown on a type parameter | warn | suggestion | |
@typescript-eslint/no-unnecessary-type-conversion | Disallow converting a value to the type it already has | suggestion | yes | |
@typescript-eslint/no-unnecessary-type-parameters | Disallow a type parameter that is used only once in a signature | suggestion | yes | |
@typescript-eslint/no-unsafe-argument | Disallow passing a value of type any as an argument | yes | ||
@typescript-eslint/no-unsafe-assignment | Disallow assigning a value of type any to a variable or a property | yes | ||
@typescript-eslint/no-unsafe-call | Disallow calling a value of type any | yes | ||
@typescript-eslint/no-unsafe-declaration-merging | Disallow a class and an interface with the same name | warn | ||
@typescript-eslint/no-unsafe-enum-assignment | Disallow giving a plain number or string to a place typed as an enum | yes | ||
@typescript-eslint/no-unsafe-enum-comparison | Disallow comparing an enum value with a plain number or string | suggestion | yes | |
@typescript-eslint/no-unsafe-function-type | Disallow the built-in Function type | warn | ||
@typescript-eslint/no-unsafe-member-access | Disallow reading a property of a value of type any | yes | ||
@typescript-eslint/no-unsafe-return | Disallow returning a value of type any from a function | yes | ||
@typescript-eslint/no-unsafe-type-assertion | Disallow type assertions that narrow a type | yes | ||
@typescript-eslint/no-unsafe-unary-minus | Require the operand of unary - to be a number or a bigint | yes | ||
@typescript-eslint/no-unused-expressions | Disallow statements that compute a value and do nothing with it | warn | ||
@typescript-eslint/no-unused-private-class-members | Disallow private class members that are never used | |||
@typescript-eslint/no-unused-vars | Disallow variables, functions, parameters, imports, and types that are never used | warn | yes | |
@typescript-eslint/no-use-before-define | Disallow using a variable, function, class, enum, or type above the line that declares it | |||
@typescript-eslint/no-useless-constructor | Disallow constructors that do what the default constructor does | suggestion | ||
@typescript-eslint/no-useless-default-assignment | Disallow default values that can never be used | suggestion | yes | |
@typescript-eslint/no-useless-empty-export | Disallow export {} in a file that is already a module | yes | ||
@typescript-eslint/no-var-requires | Disallow const x = require() in favor of import | |||
@typescript-eslint/no-wrapper-object-types | Disallow String, Number, Boolean, BigInt, Symbol, and Object as types | warn | yes | |
@typescript-eslint/non-nullable-type-assertion-style | Require value! instead of value as T when the assertion only removes null and undefined | yes | yes | |
@typescript-eslint/only-throw-error | Disallow throwing values that are not Error objects | yes | ||
@typescript-eslint/parameter-properties | Require or disallow parameter properties in class constructors | |||
@typescript-eslint/prefer-as-const | Require as const instead of repeating a literal as its own type | warn | yes | |
@typescript-eslint/prefer-destructuring | Require destructuring to read a property or an element into a variable | yes | yes | |
@typescript-eslint/prefer-enum-initializers | Require every enum member to have an explicit value | suggestion | ||
@typescript-eslint/prefer-find | Require .find() instead of .filter()[0] to get the first match | suggestion | yes | |
@typescript-eslint/prefer-for-of | Require for...of instead of a for loop that only uses its index to read the array | |||
@typescript-eslint/prefer-function-type | Require a function type instead of an interface or object type with only a call signature | yes | ||
@typescript-eslint/prefer-includes | Require .includes() instead of comparing .indexOf() with -1 | yes | yes | |
@typescript-eslint/prefer-literal-enum-member | Require enum values to be literals, not computed expressions | |||
@typescript-eslint/prefer-namespace-keyword | Require namespace instead of module to declare a namespace | warn | yes | |
@typescript-eslint/prefer-nullish-coalescing | Require ?? instead of || or a ternary to give a default for null or undefined | suggestion | yes | |
@typescript-eslint/prefer-optional-chain | Require a?.b instead of a && a.b, !a || !a.b, or (a || {}).b | yes | yes | |
@typescript-eslint/prefer-promise-reject-errors | Require an Error as the reason when a promise is rejected | yes | ||
@typescript-eslint/prefer-readonly | Require readonly on private members that are only assigned in the constructor | yes | yes | |
@typescript-eslint/prefer-readonly-parameter-types | Require the types of function parameters to be read-only | yes | ||
@typescript-eslint/prefer-reduce-type-parameter | Require a type argument on reduce instead of a type assertion on the initial value | yes | yes | |
@typescript-eslint/prefer-regexp-exec | Require pattern.exec(text) instead of text.match(pattern) when there is no g flag | yes | yes | |
@typescript-eslint/prefer-return-this-type | Require the return type this for a method that returns this | yes | yes | |
@typescript-eslint/prefer-string-starts-ends-with | Require startsWith and endsWith instead of other ways to test the start or end of a string | yes | yes | |
@typescript-eslint/prefer-ts-expect-error | Require @ts-expect-error instead of @ts-ignore | yes | ||
@typescript-eslint/promise-function-async | Require functions that return a promise to be async | yes | yes | |
@typescript-eslint/related-getter-setter-pairs | Require the type of a getter to be assignable to the type of its setter | yes | ||
@typescript-eslint/require-array-sort-compare | Require a compare function in calls to sort and toSorted on arrays | yes | ||
@typescript-eslint/require-await | Disallow async functions that never await and do not return a promise | suggestion | yes | |
@typescript-eslint/restrict-plus-operands | Require both operands of + to be numbers, bigints, or strings | yes | ||
@typescript-eslint/restrict-template-expressions | Disallow values in template literals that do not turn into a useful string | yes | ||
@typescript-eslint/return-await | Enforce consistent use of await when an async function returns a promise | yes | yes | |
@typescript-eslint/sort-type-constituents | Require the members of union and intersection types to be sorted | yes | ||
@typescript-eslint/strict-boolean-expressions | Disallow nullable numbers, strings, and booleans, any, and always-true values in conditions | suggestion | yes | |
@typescript-eslint/strict-void-return | Disallow passing a function that returns a value where a void function is expected | suggestion | yes | |
@typescript-eslint/switch-exhaustiveness-check | Require a switch on a union or an enum to have a case for every member | suggestion | yes | |
@typescript-eslint/triple-slash-reference | Disallow /// <reference /> comments where an import does the job | warn | ||
@typescript-eslint/typedef | Require type annotations in the places you choose | |||
@typescript-eslint/unbound-method | Disallow taking a method off its object without binding it | yes | ||
@typescript-eslint/unified-signatures | Disallow overloads that can be written as one signature | |||
@typescript-eslint/use-unknown-in-catch-callback-variable | Require the parameter of a promise rejection callback to be typed unknown | suggestion | yes |
React#
135 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
react-hooks/capitalized-calls | Disallow calling a function with a capitalized name from a component or a hook | |||
react-hooks/component-hook-factories | Deprecated: reports nothing, and is kept so that older configs still load | |||
react-hooks/config | Report an invalid configuration of the React Compiler | |||
react-hooks/error-boundaries | Disallow JSX inside a try block, where catch cannot see rendering errors | |||
react-hooks/exhaustive-deps | Require the dependency array of a hook to list every value its callback reads | warn | yes | |
react-hooks/exhaustive-effect-dependencies | Require the dependency array of an effect to match what the effect reads | suggestion | ||
react-hooks/fbt | Reserved for problems with fbt translations in the React Compiler: reports nothing | |||
react-hooks/gating | Validate the directive that puts a compiled component behind a feature flag | |||
react-hooks/globals | Disallow reassigning variables declared outside a component or hook during render | |||
react-hooks/hooks | Require hooks to be called at the top level of a component or hook, never conditionally | |||
react-hooks/immutability | Disallow modifying props, state, and other values that React expects to stay unchanged | |||
react-hooks/incompatible-library | Report calls to library APIs that the React Compiler cannot memoize safely | |||
react-hooks/invariant | Report code that makes the React Compiler fail one of its internal checks | |||
react-hooks/memo-dependencies | Require the dependency list of useMemo and useCallback to match what the callback reads | suggestion | ||
react-hooks/memoized-effect-dependencies | Require the dependencies of an effect to be memoized | |||
react-hooks/no-deriving-state-in-effects | Disallow effects that only compute state from props or other state | |||
react-hooks/preserve-manual-memoization | Disallow useMemo and useCallback calls that React Compiler cannot keep memoized | |||
react-hooks/purity | Disallow calls such as Math.random() and Date.now() while a component renders | |||
react-hooks/refs | Disallow reading or writing ref.current while a component renders | |||
react-hooks/rule-suppression | Disallow comments that turn off rules-of-hooks or exhaustive-deps | |||
react-hooks/rules-of-hooks | Require hooks to be called at the top level of a component or a custom hook | error | ||
react-hooks/set-state-in-effect | Disallow calling a state setter directly in the body of an effect | |||
react-hooks/set-state-in-render | Disallow calling a state setter unconditionally while a component renders | |||
react-hooks/static-components | Disallow components that are created while another component renders | |||
react-hooks/syntax | Disallow invalid JavaScript in components and hooks, such as assigning to a const | suggestion | ||
react-hooks/todo | Report valid syntax that the React Compiler does not support yet | |||
react-hooks/unsupported-syntax | Disallow syntax that the React Compiler cannot compile, such as eval() | |||
react-hooks/use-memo | Require useMemo() callbacks to take no parameters, be synchronous, and not reassign outer variables | |||
react-hooks/void-use-memo | Require useMemo() callbacks to return a value, and the value to be used | |||
react/boolean-prop-naming | Enforce a naming pattern such as isOpen or hasIcon for boolean props | |||
react/button-has-type | Require an explicit, valid type on every button element | |||
react/checked-requires-onchange-or-readonly | Require onChange or readOnly on an input that has checked | |||
react/default-props-match-prop-types | Require every entry of defaultProps to have a prop type that is not required | |||
react/destructuring-assignment | Enforce one style for reading props, state, and context: destructured or not | yes | ||
react/display-name | Require every component to have a name that React can show | |||
react/forbid-component-props | Disallow chosen props, by default className and style, on components | |||
react/forbid-dom-props | Disallow the props you choose on DOM elements such as div | |||
react/forbid-elements | Disallow the elements and components you choose | |||
react/forbid-foreign-prop-types | Disallow reading the propTypes of another component | |||
react/forbid-prop-types | Disallow vague prop types such as any, array, and object | |||
react/forward-ref-uses-ref | Require a component wrapped in forwardRef to take a ref parameter | suggestion | ||
react/function-component-definition | Enforce one way to write function components: declaration, expression, or arrow function | yes | ||
react/hook-use-state | Require useState to be destructured into a [value, setValue] pair | suggestion | ||
react/iframe-missing-sandbox | Require a valid sandbox attribute on iframe elements | |||
react/jsx-boolean-value | Enforce one way to write boolean attributes in JSX: disabled or disabled={true} | yes | ||
react/jsx-child-element-spacing | Disallow a line break between text and an inline element in JSX, where a space may be lost | |||
react/jsx-closing-bracket-location | Enforce where the closing bracket of a multiline JSX tag goes | yes | ||
react/jsx-closing-tag-location | Enforce that the closing tag of a multiline JSX element lines up with its opening tag | yes | ||
react/jsx-curly-brace-presence | Disallow curly braces around plain strings in JSX, or require them | yes | ||
react/jsx-curly-newline | Enforce consistent line breaks inside the curly braces of JSX expressions | yes | ||
react/jsx-curly-spacing | Enforce or disallow spaces inside the curly braces of JSX attributes and children | yes | ||
react/jsx-equals-spacing | Enforce or disallow spaces around the = of JSX attributes | yes | ||
react/jsx-filename-extension | Restrict the file extensions that may contain JSX | |||
react/jsx-first-prop-new-line | Enforce the position of the first prop of a JSX element | yes | ||
react/jsx-fragments | Enforce <> or <React.Fragment> for React fragments | yes | ||
react/jsx-handler-names | Enforce naming conventions for event handlers and the props they are passed to | |||
react/jsx-indent | Enforce consistent indentation of JSX elements and their children | yes | ||
react/jsx-indent-props | Enforce consistent indentation of JSX props | yes | ||
react/jsx-key | Require a key prop on elements in arrays and iterators | error | ||
react/jsx-max-depth | Enforce a maximum depth of nested JSX elements | |||
react/jsx-max-props-per-line | Enforce a maximum number of props on one line of a JSX tag | yes | ||
react/jsx-newline | Require or disallow an empty line between JSX elements and expressions | yes | ||
react/jsx-no-bind | Disallow .bind() and functions created during render as JSX props | |||
react/jsx-no-comment-textnodes | Disallow // and /* */ comments written as text between JSX tags | |||
react/jsx-no-constructed-context-values | Disallow context provider values that are created anew on every render | |||
react/jsx-no-duplicate-props | Disallow the same prop twice on one JSX element | |||
react/jsx-no-leaked-render | Disallow && conditions in JSX that can render 0 or NaN | yes | ||
react/jsx-no-literals | Disallow text written directly in JSX | |||
react/jsx-no-script-url | Disallow javascript: URLs in links | |||
react/jsx-no-target-blank | Require rel="noreferrer" on links that open in a new tab | yes | ||
react/jsx-no-undef | Disallow components in JSX that are not declared or imported | |||
react/jsx-no-useless-fragment | Disallow fragments that wrap a single child or sit directly in an HTML element | yes | ||
react/jsx-one-expression-per-line | Require each child of a JSX element to be on its own line | yes | ||
react/jsx-pascal-case | Require component names in JSX to be in PascalCase | |||
react/jsx-props-no-multi-spaces | Disallow more than one space, or an empty line, between JSX props | yes | ||
react/jsx-props-no-spread-multi | Disallow spreading the same variable twice in one JSX element | yes | ||
react/jsx-props-no-spreading | Disallow {...props} in JSX | |||
react/jsx-sort-default-props | Require the keys of defaultProps to be sorted alphabetically | |||
react/jsx-sort-props | Require JSX props to be sorted alphabetically | yes | ||
react/jsx-tag-spacing | Enforce spacing around the <, / and > of JSX tags | yes | ||
react/jsx-uses-react | Count React as used in files that contain JSX | error | ||
react/jsx-uses-vars | Count a variable as used when it is the name of a JSX tag | |||
react/jsx-wrap-multilines | Require parentheses around JSX that spans several lines | yes | ||
react/no-access-state-in-setstate | Disallow reading this.state in the argument of this.setState() | |||
react/no-adjacent-inline-elements | Disallow inline elements that touch each other without whitespace between them | |||
react/no-array-index-key | Disallow the index of an array item as its key | |||
react/no-arrow-function-lifecycle | Disallow arrow functions in class fields as React lifecycle methods | yes | ||
react/no-children-prop | Disallow passing children as a prop | |||
react/no-clone-element | Disallow React.cloneElement | |||
react/no-danger | Disallow the dangerouslySetInnerHTML prop | |||
react/no-danger-with-children | Disallow dangerouslySetInnerHTML on an element that also has children | |||
react/no-deprecated | Disallow React APIs that are deprecated | |||
react/no-did-mount-set-state | Disallow this.setState() in componentDidMount | |||
react/no-did-update-set-state | Disallow this.setState() in componentDidUpdate | |||
react/no-direct-mutation-state | Disallow assigning to this.state outside of the constructor | |||
react/no-find-dom-node | Disallow findDOMNode | |||
react/no-invalid-html-attribute | Disallow values of the rel attribute that HTML does not define | suggestion | ||
react/no-is-mounted | Disallow this.isMounted() | |||
react/no-multi-comp | Disallow more than one React component in a file | |||
react/no-namespace | Disallow namespaced element names such as <svg:circle> | |||
react/no-object-type-as-default-prop | Disallow objects, arrays, and functions as default values of destructured props | |||
react/no-react-children | Disallow the React.Children methods | |||
react/no-redundant-should-component-update | Disallow shouldComponentUpdate in a class that extends React.PureComponent | |||
react/no-render-return-value | Disallow using the return value of ReactDOM.render | |||
react/no-set-state | Disallow this.setState in class components | |||
react/no-string-refs | Disallow strings as the value of the ref attribute | |||
react/no-this-in-sfc | Disallow this in function components | |||
react/no-typos | Disallow misspelled lifecycle methods, static properties, and prop types | |||
react/no-unescaped-entities | Disallow " and ' as plain characters in JSX text | suggestion | ||
react/no-unknown-property | Disallow attributes on DOM elements that React does not know | yes | ||
react/no-unsafe | Disallow the UNSAFE_ lifecycle methods of class components | |||
react/no-unstable-nested-components | Disallow defining a component inside another component | |||
react/no-unused-class-component-methods | Disallow methods and properties of a class component that the class never uses | |||
react/no-unused-prop-types | Disallow props that are declared but never used in the component | |||
react/no-unused-state | Disallow fields of a class component's state that are never read | |||
react/no-will-update-set-state | Disallow this.setState in componentWillUpdate | |||
react/only-export-components | Require files with components to export only components, so Fast Refresh works | |||
react/prefer-es6-class | Enforce one way to write class components: class or createReactClass | |||
react/prefer-exact-props | Require propTypes to be wrapped in a function that rejects unknown props | |||
react/prefer-function-component | Require function components instead of class components | |||
react/prefer-read-only-props | Require the props in a component's type to be readonly | yes | ||
react/prefer-stateless-function | Require class components that only render from props to be functions | |||
react/prop-types | Require every prop that a component uses to be declared | |||
react/react-in-jsx-scope | Require React to be in scope in files that use JSX | |||
react/require-default-props | Require a default value for every prop that is not required | |||
react/require-optimization | Require class components to define shouldComponentUpdate or extend PureComponent | |||
react/require-render-return | Require the render method of a class component to return something | |||
react/self-closing-comp | Require elements without children to be self-closing | yes | ||
react/sort-comp | Enforce the order of methods and properties in a class component | |||
react/sort-default-props | Require the keys of defaultProps to be sorted alphabetically | |||
react/sort-prop-types | Require the keys of propTypes to be sorted alphabetically | yes | ||
react/state-in-constructor | Enforce where a class component sets its initial state: in the constructor or in a class field | |||
react/static-property-placement | Enforce where a class component declares propTypes, defaultProps and other static properties | |||
react/style-prop-object | Require the value of the style prop to be an object | |||
react/void-dom-elements-no-children | Disallow children on void DOM elements such as <img /> and <br /> |
React performance#
4 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
react-perf/jsx-no-jsx-as-prop | Disallow JSX elements created during render as the value of a JSX prop | |||
react-perf/jsx-no-new-array-as-prop | Disallow arrays created during render as the value of a JSX prop | |||
react-perf/jsx-no-new-function-as-prop | Disallow functions created during render as the value of a JSX prop | |||
react-perf/jsx-no-new-object-as-prop | Disallow objects created during render as the value of a JSX prop |
Accessibility (jsx-a11y)#
36 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
jsx-a11y/alt-text | Require alternative text on img, area, object and input type="image" | |||
jsx-a11y/anchor-ambiguous-text | Disallow link text such as "click here" that says nothing about the target | |||
jsx-a11y/anchor-has-content | Require links to have content that a screen reader can read | yes | ||
jsx-a11y/anchor-is-valid | Require links to have a real href, and buttons to be button elements | |||
jsx-a11y/aria-activedescendant-has-tabindex | Require elements with aria-activedescendant to be focusable | |||
jsx-a11y/aria-props | Disallow aria-* attributes that do not exist | yes | ||
jsx-a11y/aria-proptypes | Require aria-* attributes to have a value of the right kind | |||
jsx-a11y/aria-role | Require role to be a real ARIA role that is not abstract | |||
jsx-a11y/aria-unsupported-elements | Disallow role and aria-* attributes on elements that do not support them | yes | ||
jsx-a11y/autocomplete-valid | Require autoComplete on an input to be a value that browsers know | |||
jsx-a11y/click-events-have-key-events | Require a keyboard handler next to onClick on elements that are not controls | |||
jsx-a11y/control-has-associated-label | Require buttons, links and other controls to have a text label | |||
jsx-a11y/heading-has-content | Require headings to have content that a screen reader can read | |||
jsx-a11y/html-has-lang | Require a lang attribute on the html element | |||
jsx-a11y/iframe-has-title | Require a title on iframe elements | |||
jsx-a11y/img-redundant-alt | Disallow the words "image", "photo" and "picture" in alt text | |||
jsx-a11y/interactive-supports-focus | Require elements with an interactive role and an event handler to be focusable | suggestion | ||
jsx-a11y/label-has-associated-control | Require every <label> to have text and a form control it belongs to | |||
jsx-a11y/lang | Require the lang attribute of <html> to be a valid language tag | |||
jsx-a11y/media-has-caption | Require <audio> and <video> to have a <track> with captions | |||
jsx-a11y/mouse-events-have-key-events | Require onFocus with onMouseOver and onBlur with onMouseOut | |||
jsx-a11y/no-access-key | Disallow the accessKey attribute | suggestion | ||
jsx-a11y/no-aria-hidden-on-focusable | Disallow aria-hidden="true" on elements that can receive focus | yes | ||
jsx-a11y/no-autofocus | Disallow the autoFocus attribute | suggestion | ||
jsx-a11y/no-distracting-elements | Disallow <marquee> and <blink> | |||
jsx-a11y/no-interactive-element-to-noninteractive-role | Disallow non-interactive ARIA roles on interactive elements | |||
jsx-a11y/no-noninteractive-element-interactions | Disallow mouse and keyboard handlers on non-interactive elements | |||
jsx-a11y/no-noninteractive-element-to-interactive-role | Disallow interactive ARIA roles on non-interactive elements | |||
jsx-a11y/no-noninteractive-tabindex | Disallow tabIndex of 0 or more on non-interactive elements | |||
jsx-a11y/no-redundant-roles | Disallow a role that the element already has | yes | ||
jsx-a11y/no-static-element-interactions | Require a role on <div>, <span> and similar elements that have event handlers | |||
jsx-a11y/prefer-tag-over-role | Require the HTML element instead of a role that imitates it | |||
jsx-a11y/role-has-required-aria-props | Require the aria-* attributes that an element's role needs | |||
jsx-a11y/role-supports-aria-props | Disallow aria-* attributes that the element's role does not support | |||
jsx-a11y/scope | Disallow the scope attribute on elements other than <th> | yes | ||
jsx-a11y/tabindex-no-positive | Disallow tabIndex values greater than 0 | suggestion |
Next.js#
21 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
@next/next/google-font-display | Require a display parameter other than auto, block or fallback on Google Fonts URLs | |||
@next/next/google-font-preconnect | Require rel="preconnect" on <link> elements that point to fonts.gstatic.com | |||
@next/next/inline-script-id | Require an id on next/script components that have inline content | |||
@next/next/next-script-for-ga | Require next/script instead of <script> to load Google Analytics | |||
@next/next/no-assign-module-variable | Disallow declaring a variable named module | |||
@next/next/no-async-client-component | Disallow async components in files that start with "use client" | |||
@next/next/no-before-interactive-script-outside-document | Disallow the beforeInteractive strategy of next/script outside pages/_document.js | |||
@next/next/no-css-tags | Disallow <link rel="stylesheet"> for your own CSS files | |||
@next/next/no-document-import-in-page | Disallow importing next/document outside pages/_document.js | |||
@next/next/no-duplicate-head | Disallow more than one <Head> element in a file | |||
@next/next/no-head-element | Disallow the <head> element in favor of Head from next/head | |||
@next/next/no-head-import-in-document | Disallow importing next/head in pages/_document.js | |||
@next/next/no-html-link-for-pages | Disallow <a> elements that link to another page of the app | |||
@next/next/no-img-element | Disallow the <img> element in favor of Image from next/image | |||
@next/next/no-page-custom-font | Disallow Google Fonts <link> elements outside pages/_document.js | |||
@next/next/no-script-component-in-head | Disallow <Script> as a child of Head from next/head | |||
@next/next/no-styled-jsx-in-document | Disallow <style jsx> in pages/_document.js | |||
@next/next/no-sync-scripts | Disallow <script src> without async or defer | |||
@next/next/no-title-in-document-head | Disallow <title> in the Head of next/document | |||
@next/next/no-typos | Disallow misspellings of getStaticProps, getStaticPaths and getServerSideProps | suggestion | ||
@next/next/no-unwanted-polyfillio | Disallow scripts from polyfill.io, and polyfills that Next.js already ships |
import#
46 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
import/consistent-type-specifier-style | Enforce one way to mark type-only imports: import type { A } or import { type A } | yes | ||
import/default | Require a default import to match a default export in the imported file | |||
import/dynamic-import-chunkname | Require a webpackChunkName comment in every dynamic import() | suggestion | ||
import/enforce-node-protocol-usage | Enforce either node:fs or fs when importing Node.js built-in modules | yes | ||
import/export | Disallow exporting the same name twice, and export * from a file with no named exports | |||
import/exports-last | Require all exports to come after every other statement in the file | |||
import/extensions | Enforce that import paths always include the file extension, or never do | |||
import/first | Require all imports to come before every other statement in the file | yes | ||
import/group-exports | Require all named exports to be in a single export declaration | |||
import/imports-first | Require all imports to come before every other statement (old name of import/first) | yes | ||
import/max-dependencies | Enforce a maximum number of modules that a file can import | |||
import/named | Require each named import to match a named export in the imported file | |||
import/namespace | Require each property read from an import * as namespace to be exported by that file | |||
import/newline-after-import | Require an empty line between the last import and the code that follows | yes | ||
import/no-absolute-path | Disallow importing a module by an absolute file system path | yes | ||
import/no-amd | Disallow AMD define() and require() calls | |||
import/no-anonymous-default-export | Disallow default exports that have no name | |||
import/no-commonjs | Disallow require(), module.exports and exports.* in favor of import and export | |||
import/no-cycle | Disallow importing a module that imports this file back, directly or through other modules | |||
import/no-default-export | Disallow default exports | |||
import/no-deprecated | Disallow importing and using names that are marked @deprecated | |||
import/no-duplicates | Disallow importing the same module more than once in a file | yes | ||
import/no-dynamic-require | Disallow require() with an argument that is not a string literal | |||
import/no-empty-named-blocks | Disallow import {} from with nothing between the braces | yes | ||
import/no-extraneous-dependencies | Disallow importing a package that package.json does not list | |||
import/no-import-module-exports | Disallow import declarations in a file that exports with module.exports or exports.* | yes | ||
import/no-internal-modules | Disallow importing a file from inside another directory or package | |||
import/no-mutable-exports | Disallow exporting a variable declared with let or var | |||
import/no-named-as-default | Disallow naming a default import after a named export of the same module | |||
import/no-named-as-default-member | Disallow reading a property of a default import that is also a named export of the module | |||
import/no-named-default | Disallow import { default as name } in favor of import name | |||
import/no-named-export | Disallow named exports, so that a module only has a default export | |||
import/no-namespace | Disallow import * as name in favor of named imports | yes | ||
import/no-nodejs-modules | Disallow importing Node.js builtin modules such as fs and path | |||
import/no-relative-packages | Disallow relative imports that reach into another package | yes | ||
import/no-relative-parent-imports | Disallow relative imports from parent directories | |||
import/no-restricted-paths | Disallow files in one folder from importing files in another | |||
import/no-self-import | Disallow a module from importing itself | |||
import/no-unassigned-import | Disallow imports that bind no name | |||
import/no-unresolved | Require every import to point to a file or package that exists | |||
import/no-unused-modules | Disallow exports that no other file imports, and files that export nothing | |||
import/no-useless-path-segments | Disallow path segments in imports that can be removed | yes | ||
import/no-webpack-loader-syntax | Disallow webpack loader syntax such as style-loader!./app.css in imports | |||
import/order | Enforce a consistent order of imports, by group and optionally by name | yes | ||
import/prefer-default-export | Require a default export in a file that exports a single name | |||
import/unambiguous | Require a module to have an import or export so it cannot be read as a script |
unicorn#
138 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
unicorn/catch-error-name | Enforce one name for the error in catch clauses and promise handlers | yes | ||
unicorn/consistent-assert | Require assert.ok(value) instead of assert(value) with node:assert | yes | ||
unicorn/consistent-date-clone | Require new Date(date) instead of new Date(date.getTime()) to copy a date | yes | ||
unicorn/consistent-empty-array-spread | Require both branches of a spread ternary in an array to have the same type | suggestion | ||
unicorn/consistent-existence-index-check | Require === -1 and !== -1 to test the result of indexOf() and findIndex() | yes | ||
unicorn/consistent-function-scoping | Require functions that use nothing from the enclosing function to be moved out of it | |||
unicorn/consistent-template-literal-escape | Enforce one way to escape ${ in template literals | yes | ||
unicorn/custom-error-definition | Enforce that subclasses of Error set name and pass the message to super() | |||
unicorn/empty-brace-spaces | Disallow spaces and line breaks inside empty braces | yes | ||
unicorn/error-message | Require a message when creating a built-in error | |||
unicorn/escape-case | Require uppercase hexadecimal digits in escape sequences | yes | ||
unicorn/explicit-length-check | Require length and size to be compared with a number | yes | ||
unicorn/explicit-timer-delay | Require or disallow an explicit delay for setTimeout() and setInterval() | yes | ||
unicorn/filename-case | Enforce one case style for file names | |||
unicorn/import-style | Enforce how each module is imported: named, default, namespace, or for side effects | |||
unicorn/max-nested-calls | Enforce a maximum depth of calls nested in the arguments of other calls | |||
unicorn/new-for-builtins | Require new for built-in classes and disallow it for String, Number, Boolean, Symbol, BigInt | |||
unicorn/no-abusive-eslint-disable | Require eslint-disable comments to name the rules they turn off | |||
unicorn/no-accessor-recursion | Disallow a getter or setter that uses its own property on this | |||
unicorn/no-anonymous-default-export | Require a name for a function or class that is the default export | |||
unicorn/no-array-callback-reference | Disallow passing a function by name to array methods such as map and filter | |||
unicorn/no-array-fill-with-reference-type | Disallow filling an array with one object, array, or class instance | |||
unicorn/no-array-for-each | Require a for...of loop instead of .forEach() | |||
unicorn/no-array-method-this-argument | Disallow the thisArg argument of array methods such as map and filter | |||
unicorn/no-array-reduce | Disallow reduce() and reduceRight() in favor of a loop | |||
unicorn/no-array-reverse | Require toReversed() instead of reverse(), which changes the array | suggestion | ||
unicorn/no-array-sort | Require toSorted() instead of sort(), which changes the array | suggestion | ||
unicorn/no-await-expression-member | Disallow reading a property directly from an await expression | yes | ||
unicorn/no-await-in-promise-methods | Disallow await on the elements of the array passed to Promise.all() and similar methods | suggestion | ||
unicorn/no-confusing-array-with | Disallow a negative index and .length as the index of Array#with() | |||
unicorn/no-console-spaces | Disallow spaces at the edges of strings where console.log() already adds one | yes | ||
unicorn/no-document-cookie | Disallow assigning to document.cookie | |||
unicorn/no-empty-file | Disallow files that contain no code | |||
unicorn/no-hex-escape | Require Unicode escapes such as \u001B instead of hexadecimal escapes such as \x1B | yes | ||
unicorn/no-immediate-mutation | Disallow changing an array, object, Set, or Map in the statement right after creating it | |||
unicorn/no-instanceof-array | Require Array.isArray() instead of instanceof Array | yes | ||
unicorn/no-instanceof-builtins | Disallow instanceof with built-in constructors such as Array, String, and Function | suggestion | ||
unicorn/no-invalid-fetch-options | Disallow a body in fetch() and new Request() when the method is GET or HEAD | |||
unicorn/no-invalid-remove-event-listener | Disallow passing a new function to removeEventListener() | |||
unicorn/no-length-as-slice-end | Disallow passing .length as the end argument of .slice() | yes | ||
unicorn/no-lonely-if | Disallow an if as the only statement in another if when neither has an else | |||
unicorn/no-magic-array-flat-depth | Disallow an unexplained number as the depth of .flat() | |||
unicorn/no-negated-condition | Disallow a negated condition in an if with an else and in a ternary | yes | ||
unicorn/no-negation-in-equality-check | Disallow ! on the left side of ===, !==, ==, and != | suggestion | ||
unicorn/no-nested-ternary | Disallow deeply nested ternaries, and require parentheses around a ternary in a ternary | yes | ||
unicorn/no-new-array | Disallow new Array() with a single argument | suggestion | ||
unicorn/no-new-buffer | Require Buffer.from() or Buffer.alloc() instead of the deprecated new Buffer() | suggestion | ||
unicorn/no-null | Disallow the null literal in favor of undefined | yes | ||
unicorn/no-object-as-default-parameter | Disallow an object literal with properties as the default value of a parameter | |||
unicorn/no-process-exit | Disallow process.exit() | |||
unicorn/no-single-promise-in-promise-methods | Disallow an array with one item in Promise.all(), Promise.any(), and Promise.race() | yes | ||
unicorn/no-static-only-class | Disallow classes that have only static members | yes | ||
unicorn/no-thenable | Disallow a then property on objects, classes, and module exports | |||
unicorn/no-this-assignment | Disallow assigning this to a variable | |||
unicorn/no-typeof-undefined | Require comparing with undefined directly instead of typeof x === "undefined" | yes | ||
unicorn/no-unnecessary-array-flat-depth | Disallow passing 1 as the depth to Array#flat() | suggestion | ||
unicorn/no-unnecessary-array-splice-count | Disallow .length or Infinity as the count of splice() and toSpliced() | yes | ||
unicorn/no-unnecessary-await | Disallow await on a value that cannot be a promise | yes | ||
unicorn/no-unnecessary-slice-end | Disallow .length or Infinity as the end of slice() | yes | ||
unicorn/no-unreadable-array-destructuring | Disallow array destructuring that skips two or more values in a row | |||
unicorn/no-unreadable-iife | Disallow calling an arrow function in place when its body is in parentheses | suggestion | ||
unicorn/no-useless-collection-argument | Disallow empty arguments and fallbacks in new Set(), Map, WeakSet, and WeakMap | suggestion | ||
unicorn/no-useless-error-capture-stack-trace | Disallow Error.captureStackTrace() in the constructor of an Error subclass | suggestion | ||
unicorn/no-useless-fallback-in-spread | Disallow an empty object as the fallback when spreading into an object literal | yes | ||
unicorn/no-useless-iterator-to-array | Disallow .toArray() on an iterator where the iterator itself works | yes | ||
unicorn/no-useless-length-check | Disallow checking an array's length next to .some() or .every() where it changes nothing | |||
unicorn/no-useless-promise-resolve-reject | Disallow returning Promise.resolve() or Promise.reject() from an async function or promise callback | yes | ||
unicorn/no-useless-spread | Disallow spreads that only build an array or object to take it apart or copy it again | yes | ||
unicorn/no-useless-switch-case | Disallow empty case clauses that fall through to the last default | suggestion | ||
unicorn/no-useless-undefined | Disallow undefined where leaving it out means the same | yes | ||
unicorn/no-zero-fractions | Disallow numbers with a zero fraction or a dangling dot | yes | ||
unicorn/number-literal-case | Require lowercase prefixes and exponents, and uppercase hexadecimal digits, in numbers | yes | ||
unicorn/numeric-separators-style | Enforce how digits are grouped with _ in numbers | yes | ||
unicorn/prefer-add-event-listener | Require addEventListener() instead of assigning to on properties such as onclick | |||
unicorn/prefer-array-find | Require .find() or .findLast() instead of taking one element from .filter() | |||
unicorn/prefer-array-flat | Require .flat() instead of flattening an array with concat, reduce or flatMap | yes | ||
unicorn/prefer-array-flat-map | Require one .flatMap() instead of .map().flat() or .filter().flatMap() | yes | ||
unicorn/prefer-array-index-of | Require .indexOf() instead of .findIndex() when looking for a value | |||
unicorn/prefer-array-some | Require .some() to test whether an array has a matching element | suggestion | ||
unicorn/prefer-at | Require .at() to read an element counted from the end of an array or string | yes | ||
unicorn/prefer-bigint-literals | Require BigInt literals such as 123n instead of BigInt(123) | yes | ||
unicorn/prefer-blob-reading-methods | Require blob.text() and blob.arrayBuffer() instead of a FileReader | |||
unicorn/prefer-class-fields | Require class fields instead of this assignments of fixed values in the constructor | yes | ||
unicorn/prefer-classlist-toggle | Require classList.toggle() instead of choosing between add() and remove() | yes | ||
unicorn/prefer-code-point | Require codePointAt() and String.fromCodePoint() over charCodeAt() and String.fromCharCode() | yes | ||
unicorn/prefer-date-now | Require Date.now() to get the current time in milliseconds | yes | ||
unicorn/prefer-default-parameters | Require default parameters instead of reassigning a parameter in the function body | suggestion | ||
unicorn/prefer-dom-node-append | Require .append() instead of .appendChild() on DOM nodes | yes | ||
unicorn/prefer-dom-node-dataset | Require .dataset instead of the attribute methods for data-* attributes | yes | ||
unicorn/prefer-dom-node-remove | Require child.remove() instead of parent.removeChild(child) | |||
unicorn/prefer-dom-node-text-content | Require .textContent instead of .innerText | yes | ||
unicorn/prefer-event-target | Require EventTarget instead of EventEmitter | |||
unicorn/prefer-export-from | Require export ... from to re-export instead of an import and a separate export | suggestion | ||
unicorn/prefer-global-this | Require globalThis instead of window, self and global | suggestion | ||
unicorn/prefer-import-meta-properties | Require import.meta.dirname and import.meta.filename instead of building them from the URL | yes | ||
unicorn/prefer-includes | Require .includes() instead of comparing .indexOf() with -1 or 0 | suggestion | ||
unicorn/prefer-keyboard-event-key | Require event.key instead of keyCode, charCode and which | yes | ||
unicorn/prefer-logical-operator-over-ternary | Require || or ?? instead of a ternary that repeats its condition | suggestion | ||
unicorn/prefer-math-min-max | Require Math.min() and Math.max() instead of a ternary that picks the smaller or larger value | suggestion | ||
unicorn/prefer-math-trunc | Require Math.trunc() instead of bitwise tricks to drop the fraction of a number | suggestion | ||
unicorn/prefer-modern-dom-apis | Require .before(), .after(), .append(), .prepend() and .replaceWith() over older DOM methods | suggestion | ||
unicorn/prefer-modern-math-apis | Require Math.log10(), Math.log2(), Math.hypot() and Math.abs() over hand-written formulas | |||
unicorn/prefer-module | Require ES modules instead of CommonJS | |||
unicorn/prefer-native-coercion-functions | Require passing String, Number, BigInt, Boolean and Symbol directly instead of wrapping them | |||
unicorn/prefer-negative-index | Require a negative index instead of .length - index | yes | ||
unicorn/prefer-node-protocol | Require the node: prefix when importing Node.js built-in modules | yes | ||
unicorn/prefer-number-coercion | Require Number() instead of parseFloat() and base-10 parseInt() | suggestion | ||
unicorn/prefer-number-properties | Require Number.isNaN, Number.parseInt and the like instead of the globals | yes | ||
unicorn/prefer-object-from-entries | Require Object.fromEntries() to turn key-value pairs into an object | |||
unicorn/prefer-optional-catch-binding | Require catch {} without a parameter when the error is not used | yes | ||
unicorn/prefer-prototype-methods | Require borrowing a method from the prototype instead of from an empty [] or {} | yes | ||
unicorn/prefer-query-selector | Require querySelector() and querySelectorAll() instead of the getElement... methods | yes | ||
unicorn/prefer-reflect-apply | Require Reflect.apply() instead of Function.prototype.apply() | suggestion | ||
unicorn/prefer-regexp-test | Require RegExp#test() instead of String#match() and RegExp#exec() for a yes or no answer | yes | ||
unicorn/prefer-response-static-json | Require Response.json() instead of new Response(JSON.stringify()) | suggestion | ||
unicorn/prefer-set-has | Require Set#has() instead of Array#includes() for an array that is only searched | yes | ||
unicorn/prefer-set-size | Require Set#size instead of converting the Set to an array to read length | yes | ||
unicorn/prefer-single-call | Require one call instead of several in a row to push(), unshift(), classList.add() and the like | yes | ||
unicorn/prefer-spread | Require the spread operator instead of Array.from(), concat(), slice() and toSpliced() | yes | ||
unicorn/prefer-string-raw | Require String.raw for strings that escape backslashes | yes | ||
unicorn/prefer-string-replace-all | Require replaceAll() instead of replace() with a global regex | yes | ||
unicorn/prefer-string-slice | Require slice() instead of substr() and substring() | yes | ||
unicorn/prefer-string-starts-ends-with | Require startsWith() and endsWith() instead of a regex with ^ or $ | yes | ||
unicorn/prefer-string-trim-start-end | Require trimStart() and trimEnd() instead of trimLeft() and trimRight() | yes | ||
unicorn/prefer-structured-clone | Require structuredClone() for deep clones | suggestion | ||
unicorn/prefer-ternary | Require a ternary instead of an if/else where both branches do the same kind of thing | |||
unicorn/prefer-top-level-await | Require top-level await instead of promise chains and async wrappers at the top of a module | |||
unicorn/prefer-type-error | Require TypeError when the throw follows a type check | yes | ||
unicorn/relative-url-style | Enforce one style for relative URLs in new URL(): with or without ./ | yes | ||
unicorn/require-array-join-separator | Require the separator argument of Array#join() | yes | ||
unicorn/require-module-attributes | Disallow an empty attribute list in import, export and import() | suggestion | ||
unicorn/require-module-specifiers | Disallow empty braces in import and export statements | yes | ||
unicorn/require-number-to-fixed-digits-argument | Require the digits argument of Number#toFixed() | yes | ||
unicorn/require-post-message-target-origin | Require the targetOrigin argument of window.postMessage() | suggestion | ||
unicorn/switch-case-braces | Enforce braces, or no braces, around the body of each case | yes | ||
unicorn/switch-case-break-position | Require break, return, continue and throw inside the braces of a case | |||
unicorn/text-encoding-identifier-case | Enforce one spelling for the encoding names utf8 and ascii | yes | ||
unicorn/throw-new-error | Require new when creating an error | yes |
promise#
16 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
promise/always-return | Require every then() callback to return a value or throw | |||
promise/avoid-new | Disallow creating promises with new Promise() | |||
promise/catch-or-return | Require a promise chain to end with catch() or to be returned | |||
promise/no-callback-in-promise | Disallow calling a callback inside then() or catch() | |||
promise/no-multiple-resolved | Disallow paths that call resolve or reject more than once in a new Promise() executor | |||
promise/no-nesting | Disallow then() and catch() nested inside another then() or catch() | |||
promise/no-new-statics | Disallow new on static Promise methods such as Promise.all | yes | ||
promise/no-promise-in-callback | Disallow promises inside error-first callbacks | |||
promise/no-return-in-finally | Disallow return in a finally() callback | |||
promise/no-return-wrap | Disallow returning Promise.resolve() or Promise.reject() from a promise callback | |||
promise/param-names | Require the parameters of a new Promise() executor to be named resolve and reject | |||
promise/prefer-await-to-callbacks | Require async/await instead of error-first callbacks | |||
promise/prefer-await-to-then | Require await instead of then(), catch() and finally() | |||
promise/prefer-catch | Require catch() instead of a second argument to then() | |||
promise/spec-only | Disallow Promise static methods that are not part of the language | |||
promise/valid-params | Require the right number of arguments for Promise methods |
Node.js (n)#
15 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
n/callback-return | Require a return with every call to a callback | |||
n/exports-style | Enforce either module.exports or exports in CommonJS files | |||
n/global-require | Require require() calls to be at the top level of the file | |||
n/handle-callback-err | Require callbacks to use their error parameter | |||
n/no-exports-assign | Disallow assigning to exports | yes | ||
n/no-mixed-requires | Disallow require() calls mixed with other variables in one declaration | |||
n/no-new-require | Disallow new require() | |||
n/no-path-concat | Disallow joining __dirname and __filename to a path with + or a template | |||
n/no-process-env | Disallow process.env | |||
n/no-process-exit | Disallow process.exit() | |||
n/no-sync | Disallow calls to functions with names that end in Sync | |||
n/no-top-level-await | Disallow await at the top level of a module | |||
n/no-unsupported-features/es-builtins | Disallow JavaScript built-ins that the Node.js versions you support do not have | |||
n/no-unsupported-features/es-syntax | Disallow JavaScript syntax that the Node.js versions you support do not have | |||
n/no-unsupported-features/node-builtins | Disallow Node.js APIs that the Node.js versions you support do not have |
oxc#
27 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
oxc/approx-constant | Disallow numbers that approximate a constant of the Math object | suggestion | ||
oxc/bad-array-method-on-arguments | Disallow calling array methods on the arguments object | |||
oxc/bad-bitwise-operator | Disallow & and | where && and || were probably meant | suggestion | ||
oxc/bad-char-at-comparison | Disallow comparing a single character with a longer string | |||
oxc/bad-comparison-sequence | Disallow chained comparisons such as a < b < c | |||
oxc/bad-match-all-arg | Require the g flag on a regular expression passed to matchAll() | |||
oxc/bad-min-max-func | Disallow Math.min and Math.max combinations that always give the same result | |||
oxc/bad-object-literal-comparison | Disallow comparing a value with {} or [] | |||
oxc/bad-replace-all-arg | Require the g flag on a regular expression passed to replaceAll() | |||
oxc/branches-sharing-code | Disallow the same statements at the start or end of every branch of an if | suggestion | ||
oxc/const-comparisons | Disallow comparisons that are always true, always false, or repeated | |||
oxc/double-comparisons | Disallow two comparisons of the same values that one operator can express | suggestion | ||
oxc/erasing-op | Disallow operations with 0 that erase the other operand | yes | ||
oxc/misrefactored-assign-op | Disallow a += a + b, where the target is repeated on the right | suggestion | ||
oxc/missing-throw | Require throw before a new Error() that is not used | suggestion | ||
oxc/no-accumulating-spread | Disallow spreading the accumulator in reduce() and in loops | |||
oxc/no-async-await | Disallow async functions | |||
oxc/no-async-endpoint-handlers | Disallow async functions as Express route handlers and middleware | |||
oxc/no-barrel-file | Disallow files that load too many modules through export * | |||
oxc/no-const-enum | Disallow TypeScript const enum | yes | ||
oxc/no-map-spread | Disallow object and array spreads in the return value of map and flatMap callbacks | suggestion | ||
oxc/no-optional-chaining | Disallow optional chaining (?.) | |||
oxc/no-rest-spread-properties | Disallow ... in object literals and object destructuring | |||
oxc/no-this-in-exported-function | Disallow this in exported functions | |||
oxc/number-arg-out-of-range | Disallow out-of-range arguments to toString, toFixed, toExponential, and toPrecision | |||
oxc/only-used-in-recursion | Disallow parameters that are only passed on to the function's own recursive calls | yes | ||
oxc/uninvoked-array-callback | Disallow array methods with a callback directly on new Array(n) |
Bun#
29 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
bun/consistent-directive-prefix | Require comments that turn rules off to start with the same word, eslint or oxlint | yes | ||
bun/format | Require code to be formatted the way bun fmt prints it | yes | ||
bun/jsx-no-forbidden-nesting | Disallow a JSX element inside another element that cannot contain it | |||
bun/no-array-just-to-count | Disallow .split(separator).length with a one-character separator | yes | ||
bun/no-cast-to-brand | Disallow casts to a branded type outside the module that declares it | |||
bun/no-console-window-flash | Require windowsHide for a child process that does not share a stream with its parent | |||
bun/no-cwd-dependent-path | Disallow relative paths that depend on the directory the process was started in | |||
bun/no-eager-dynamic-import | Disallow import() that runs as soon as the module is loaded | |||
bun/no-eager-native-addon | Disallow loading a .node native addon as soon as the module is loaded | |||
bun/no-env-at-module-scope | Disallow reading environment variables as soon as the module is loaded | |||
bun/no-literal-temp-dir | Disallow hard-coded temporary directories such as /tmp in favor of os.tmpdir() | |||
bun/no-negative-repeat-count | Disallow a repeat() count that comes from a subtraction and can be negative | suggestion | ||
bun/no-redundant-catch-type | Disallow : unknown on the variable of a catch clause | yes | ||
bun/no-restricted-text | Disallow text that matches a pattern in strings, templates, JSX text, comments, and regular expressions | |||
bun/no-side-effects-on-import | Disallow top-level statements that call something or assign to a property | |||
bun/no-unbounded-requests | Require an axios request to have a timeout or a signal | |||
bun/no-unhandled-emitter-errors | Require an error listener on event emitters that Node.js functions return | |||
bun/no-unportable-commands | Disallow starting a process with a command that does not work the same on every system | |||
bun/no-unseeded-random-in-property-test | Disallow Math.random() and fc.sample() inside a fast-check property | |||
bun/no-useless-spread-fallback | Disallow an empty object as the fallback in ...(condition ? value : {}) | suggestion | ||
bun/prefer-builtin-sleep | Prefer Bun.sleep() to a promise that only waits for setTimeout | suggestion | ||
bun/prefer-lazy-schema | Disallow building a validation schema while the module loads | |||
bun/prefer-local-module | Require importing a package through the module in your project that wraps it | yes | ||
bun/prefer-timeout-signal | Prefer AbortSignal.timeout() to an AbortController that only a timer aborts | |||
bun/prefer-url-for-sibling-files | Prefer new URL("./file", import.meta.url) to a path joined onto the module's directory | |||
bun/react-no-latest-value-ref | Disallow a ref that is set to the latest value on every render | |||
bun/react-no-local-render-helpers | Disallow renderItem() functions that are defined inside a component and used in its JSX | |||
bun/react-no-namespace-hooks | Require React hooks to be imported by name: useState(), not React.useState() | yes | ||
bun/react-prefer-updater-function | Prefer setItems(previous => ..) to a new array or object made from the state of the last render |
bun:test#
65 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
bun:test/consistent-test-filename | Require test files to follow one naming pattern | |||
bun:test/consistent-test-it | Enforce one of test or it for defining tests | yes | ||
bun:test/expect-expect | Require every test to make at least one assertion | |||
bun:test/max-expects | Enforce a maximum number of expect() calls in a test | |||
bun:test/max-nested-describe | Enforce a maximum depth of nested describe() calls | |||
bun:test/no-alias-methods | Disallow matcher aliases such as toBeCalled in favor of toHaveBeenCalled | yes | ||
bun:test/no-commented-out-tests | Disallow tests that are inside a comment | |||
bun:test/no-conditional-expect | Disallow expect inside if, catch and other code that only runs sometimes | |||
bun:test/no-conditional-in-test | Disallow if, switch, ? :, &&, || and ?? inside a test | |||
bun:test/no-conditional-tests | Disallow test and describe inside an if statement | |||
bun:test/no-disabled-tests | Disallow skipped tests such as test.skip, xtest and xdescribe | warn | ||
bun:test/no-done-callback | Disallow the done callback in tests and hooks in favor of promises | |||
bun:test/no-duplicate-hooks | Disallow using the same hook twice in one describe block | |||
bun:test/no-export | Disallow exports from a file that has tests | warn | ||
bun:test/no-focused-tests | Disallow test.only and describe.only | error | suggestion | |
bun:test/no-hooks | Disallow beforeAll, beforeEach, afterEach and afterAll | |||
bun:test/no-identical-title | Disallow two tests or two describe blocks with the same title in one block | |||
bun:test/no-interpolation-in-snapshots | Disallow ${} in inline snapshots | |||
bun:test/no-large-snapshots | Disallow snapshots that are longer than a set number of lines | |||
bun:test/no-restricted-jest-methods | Disallow the jest and vi methods that you list | |||
bun:test/no-restricted-matchers | Disallow the matchers and modifiers you list | |||
bun:test/no-standalone-expect | Disallow expect outside of a test or it block | |||
bun:test/no-test-prefixes | Require .skip instead of the x prefix | yes | ||
bun:test/no-test-return-statement | Disallow return expect(..) in a test | |||
bun:test/no-unneeded-async-expect-function | Disallow an async function around a single awaited call in expect | yes | ||
bun:test/padding-around-after-all-blocks | Require a blank line before each afterAll call | yes | ||
bun:test/padding-around-test-blocks | Require a blank line before each test and it call | yes | ||
bun:test/prefer-called-once | Require toHaveBeenCalledOnce() instead of toHaveBeenCalledTimes(1) | yes | ||
bun:test/prefer-called-times | Require toHaveBeenCalledTimes(1) instead of toHaveBeenCalledOnce() | yes | ||
bun:test/prefer-called-with | Require toHaveBeenCalledWith() instead of toHaveBeenCalled() | suggestion | ||
bun:test/prefer-comparison-matcher | Require matchers such as toBeGreaterThan() instead of comparing inside expect() | suggestion | ||
bun:test/prefer-describe-function-title | Require describe(fn, ...) instead of a string with the name of an imported function | suggestion | ||
bun:test/prefer-each | Require test.each and describe.each instead of a loop around tests | |||
bun:test/prefer-ending-with-an-expect | Require the last statement of a test to be an assertion | |||
bun:test/prefer-equality-matcher | Require toBe or toEqual instead of comparing with === inside expect | suggestion | ||
bun:test/prefer-expect-assertions | Require expect.assertions() or expect.hasAssertions() at the start of every test | suggestion | ||
bun:test/prefer-expect-resolves | Require await expect(promise).resolves instead of expect(await promise) | suggestion | ||
bun:test/prefer-expect-type-of | Require toBeTypeOf instead of expect(typeof value).toBe(...) | yes | ||
bun:test/prefer-hooks-in-order | Require hooks to be written in the order they run | |||
bun:test/prefer-hooks-on-top | Require hooks to come before the tests in their block | |||
bun:test/prefer-lowercase-title | Require the titles of tests and describe blocks to start with a lowercase letter | yes | ||
bun:test/prefer-mock-promise-shorthand | Require mockResolvedValue() and mockRejectedValue() for mocks that return a promise | yes | ||
bun:test/prefer-mock-return-shorthand | Require mockReturnValue() for a mock that only returns a value | yes | ||
bun:test/prefer-snapshot-hint | Require a hint on toMatchSnapshot() and toThrowErrorMatchingSnapshot() | |||
bun:test/prefer-spy-on | Require spyOn() instead of assigning jest.fn() to a property | suggestion | ||
bun:test/prefer-strict-boolean-matchers | Require toBe(true) and toBe(false) instead of toBeTruthy() and toBeFalsy() | suggestion | ||
bun:test/prefer-strict-equal | Require toStrictEqual() instead of toEqual() | suggestion | ||
bun:test/prefer-to-be | Require toBe() for primitive literals, and toBeNull(), toBeUndefined(), toBeNaN() | yes | ||
bun:test/prefer-to-be-falsy | Require toBeFalsy() instead of toBe(false) | suggestion | ||
bun:test/prefer-to-be-truthy | Require toBeTruthy() instead of toBe(true) | suggestion | ||
bun:test/prefer-to-contain | Require toContain() instead of comparing the result of includes() with a boolean | suggestion | ||
bun:test/prefer-to-have-been-called | Require not.toHaveBeenCalled() instead of toHaveBeenCalledTimes(0) | yes | ||
bun:test/prefer-to-have-been-called-times | Require toHaveBeenCalledTimes() instead of checking the length of mock.calls | yes | ||
bun:test/prefer-to-have-length | Require toHaveLength() instead of comparing the length property | yes | ||
bun:test/prefer-todo | Require test.todo for tests that have no body yet | yes | ||
bun:test/require-hook | Require setup and teardown code to be inside a hook | |||
bun:test/require-mock-type-parameters | Require a type parameter on jest.fn() and vi.fn() | |||
bun:test/require-test-timeout | Require every test to set a timeout | |||
bun:test/require-to-throw-message | Require toThrow() to say which error it expects | |||
bun:test/require-top-level-describe | Require tests and hooks to be inside a describe block | |||
bun:test/valid-describe-callback | Require describe to get a callback that is a function with no parameters | error | ||
bun:test/valid-expect | Require expect to get a value, end in a called matcher, and be awaited when it is async | error | suggestion | |
bun:test/valid-expect-in-promise | Require a promise chain that contains expect to be awaited or returned from the test | error | ||
bun:test/valid-title | Require test and describe titles to be non-empty, with no stray spaces or repeated prefix | yes | ||
bun:test/warn-todo | Disallow .todo on test, it and describe |
Jest#
60 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
jest/consistent-test-it | Enforce one of test or it for defining tests | yes | ||
jest/expect-expect | Require every test to make at least one assertion | |||
jest/max-expects | Enforce a maximum number of expect() calls in a test | |||
jest/max-nested-describe | Enforce a maximum depth of nested describe() calls | |||
jest/no-alias-methods | Disallow matcher aliases such as toBeCalled in favor of toHaveBeenCalled | yes | ||
jest/no-commented-out-tests | Disallow tests that are inside a comment | |||
jest/no-conditional-expect | Disallow expect inside if, catch and other code that only runs sometimes | |||
jest/no-conditional-in-test | Disallow if, switch, ? :, &&, || and ?? inside a test | |||
jest/no-confusing-set-timeout | Disallow jest.setTimeout inside a block, after a test, or more than once in a file | |||
jest/no-deprecated-functions | Disallow Jest functions that have been renamed or replaced | yes | ||
jest/no-disabled-tests | Disallow skipped tests such as test.skip, xtest and xdescribe | |||
jest/no-done-callback | Disallow the done callback in tests and hooks in favor of promises | |||
jest/no-duplicate-hooks | Disallow using the same hook twice in one describe block | |||
jest/no-export | Disallow exports from a file that has tests | |||
jest/no-focused-tests | Disallow test.only, describe.only, fit and fdescribe | suggestion | ||
jest/no-hooks | Disallow beforeAll, beforeEach, afterEach and afterAll | |||
jest/no-identical-title | Disallow two tests or two describe blocks with the same title in one block | |||
jest/no-interpolation-in-snapshots | Disallow ${} in inline snapshots | |||
jest/no-jasmine-globals | Disallow Jasmine globals such as jasmine.any, spyOn, fail and pending | yes | ||
jest/no-large-snapshots | Disallow snapshots that are longer than a set number of lines | |||
jest/no-mocks-import | Disallow importing from a __mocks__ directory | |||
jest/no-restricted-jest-methods | Disallow the jest methods that you list | |||
jest/no-restricted-matchers | Disallow the matchers and modifiers you list | |||
jest/no-standalone-expect | Disallow expect outside of a test or it block | |||
jest/no-test-prefixes | Require .only and .skip instead of the f and x prefixes | yes | ||
jest/no-test-return-statement | Disallow return expect(..) in a test | |||
jest/no-unneeded-async-expect-function | Disallow an async function around a single awaited call in expect | yes | ||
jest/no-untyped-mock-factory | Require a type parameter on jest.mock() and jest.doMock() with a factory | yes | ||
jest/padding-around-after-all-blocks | Require a blank line before each afterAll call | yes | ||
jest/padding-around-test-blocks | Require a blank line before each test and it call | yes | ||
jest/prefer-called-with | Require toHaveBeenCalledWith() instead of toHaveBeenCalled() | yes | ||
jest/prefer-comparison-matcher | Require matchers such as toBeGreaterThan() instead of comparing inside expect() | yes | ||
jest/prefer-each | Require test.each and describe.each instead of a loop around tests | |||
jest/prefer-ending-with-an-expect | Require the last statement of a test to be an assertion | |||
jest/prefer-equality-matcher | Require toBe or toEqual instead of comparing with === inside expect | suggestion | ||
jest/prefer-expect-assertions | Require expect.assertions() or expect.hasAssertions() at the start of every test | suggestion | ||
jest/prefer-expect-resolves | Require await expect(promise).resolves instead of expect(await promise) | yes | ||
jest/prefer-hooks-in-order | Require hooks to be written in the order they run | |||
jest/prefer-hooks-on-top | Require hooks to come before the tests in their block | |||
jest/prefer-importing-jest-globals | Require describe, test, expect and jest to be imported from @jest/globals | yes | ||
jest/prefer-jest-mocked | Require jest.mocked(fn) instead of fn as jest.Mock | yes | ||
jest/prefer-lowercase-title | Require the titles of tests and describe blocks to start with a lowercase letter | yes | ||
jest/prefer-mock-promise-shorthand | Require mockResolvedValue() and mockRejectedValue() for mocks that return a promise | yes | ||
jest/prefer-mock-return-shorthand | Require mockReturnValue() for a mock that only returns a value | yes | ||
jest/prefer-snapshot-hint | Require a hint on toMatchSnapshot() and toThrowErrorMatchingSnapshot() | |||
jest/prefer-spy-on | Require jest.spyOn() instead of assigning jest.fn() to a property | suggestion | ||
jest/prefer-strict-equal | Require toStrictEqual() instead of toEqual() | suggestion | ||
jest/prefer-to-be | Require toBe() for primitive literals, and toBeNull(), toBeUndefined(), toBeNaN() | yes | ||
jest/prefer-to-contain | Require toContain() instead of comparing the result of includes() with a boolean | yes | ||
jest/prefer-to-have-been-called | Require not.toHaveBeenCalled() instead of toHaveBeenCalledTimes(0) | yes | ||
jest/prefer-to-have-been-called-times | Require toHaveBeenCalledTimes() instead of checking the length of mock.calls | yes | ||
jest/prefer-to-have-length | Require toHaveLength() instead of comparing the length property | yes | ||
jest/prefer-todo | Require test.todo for tests that have no body yet | yes | ||
jest/require-hook | Require setup and teardown code to be inside a hook | |||
jest/require-to-throw-message | Require toThrow() to say which error it expects | |||
jest/require-top-level-describe | Require tests and hooks to be inside a describe block | |||
jest/valid-describe-callback | Require describe to get a title and a plain synchronous callback | |||
jest/valid-expect | Require expect to get a value, end in a called matcher, and be awaited when it is async | suggestion | ||
jest/valid-expect-in-promise | Require a promise chain that contains expect to be awaited or returned from the test | |||
jest/valid-title | Require test and describe titles to be non-empty strings with no stray spaces or repeated prefix | yes |
Vitest#
73 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
vitest/consistent-each-for | Enforce either .each or .for for parameterized tests | |||
vitest/consistent-test-filename | Require test files to follow one naming pattern | |||
vitest/consistent-test-it | Enforce one of test or it for defining tests | yes | ||
vitest/consistent-vitest-vi | Enforce one of vi or vitest for Vitest's helper object | yes | ||
vitest/expect-expect | Require every test to make at least one assertion | |||
vitest/hoisted-apis-on-top | Require vi.mock, vi.unmock and vi.hoisted at the top level of the file | suggestion | ||
vitest/max-expects | Enforce a maximum number of expect() calls in a test | |||
vitest/max-nested-describe | Enforce a maximum depth of nested describe() calls | |||
vitest/no-alias-methods | Disallow matcher aliases such as toBeCalled in favor of toHaveBeenCalled | yes | ||
vitest/no-commented-out-tests | Disallow tests that are inside a comment | |||
vitest/no-conditional-expect | Disallow expect inside if, catch and other code that only runs sometimes | |||
vitest/no-conditional-in-test | Disallow if, switch, ? :, &&, || and ?? inside a test | |||
vitest/no-conditional-tests | Disallow test and describe inside an if statement | |||
vitest/no-disabled-tests | Disallow skipped tests such as test.skip and describe.skip | |||
vitest/no-duplicate-hooks | Disallow using the same hook twice in one describe block | |||
vitest/no-focused-tests | Disallow test.only and describe.only | suggestion | ||
vitest/no-hooks | Disallow beforeAll, beforeEach, afterEach and afterAll | |||
vitest/no-identical-title | Disallow two tests or two describe blocks with the same title in one block | |||
vitest/no-import-node-test | Disallow importing from node:test in a project that uses Vitest | suggestion | ||
vitest/no-importing-vitest-globals | Disallow importing test, expect, vi and the other Vitest globals | yes | ||
vitest/no-interpolation-in-snapshots | Disallow ${} in inline snapshots | |||
vitest/no-large-snapshots | Disallow snapshots that are longer than a set number of lines | |||
vitest/no-mocks-import | Disallow importing from a __mocks__ directory | |||
vitest/no-restricted-matchers | Disallow the matchers and modifiers you list | |||
vitest/no-restricted-vi-methods | Disallow the vi methods you list | |||
vitest/no-standalone-expect | Disallow expect outside of a test or it block | |||
vitest/no-test-prefixes | Require .only and .skip instead of the f and x prefixes | yes | ||
vitest/no-test-return-statement | Disallow return expect(..) in a test | |||
vitest/no-unneeded-async-expect-function | Disallow an async function around a single awaited call in expect | yes | ||
vitest/padding-around-after-all-blocks | Require a blank line before each afterAll call | yes | ||
vitest/padding-around-test-blocks | Require a blank line before each test and it call | yes | ||
vitest/prefer-called-exactly-once-with | Require toHaveBeenCalledExactlyOnceWith() over separate call count and argument checks | yes | ||
vitest/prefer-called-once | Require toHaveBeenCalledOnce() instead of toHaveBeenCalledTimes(1) | yes | ||
vitest/prefer-called-times | Require toHaveBeenCalledTimes(1) instead of toHaveBeenCalledOnce() | yes | ||
vitest/prefer-called-with | Require toHaveBeenCalledWith() instead of toHaveBeenCalled() | yes | ||
vitest/prefer-comparison-matcher | Require matchers such as toBeGreaterThan() instead of comparing inside expect() | yes | ||
vitest/prefer-describe-function-title | Require describe(fn, ...) instead of a string with the name of an imported function | yes | ||
vitest/prefer-each | Require test.each and describe.each instead of a loop around tests | |||
vitest/prefer-equality-matcher | Require toBe or toEqual instead of comparing with === inside expect | suggestion | ||
vitest/prefer-expect-assertions | Require expect.assertions() or expect.hasAssertions() at the start of every test | suggestion | ||
vitest/prefer-expect-resolves | Require await expect(promise).resolves instead of expect(await promise) | yes | ||
vitest/prefer-expect-type-of | Require toBeTypeOf instead of expect(typeof value).toBe(...) | yes | ||
vitest/prefer-hooks-in-order | Require hooks to be written in the order they run | |||
vitest/prefer-hooks-on-top | Require hooks to come before the tests in their block | |||
vitest/prefer-import-in-mock | Require import() instead of a string path in vi.mock() and vi.doMock() | yes | ||
vitest/prefer-importing-vitest-globals | Require describe, test, expect and vi to be imported from vitest | yes | ||
vitest/prefer-lowercase-title | Require the titles of tests and describe blocks to start with a lowercase letter | yes | ||
vitest/prefer-mock-promise-shorthand | Require mockResolvedValue() and mockRejectedValue() for mocks that return a promise | yes | ||
vitest/prefer-mock-return-shorthand | Require mockReturnValue() for a mock that only returns a value | yes | ||
vitest/prefer-snapshot-hint | Require a hint on toMatchSnapshot() and toThrowErrorMatchingSnapshot() | |||
vitest/prefer-spy-on | Require vi.spyOn() instead of assigning vi.fn() to a property | suggestion | ||
vitest/prefer-strict-boolean-matchers | Require toBe(true) and toBe(false) instead of toBeTruthy() and toBeFalsy() | yes | ||
vitest/prefer-strict-equal | Require toStrictEqual() instead of toEqual() | suggestion | ||
vitest/prefer-to-be | Require toBe() for primitive literals, and toBeNull(), toBeUndefined(), toBeNaN() | yes | ||
vitest/prefer-to-be-falsy | Require toBeFalsy() instead of toBe(false) | suggestion | ||
vitest/prefer-to-be-object | Require toBeObject() when expectTypeOf() checks for an object | yes | ||
vitest/prefer-to-be-truthy | Require toBeTruthy() instead of toBe(true) | suggestion | ||
vitest/prefer-to-contain | Require toContain() instead of comparing the result of includes() with a boolean | yes | ||
vitest/prefer-to-have-been-called-times | Require toHaveBeenCalledTimes() instead of checking the length of mock.calls | yes | ||
vitest/prefer-to-have-length | Require toHaveLength() instead of comparing the length property | yes | ||
vitest/prefer-todo | Require test.todo for tests that have no body yet | yes | ||
vitest/require-awaited-expect-poll | Require expect.poll and expect.element assertions to be awaited or returned | |||
vitest/require-hook | Require setup and teardown code to be inside a hook | |||
vitest/require-local-test-context-for-concurrent-snapshots | Require the expect of the test context for snapshots in concurrent tests | |||
vitest/require-mock-type-parameters | Require a type parameter on vi.fn() | |||
vitest/require-test-timeout | Require every test to set a timeout | |||
vitest/require-to-throw-message | Require toThrow() to say which error it expects | |||
vitest/require-top-level-describe | Require tests and hooks to be inside a describe block | |||
vitest/valid-describe-callback | Require describe to get a title and a callback with no parameters and no return | |||
vitest/valid-expect | Require expect to get a value, end in a called matcher, and be awaited when it is async | suggestion | ||
vitest/valid-expect-in-promise | Require a promise chain that contains expect to be awaited or returned from the test | |||
vitest/valid-title | Require test and describe titles to be non-empty strings with no stray spaces or repeated prefix | yes | ||
vitest/warn-todo | Disallow .todo on test, it and describe |
Prettier#
1 rules.
| Rule | Description | Default | Fixable | Needs types |
|---|---|---|---|---|
prettier/prettier | Require code to be formatted the way Prettier prints it | yes |