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.

RuleDescriptionDefaultFixableNeeds types
accessor-pairsRequire a getter for every setter in objects and classes
array-callback-returnRequire callbacks of array methods such as map and filter to return a valuesuggestion
arrow-body-styleEnforce one style for the braces around arrow function bodiesyes
block-scoped-varDisallow using a var outside the block it is declared in
callback-returnRequire return when calling a callback
camelcaseRequire camelCase names for variables, functions and properties
capitalized-commentsRequire comments to start with a capital letter, or forbid ityes
class-methods-use-thisRequire class methods to use this
complexityEnforce a maximum number of branches in a function
consistent-returnRequire every return in a function to have a value, or none of them
consistent-thisEnforce one name for variables that hold this
constructor-superRequire super() to be called exactly once in the constructor of a derived classerror
curlyRequire braces around the bodies of if, else and loopsyes
default-caseRequire a default case in every switch
default-case-lastRequire default to be the last clause of a switch
default-param-lastRequire parameters with a default value to come after the required ones
dot-notationRequire user.name instead of user["name"]yes
eqeqeqRequire === and !== instead of == and !=yes
for-directionRequire the update clause of a for loop to move the counter toward the end of the looperror
func-name-matchingRequire a function expression's name to match the variable or property it is assigned to
func-namesRequire or disallow names for function expressions
func-styleEnforce one way to define functions: declarations, or expressions assigned to variables
getter-returnRequire getters to return a valueerror
global-requireRequire require() calls to be at the top level of the module
grouped-accessor-pairsRequire the getter and setter of a property to be next to each other
guard-for-inRequire the body of a for...in loop to be guarded by an if
handle-callback-errRequire callbacks to use their error parameter
id-blacklistDisallow the identifier names you list (old name of id-denylist)
id-denylistDisallow the identifier names you list
id-lengthEnforce a minimum and a maximum length for identifier names
id-matchRequire identifier names to match a regular expression
init-declarationsRequire or disallow a value in variable declarations
logical-assignment-operatorsRequire or disallow the logical assignment operators ||=, &&= and ??=yes
max-classes-per-fileEnforce a maximum number of classes per file
max-depthEnforce a maximum depth that blocks can be nested
max-linesEnforce a maximum number of lines per file
max-lines-per-functionEnforce a maximum number of lines in a function
max-nested-callbacksEnforce a maximum depth that callbacks can be nested
max-paramsEnforce a maximum number of parameters in function definitions
max-statementsEnforce a maximum number of statements in a function
new-capRequire constructor names to begin with a capital letter
no-alertDisallow alert, confirm, and prompt
no-array-constructorDisallow Array constructors in favor of array literalsyes
no-async-promise-executorDisallow an async function as a Promise executorerror
no-await-in-loopDisallow await inside of loops
no-bitwiseDisallow bitwise operators
no-buffer-constructorDisallow the deprecated Buffer() constructor
no-callerDisallow arguments.caller and arguments.callee
no-case-declarationsDisallow let, const, function and class declarations directly in a case clausewarnsuggestion
no-catch-shadowDisallow a catch parameter with the name of a variable in the scope around it
no-class-assignDisallow assigning to the name of a classerror
no-compare-neg-zeroDisallow comparing against -0errorsuggestion
no-cond-assignDisallow assignments in the test of if, loops and ? :warn
no-consoleDisallow the use of consolesuggestion
no-const-assignDisallow reassigning const, using and await using variableserror
no-constant-binary-expressionDisallow comparisons and &&, ||, ?? that always give the same resulterror
no-constant-conditionDisallow conditions that are always truthy or always falsywarn
no-constructor-returnDisallow returning a value from a constructor
no-continueDisallow continue statements
no-control-regexDisallow control characters in regular expressionswarn
no-debuggerDisallow debugger statementserror
no-delete-varDisallow delete on variableswarn
no-div-regexDisallow regular expressions that start with =yes
no-dupe-argsDisallow two parameters with the same name in a functionerror
no-dupe-class-membersDisallow two class members with the same nameerror
no-dupe-else-ifDisallow an else if with a condition that an earlier branch already coverserror
no-dupe-keysDisallow two keys with the same name in an object literalerror
no-duplicate-caseDisallow two case labels with the same test in a switcherror
no-duplicate-importsDisallow importing from the same module more than once in a file
no-else-returnDisallow else after an if branch that always returnsyes
no-emptyDisallow empty block statementswarnsuggestion
no-empty-character-classDisallow empty character classes [] in regular expressionswarn
no-empty-functionDisallow functions with an empty bodysuggestion
no-empty-patternDisallow destructuring patterns that bind nothingwarn
no-empty-static-blockDisallow empty static {} blocks in classeswarnsuggestion
no-eq-nullDisallow comparing with null using == or !=
no-evalDisallow eval()
no-ex-assignDisallow assigning to the error parameter of a catch clausewarn
no-extend-nativeDisallow adding properties to the prototypes of built-in objects
no-extra-bindDisallow .bind() on functions that do not use thisyes
no-extra-boolean-castDisallow !! and Boolean() where the value is converted to a boolean anywaywarnyes
no-extra-labelDisallow labels on break and continue that name the innermost loop or switchyes
no-fallthroughDisallow case clauses that run on into the next oneerror
no-func-assignDisallow assigning to the name of a function declarationerror
no-global-assignDisallow assigning to built-in and other read-only global variableswarn
no-implicit-coercionRequire Boolean(), Number() and String() instead of operator tricks like !!x and +xyes
no-implicit-globalsDisallow declarations and assignments that create global variables by accident
no-implied-evalDisallow passing a string of code to setTimeout(), setInterval() or execScript()
no-import-assignDisallow assigning to imported bindingserror
no-inline-commentsDisallow comments on the same line as code
no-inner-declarationsDisallow function and, optionally, var declarations in nested blocks
no-invalid-regexpDisallow invalid patterns and flags in RegExp() and new RegExp()error
no-invalid-thisDisallow this where its value is undefined
no-irregular-whitespaceDisallow whitespace characters other than the ordinary space, tab and line breakerror
no-iteratorDisallow the __iterator__ property
no-label-varDisallow labels that share a name with a variable
no-labelsDisallow labeled statements
no-lone-blocksDisallow blocks that do nothing
no-lonely-ifRequire else if instead of an if alone in an else blockyes
no-loop-funcDisallow functions in loops that use a variable the loop changes
no-loss-of-precisionDisallow number literals that cannot be stored exactly as writtenerror
no-magic-numbersRequire numbers to be given a name instead of being used directly
no-misleading-character-classDisallow characters made of several code points inside a regular expression character classerrorsuggestion
no-mixed-requiresDisallow require calls mixed with other variables in one declaration
no-multi-assignDisallow chained assignments such as a = b = c
no-multi-strDisallow strings that continue on the next line with a backslash
no-native-reassignDisallow assignments to built-in and other read-only global variables
no-negated-conditionDisallow negated conditions in if/else and in ternaries
no-negated-in-lhsDisallow negating the left operand of in
no-nested-ternaryDisallow a ternary inside the branch of another ternary
no-newDisallow new when the created object is thrown away
no-new-funcDisallow creating functions from strings with Function
no-new-native-nonconstructorDisallow new Symbol() and new BigInt()error
no-new-objectDisallow new Object() in favor of {}
no-new-requireDisallow new require(..)
no-new-symbolDisallow new Symbol()
no-new-wrappersDisallow new String(), new Number() and new Boolean()
no-nonoctal-decimal-escapeDisallow the \8 and \9 escapes in stringswarnsuggestion
no-obj-callsDisallow calling Math, JSON, Reflect, Atomics, Intl and Temporal as functionserror
no-object-constructorDisallow Object() and new Object() without an argumentsuggestion
no-octalDisallow number literals that start with 0 followed by a digitwarn
no-octal-escapeDisallow octal escape sequences such as \251 in strings
no-param-reassignDisallow assigning to function parameters
no-path-concatDisallow building paths with + from __dirname or __filename
no-plusplusDisallow the ++ and -- operators
no-process-envDisallow process.env
no-process-exitDisallow calls to process.exit()
no-promise-executor-returnDisallow returning a value from the function passed to new Promisesuggestion
no-protoDisallow the __proto__ property
no-prototype-builtinsDisallow calling hasOwnProperty and other Object.prototype methods on the object itselfwarnsuggestion
no-redeclareDisallow declaring the same variable twice in one scopewarn
no-regex-spacesDisallow several spaces in a row in a regular expressionwarnyes
no-restricted-exportsDisallow the export names you list, or default exports
no-restricted-globalsDisallow the global variables you list
no-restricted-importsDisallow importing the modules, or the names from them, that you list
no-restricted-modulesDisallow loading the modules you list with require()
no-restricted-propertiesDisallow the object properties you list
no-restricted-syntaxDisallow the syntax you describe with selectors
no-return-assignDisallow assignments in return statements
no-return-awaitDisallow return await where the await changes nothing for the callersuggestion
no-script-urlDisallow javascript: URLs
no-self-assignDisallow assigning a variable or a property to itselfwarn
no-self-compareDisallow comparing a value with itself
no-sequencesDisallow the comma operator
no-setter-returnDisallow returning a value from a setterwarn
no-shadowDisallow a variable with the same name as one in an outer scope
no-shadow-restricted-namesDisallow variables named undefined, NaN, Infinity, eval, arguments or globalThiswarn
no-sparse-arraysDisallow array literals with holeserror
no-syncDisallow methods with a name that ends in Sync
no-template-curly-in-stringDisallow ${} placeholders in strings with ordinary quotes
no-ternaryDisallow the ? : operator
no-this-before-superDisallow this and super.x before super() in a constructorerror
no-throw-literalRequire throw to be given something that can be an Error
no-unassigned-varsDisallow let and var variables that are read but never assignedwarn
no-undefDisallow variables that are not declared anywhereerror
no-undef-initDisallow initializing a variable to undefinedyes
no-undefinedDisallow the use of undefined as a variable
no-underscore-dangleDisallow names that start or end with an underscore
no-unexpected-multilineDisallow lines that look like a new statement but continue the previous oneerror
no-unmodified-loop-conditionDisallow loop conditions that test variables the loop never changes
no-unneeded-ternaryDisallow ? : where the condition alone says the sameyes
no-unreachableDisallow code after return, throw, break, and continue that can never runwarn
no-unreachable-loopDisallow loops with a body that can only run once
no-unsafe-finallyDisallow return, throw, break, and continue in finally blockserror
no-unsafe-negationDisallow negating the left operand of in and instanceoferrorsuggestion
no-unsafe-optional-chainingDisallow optional chaining where undefined throws an errorerror
no-unused-expressionsDisallow statements that compute a value and throw it away
no-unused-labelsDisallow labels that no break or continue refers towarnyes
no-unused-private-class-membersDisallow #private class members that are never usedwarnsuggestion
no-unused-varsDisallow variables, functions, imports, and parameters that are never usedwarnsuggestion
no-use-before-defineDisallow using a variable, function, or class above the line that declares it
no-useless-assignmentDisallow assigning a value to a variable that is never read afterwardswarn
no-useless-backreferenceDisallow regular expression backreferences that always match the empty stringwarn
no-useless-callDisallow .call() and .apply() where a normal call does the same
no-useless-catchDisallow catch clauses that only rethrow the errorwarn
no-useless-computed-keyDisallow brackets around a property key that is a plain string or numberyes
no-useless-concatDisallow joining two string literals with + on the same line
no-useless-constructorDisallow constructors that do what the default constructor doessuggestion
no-useless-escapeDisallow backslashes that do not change the meaning of a string or regular expressionwarnsuggestion
no-useless-renameDisallow renaming an import, export, or destructured value to the same nameyes
no-useless-returnDisallow a return without a value where the function ends anywayyes
no-varRequire let or const instead of varwarnyes
no-voidDisallow the void operator
no-warning-commentsDisallow comments that start with TODO, FIXME, or another term you choose
no-withDisallow with statementswarn
object-shorthandRequire or disallow the short forms { name } and { save() {} } in object literalsyes
one-varRequire variables to be declared in one statement, or in one statement eachyes
operator-assignmentRequire or disallow shorthand assignment operators such as +=yes
prefer-arrow-callbackRequire arrow functions for callbacksyes
prefer-constRequire const for variables that are never reassignedwarnyes
prefer-destructuringRequire destructuring to read a property or an element into a variableyes
prefer-exponentiation-operatorRequire the ** operator instead of Math.pow()yes
prefer-named-capture-groupRequire capture groups in regular expressions to have a namesuggestion
prefer-numeric-literalsRequire binary, octal and hexadecimal literals instead of parseInt() on a fixed stringyes
prefer-object-has-ownRequire Object.hasOwn() instead of Object.prototype.hasOwnProperty.call()yes
prefer-object-spreadRequire object spread instead of Object.assign() into a new objectyes
prefer-promise-reject-errorsRequire an Error object as the reason of a promise rejection
prefer-reflectRequire Reflect methods instead of their older Object and Function forms
prefer-regex-literalsRequire regular expression literals instead of RegExp() with a fixed patternsuggestion
prefer-rest-paramsRequire rest parameters instead of argumentswarn
prefer-spreadRequire spread syntax instead of .apply() to pass an array as argumentswarn
prefer-templateRequire template literals instead of string concatenationyes
preserve-caught-errorRequire the caught error as the cause of a new error thrown in catchwarnsuggestion
radixRequire the radix argument of parseInt()suggestion
require-atomic-updatesDisallow assignments that use a value read before an await or a yield
require-awaitDisallow async functions that never use awaitsuggestion
require-unicode-regexpRequire the u or v flag on regular expressionssuggestion
require-yieldRequire generator functions to contain yieldwarn
sort-importsEnforce sorted import declarations and sorted names inside themyes
sort-keysRequire the keys of object literals to be sorted
sort-varsRequire the variables of one declaration to be sortedyes
strictRequire or disallow "use strict" directivesyes
symbol-descriptionRequire a description when creating a Symbol
unicode-bomRequire or disallow a Unicode byte order mark at the start of a fileyes
use-isnanRequire Number.isNaN() instead of a comparison with NaNerrorsuggestion
valid-typeofRequire typeof to be compared with a valid type nameerrorsuggestion
vars-on-topRequire var declarations at the top of their function or file
yodaRequire or disallow comparisons with the literal on the leftyes

typescript-eslint#

137 rules.

RuleDescriptionDefaultFixableNeeds types
@typescript-eslint/adjacent-overload-signaturesRequire the overloads of a function to be next to each other
@typescript-eslint/array-typeRequire either T[] or Array<T> for array types, consistentlyyes
@typescript-eslint/await-thenableDisallow await on a value that is not a promisesuggestionyes
@typescript-eslint/ban-ts-commentDisallow @ts-ignore and @ts-nocheck, and require a reason after @ts-expect-errorwarnsuggestion
@typescript-eslint/ban-tslint-commentDisallow // tslint:disable and // tslint:enable commentsyes
@typescript-eslint/ban-typesDisallow String, Number, Object, Function, {} and similar types
@typescript-eslint/class-literal-property-styleRequire constants on a class to be all readonly fields or all getterssuggestion
@typescript-eslint/class-methods-use-thisRequire class methods to use this
@typescript-eslint/consistent-generic-constructorsRequire type arguments on the constructor call or on the type annotation, consistentlyyes
@typescript-eslint/consistent-indexed-object-styleRequire either Record<K, V> or an index signature, consistentlyyes
@typescript-eslint/consistent-returnRequire every return in a function to return a value, or none of themyes
@typescript-eslint/consistent-type-assertionsRequire one style of type assertion: value as T, <T>value, or noneyes
@typescript-eslint/consistent-type-definitionsRequire either interface or type for object types, consistentlyyes
@typescript-eslint/consistent-type-exportsRequire export type for exports that are only typesyesyes
@typescript-eslint/consistent-type-importsRequire import type for imports that are only used as typesyes
@typescript-eslint/default-param-lastRequire parameters with a default value, and optional parameters, to come last
@typescript-eslint/dot-notationRequire user.name instead of user["name"]yesyes
@typescript-eslint/explicit-function-return-typeRequire a return type on functions and class methods
@typescript-eslint/explicit-member-accessibilityRequire public, private or protected on class membersyes
@typescript-eslint/explicit-module-boundary-typesRequire parameter and return types on exported functions and the methods of exported classes
@typescript-eslint/init-declarationsRequire or disallow a value in variable declarations
@typescript-eslint/max-paramsEnforce a maximum number of parameters in function definitions
@typescript-eslint/member-orderingRequire a consistent order for the members of classes, interfaces and type literals
@typescript-eslint/method-signature-styleEnforce one way to write a method in an interface or type literalyes
@typescript-eslint/naming-conventionEnforce naming conventions for variables, functions, types, members and imports
@typescript-eslint/no-array-constructorDisallow Array() and new Array() in favor of array literalswarnyes
@typescript-eslint/no-array-deleteDisallow delete on an element of an arraysuggestionyes
@typescript-eslint/no-base-to-stringDisallow turning an object into a string when the result is [object Object]yes
@typescript-eslint/no-confusing-non-null-assertionDisallow a non-null assertion ! right before =, ==, ===, in or instanceofsuggestion
@typescript-eslint/no-confusing-void-expressionRequire expressions of type void to stand alone as statementsyesyes
@typescript-eslint/no-deprecatedDisallow using code marked as @deprecatedyes
@typescript-eslint/no-dupe-class-membersDisallow two class members with the same name
@typescript-eslint/no-duplicate-enum-valuesDisallow two enum members with the same valuewarn
@typescript-eslint/no-duplicate-type-constituentsDisallow the same type twice in a union or intersectionyesyes
@typescript-eslint/no-dynamic-deleteDisallow delete with a computed property key
@typescript-eslint/no-empty-functionDisallow functions with an empty bodysuggestion
@typescript-eslint/no-empty-interfaceDisallow interfaces that declare no membersyes
@typescript-eslint/no-empty-object-typeDisallow the {} type and empty interfaceswarnsuggestion
@typescript-eslint/no-explicit-anyDisallow the any typewarnyes
@typescript-eslint/no-extra-non-null-assertionDisallow a non-null assertion that has no effectwarnyes
@typescript-eslint/no-extraneous-classDisallow classes that are empty, only static, or only a constructor
@typescript-eslint/no-floating-promisesRequire promises to be awaited, returned, or handledsuggestionyes
@typescript-eslint/no-for-in-arrayDisallow for...in over an arrayyes
@typescript-eslint/no-generated-empty-object-typeDisallow type operations that produce the {} typeyes
@typescript-eslint/no-implied-evalDisallow passing code as a string to setTimeout, setInterval and new Functionyes
@typescript-eslint/no-import-type-side-effectsRequire import type when every name in an import is marked typeyes
@typescript-eslint/no-inferrable-typesDisallow type annotations that repeat what the initial value already saysyes
@typescript-eslint/no-invalid-thisDisallow this where its value is undefined
@typescript-eslint/no-invalid-void-typeDisallow void outside of return types and generic type arguments
@typescript-eslint/no-loop-funcDisallow functions in loops that use a variable the loop changes
@typescript-eslint/no-loss-of-precisionDisallow number literals that cannot be stored exactly as written
@typescript-eslint/no-magic-numbersDisallow numbers that are used without a name
@typescript-eslint/no-meaningless-void-operatorDisallow void in front of an expression that has no value to discardyesyes
@typescript-eslint/no-misused-newDisallow new in a class and constructor in an interfaceerror
@typescript-eslint/no-misused-promisesDisallow promises where the code around them cannot handle oneyes
@typescript-eslint/no-misused-spreadDisallow ... on values that do not spread the way they looksuggestionyes
@typescript-eslint/no-mixed-enumsDisallow enums that have both number and string membersyes
@typescript-eslint/no-namespaceDisallow TypeScript namespace and module blockswarn
@typescript-eslint/no-non-null-asserted-nullish-coalescingDisallow ! on the left side of ??suggestion
@typescript-eslint/no-non-null-asserted-optional-chainDisallow ! after an optional chainwarnsuggestion
@typescript-eslint/no-non-null-assertionDisallow the non-null assertion value!suggestion
@typescript-eslint/no-redeclareDisallow declaring the same name twice in one scope
@typescript-eslint/no-redundant-type-constituentsDisallow members of unions and intersections that change nothing or swallow the restyes
@typescript-eslint/no-require-importsDisallow require() in favor of import
@typescript-eslint/no-restricted-importsDisallow imports of the modules you list, with an exception for type imports
@typescript-eslint/no-restricted-typesDisallow the types you listyes
@typescript-eslint/no-shadowDisallow a declaration that hides one with the same name in an outer scope
@typescript-eslint/no-this-aliasDisallow storing this in a variablewarn
@typescript-eslint/no-type-aliasDisallow type aliases, or allow only some kinds of them
@typescript-eslint/no-unnecessary-boolean-literal-compareDisallow comparing a boolean with true or falseyesyes
@typescript-eslint/no-unnecessary-conditionDisallow conditions that the types say are always true or always falsesuggestionyes
@typescript-eslint/no-unnecessary-parameter-property-assignmentDisallow assigning a constructor parameter property to itself
@typescript-eslint/no-unnecessary-qualifierDisallow naming the enclosing namespace or enum where the short name worksyesyes
@typescript-eslint/no-unnecessary-template-expressionDisallow ${} in a template literal where plain text or the value itself does the sameyesyes
@typescript-eslint/no-unnecessary-type-argumentsDisallow a type argument that is the same as the default of its type parameteryesyes
@typescript-eslint/no-unnecessary-type-assertionDisallow as, <T> and ! assertions that do not change the typeyesyes
@typescript-eslint/no-unnecessary-type-constraintDisallow extends any and extends unknown on a type parameterwarnsuggestion
@typescript-eslint/no-unnecessary-type-conversionDisallow converting a value to the type it already hassuggestionyes
@typescript-eslint/no-unnecessary-type-parametersDisallow a type parameter that is used only once in a signaturesuggestionyes
@typescript-eslint/no-unsafe-argumentDisallow passing a value of type any as an argumentyes
@typescript-eslint/no-unsafe-assignmentDisallow assigning a value of type any to a variable or a propertyyes
@typescript-eslint/no-unsafe-callDisallow calling a value of type anyyes
@typescript-eslint/no-unsafe-declaration-mergingDisallow a class and an interface with the same namewarn
@typescript-eslint/no-unsafe-enum-assignmentDisallow giving a plain number or string to a place typed as an enumyes
@typescript-eslint/no-unsafe-enum-comparisonDisallow comparing an enum value with a plain number or stringsuggestionyes
@typescript-eslint/no-unsafe-function-typeDisallow the built-in Function typewarn
@typescript-eslint/no-unsafe-member-accessDisallow reading a property of a value of type anyyes
@typescript-eslint/no-unsafe-returnDisallow returning a value of type any from a functionyes
@typescript-eslint/no-unsafe-type-assertionDisallow type assertions that narrow a typeyes
@typescript-eslint/no-unsafe-unary-minusRequire the operand of unary - to be a number or a bigintyes
@typescript-eslint/no-unused-expressionsDisallow statements that compute a value and do nothing with itwarn
@typescript-eslint/no-unused-private-class-membersDisallow private class members that are never used
@typescript-eslint/no-unused-varsDisallow variables, functions, parameters, imports, and types that are never usedwarnyes
@typescript-eslint/no-use-before-defineDisallow using a variable, function, class, enum, or type above the line that declares it
@typescript-eslint/no-useless-constructorDisallow constructors that do what the default constructor doessuggestion
@typescript-eslint/no-useless-default-assignmentDisallow default values that can never be usedsuggestionyes
@typescript-eslint/no-useless-empty-exportDisallow export {} in a file that is already a moduleyes
@typescript-eslint/no-var-requiresDisallow const x = require() in favor of import
@typescript-eslint/no-wrapper-object-typesDisallow String, Number, Boolean, BigInt, Symbol, and Object as typeswarnyes
@typescript-eslint/non-nullable-type-assertion-styleRequire value! instead of value as T when the assertion only removes null and undefinedyesyes
@typescript-eslint/only-throw-errorDisallow throwing values that are not Error objectsyes
@typescript-eslint/parameter-propertiesRequire or disallow parameter properties in class constructors
@typescript-eslint/prefer-as-constRequire as const instead of repeating a literal as its own typewarnyes
@typescript-eslint/prefer-destructuringRequire destructuring to read a property or an element into a variableyesyes
@typescript-eslint/prefer-enum-initializersRequire every enum member to have an explicit valuesuggestion
@typescript-eslint/prefer-findRequire .find() instead of .filter()[0] to get the first matchsuggestionyes
@typescript-eslint/prefer-for-ofRequire for...of instead of a for loop that only uses its index to read the array
@typescript-eslint/prefer-function-typeRequire a function type instead of an interface or object type with only a call signatureyes
@typescript-eslint/prefer-includesRequire .includes() instead of comparing .indexOf() with -1yesyes
@typescript-eslint/prefer-literal-enum-memberRequire enum values to be literals, not computed expressions
@typescript-eslint/prefer-namespace-keywordRequire namespace instead of module to declare a namespacewarnyes
@typescript-eslint/prefer-nullish-coalescingRequire ?? instead of || or a ternary to give a default for null or undefinedsuggestionyes
@typescript-eslint/prefer-optional-chainRequire a?.b instead of a && a.b, !a || !a.b, or (a || {}).byesyes
@typescript-eslint/prefer-promise-reject-errorsRequire an Error as the reason when a promise is rejectedyes
@typescript-eslint/prefer-readonlyRequire readonly on private members that are only assigned in the constructoryesyes
@typescript-eslint/prefer-readonly-parameter-typesRequire the types of function parameters to be read-onlyyes
@typescript-eslint/prefer-reduce-type-parameterRequire a type argument on reduce instead of a type assertion on the initial valueyesyes
@typescript-eslint/prefer-regexp-execRequire pattern.exec(text) instead of text.match(pattern) when there is no g flagyesyes
@typescript-eslint/prefer-return-this-typeRequire the return type this for a method that returns thisyesyes
@typescript-eslint/prefer-string-starts-ends-withRequire startsWith and endsWith instead of other ways to test the start or end of a stringyesyes
@typescript-eslint/prefer-ts-expect-errorRequire @ts-expect-error instead of @ts-ignoreyes
@typescript-eslint/promise-function-asyncRequire functions that return a promise to be asyncyesyes
@typescript-eslint/related-getter-setter-pairsRequire the type of a getter to be assignable to the type of its setteryes
@typescript-eslint/require-array-sort-compareRequire a compare function in calls to sort and toSorted on arraysyes
@typescript-eslint/require-awaitDisallow async functions that never await and do not return a promisesuggestionyes
@typescript-eslint/restrict-plus-operandsRequire both operands of + to be numbers, bigints, or stringsyes
@typescript-eslint/restrict-template-expressionsDisallow values in template literals that do not turn into a useful stringyes
@typescript-eslint/return-awaitEnforce consistent use of await when an async function returns a promiseyesyes
@typescript-eslint/sort-type-constituentsRequire the members of union and intersection types to be sortedyes
@typescript-eslint/strict-boolean-expressionsDisallow nullable numbers, strings, and booleans, any, and always-true values in conditionssuggestionyes
@typescript-eslint/strict-void-returnDisallow passing a function that returns a value where a void function is expectedsuggestionyes
@typescript-eslint/switch-exhaustiveness-checkRequire a switch on a union or an enum to have a case for every membersuggestionyes
@typescript-eslint/triple-slash-referenceDisallow /// <reference /> comments where an import does the jobwarn
@typescript-eslint/typedefRequire type annotations in the places you choose
@typescript-eslint/unbound-methodDisallow taking a method off its object without binding ityes
@typescript-eslint/unified-signaturesDisallow overloads that can be written as one signature
@typescript-eslint/use-unknown-in-catch-callback-variableRequire the parameter of a promise rejection callback to be typed unknownsuggestionyes

React#

135 rules.

RuleDescriptionDefaultFixableNeeds types
react-hooks/capitalized-callsDisallow calling a function with a capitalized name from a component or a hook
react-hooks/component-hook-factoriesDeprecated: reports nothing, and is kept so that older configs still load
react-hooks/configReport an invalid configuration of the React Compiler
react-hooks/error-boundariesDisallow JSX inside a try block, where catch cannot see rendering errors
react-hooks/exhaustive-depsRequire the dependency array of a hook to list every value its callback readswarnyes
react-hooks/exhaustive-effect-dependenciesRequire the dependency array of an effect to match what the effect readssuggestion
react-hooks/fbtReserved for problems with fbt translations in the React Compiler: reports nothing
react-hooks/gatingValidate the directive that puts a compiled component behind a feature flag
react-hooks/globalsDisallow reassigning variables declared outside a component or hook during render
react-hooks/hooksRequire hooks to be called at the top level of a component or hook, never conditionally
react-hooks/immutabilityDisallow modifying props, state, and other values that React expects to stay unchanged
react-hooks/incompatible-libraryReport calls to library APIs that the React Compiler cannot memoize safely
react-hooks/invariantReport code that makes the React Compiler fail one of its internal checks
react-hooks/memo-dependenciesRequire the dependency list of useMemo and useCallback to match what the callback readssuggestion
react-hooks/memoized-effect-dependenciesRequire the dependencies of an effect to be memoized
react-hooks/no-deriving-state-in-effectsDisallow effects that only compute state from props or other state
react-hooks/preserve-manual-memoizationDisallow useMemo and useCallback calls that React Compiler cannot keep memoized
react-hooks/purityDisallow calls such as Math.random() and Date.now() while a component renders
react-hooks/refsDisallow reading or writing ref.current while a component renders
react-hooks/rule-suppressionDisallow comments that turn off rules-of-hooks or exhaustive-deps
react-hooks/rules-of-hooksRequire hooks to be called at the top level of a component or a custom hookerror
react-hooks/set-state-in-effectDisallow calling a state setter directly in the body of an effect
react-hooks/set-state-in-renderDisallow calling a state setter unconditionally while a component renders
react-hooks/static-componentsDisallow components that are created while another component renders
react-hooks/syntaxDisallow invalid JavaScript in components and hooks, such as assigning to a constsuggestion
react-hooks/todoReport valid syntax that the React Compiler does not support yet
react-hooks/unsupported-syntaxDisallow syntax that the React Compiler cannot compile, such as eval()
react-hooks/use-memoRequire useMemo() callbacks to take no parameters, be synchronous, and not reassign outer variables
react-hooks/void-use-memoRequire useMemo() callbacks to return a value, and the value to be used
react/boolean-prop-namingEnforce a naming pattern such as isOpen or hasIcon for boolean props
react/button-has-typeRequire an explicit, valid type on every button element
react/checked-requires-onchange-or-readonlyRequire onChange or readOnly on an input that has checked
react/default-props-match-prop-typesRequire every entry of defaultProps to have a prop type that is not required
react/destructuring-assignmentEnforce one style for reading props, state, and context: destructured or notyes
react/display-nameRequire every component to have a name that React can show
react/forbid-component-propsDisallow chosen props, by default className and style, on components
react/forbid-dom-propsDisallow the props you choose on DOM elements such as div
react/forbid-elementsDisallow the elements and components you choose
react/forbid-foreign-prop-typesDisallow reading the propTypes of another component
react/forbid-prop-typesDisallow vague prop types such as any, array, and object
react/forward-ref-uses-refRequire a component wrapped in forwardRef to take a ref parametersuggestion
react/function-component-definitionEnforce one way to write function components: declaration, expression, or arrow functionyes
react/hook-use-stateRequire useState to be destructured into a [value, setValue] pairsuggestion
react/iframe-missing-sandboxRequire a valid sandbox attribute on iframe elements
react/jsx-boolean-valueEnforce one way to write boolean attributes in JSX: disabled or disabled={true}yes
react/jsx-child-element-spacingDisallow a line break between text and an inline element in JSX, where a space may be lost
react/jsx-closing-bracket-locationEnforce where the closing bracket of a multiline JSX tag goesyes
react/jsx-closing-tag-locationEnforce that the closing tag of a multiline JSX element lines up with its opening tagyes
react/jsx-curly-brace-presenceDisallow curly braces around plain strings in JSX, or require themyes
react/jsx-curly-newlineEnforce consistent line breaks inside the curly braces of JSX expressionsyes
react/jsx-curly-spacingEnforce or disallow spaces inside the curly braces of JSX attributes and childrenyes
react/jsx-equals-spacingEnforce or disallow spaces around the = of JSX attributesyes
react/jsx-filename-extensionRestrict the file extensions that may contain JSX
react/jsx-first-prop-new-lineEnforce the position of the first prop of a JSX elementyes
react/jsx-fragmentsEnforce <> or <React.Fragment> for React fragmentsyes
react/jsx-handler-namesEnforce naming conventions for event handlers and the props they are passed to
react/jsx-indentEnforce consistent indentation of JSX elements and their childrenyes
react/jsx-indent-propsEnforce consistent indentation of JSX propsyes
react/jsx-keyRequire a key prop on elements in arrays and iteratorserror
react/jsx-max-depthEnforce a maximum depth of nested JSX elements
react/jsx-max-props-per-lineEnforce a maximum number of props on one line of a JSX tagyes
react/jsx-newlineRequire or disallow an empty line between JSX elements and expressionsyes
react/jsx-no-bindDisallow .bind() and functions created during render as JSX props
react/jsx-no-comment-textnodesDisallow // and /* */ comments written as text between JSX tags
react/jsx-no-constructed-context-valuesDisallow context provider values that are created anew on every render
react/jsx-no-duplicate-propsDisallow the same prop twice on one JSX element
react/jsx-no-leaked-renderDisallow && conditions in JSX that can render 0 or NaNyes
react/jsx-no-literalsDisallow text written directly in JSX
react/jsx-no-script-urlDisallow javascript: URLs in links
react/jsx-no-target-blankRequire rel="noreferrer" on links that open in a new tabyes
react/jsx-no-undefDisallow components in JSX that are not declared or imported
react/jsx-no-useless-fragmentDisallow fragments that wrap a single child or sit directly in an HTML elementyes
react/jsx-one-expression-per-lineRequire each child of a JSX element to be on its own lineyes
react/jsx-pascal-caseRequire component names in JSX to be in PascalCase
react/jsx-props-no-multi-spacesDisallow more than one space, or an empty line, between JSX propsyes
react/jsx-props-no-spread-multiDisallow spreading the same variable twice in one JSX elementyes
react/jsx-props-no-spreadingDisallow {...props} in JSX
react/jsx-sort-default-propsRequire the keys of defaultProps to be sorted alphabetically
react/jsx-sort-propsRequire JSX props to be sorted alphabeticallyyes
react/jsx-tag-spacingEnforce spacing around the <, / and > of JSX tagsyes
react/jsx-uses-reactCount React as used in files that contain JSXerror
react/jsx-uses-varsCount a variable as used when it is the name of a JSX tag
react/jsx-wrap-multilinesRequire parentheses around JSX that spans several linesyes
react/no-access-state-in-setstateDisallow reading this.state in the argument of this.setState()
react/no-adjacent-inline-elementsDisallow inline elements that touch each other without whitespace between them
react/no-array-index-keyDisallow the index of an array item as its key
react/no-arrow-function-lifecycleDisallow arrow functions in class fields as React lifecycle methodsyes
react/no-children-propDisallow passing children as a prop
react/no-clone-elementDisallow React.cloneElement
react/no-dangerDisallow the dangerouslySetInnerHTML prop
react/no-danger-with-childrenDisallow dangerouslySetInnerHTML on an element that also has children
react/no-deprecatedDisallow React APIs that are deprecated
react/no-did-mount-set-stateDisallow this.setState() in componentDidMount
react/no-did-update-set-stateDisallow this.setState() in componentDidUpdate
react/no-direct-mutation-stateDisallow assigning to this.state outside of the constructor
react/no-find-dom-nodeDisallow findDOMNode
react/no-invalid-html-attributeDisallow values of the rel attribute that HTML does not definesuggestion
react/no-is-mountedDisallow this.isMounted()
react/no-multi-compDisallow more than one React component in a file
react/no-namespaceDisallow namespaced element names such as <svg:circle>
react/no-object-type-as-default-propDisallow objects, arrays, and functions as default values of destructured props
react/no-react-childrenDisallow the React.Children methods
react/no-redundant-should-component-updateDisallow shouldComponentUpdate in a class that extends React.PureComponent
react/no-render-return-valueDisallow using the return value of ReactDOM.render
react/no-set-stateDisallow this.setState in class components
react/no-string-refsDisallow strings as the value of the ref attribute
react/no-this-in-sfcDisallow this in function components
react/no-typosDisallow misspelled lifecycle methods, static properties, and prop types
react/no-unescaped-entitiesDisallow " and ' as plain characters in JSX textsuggestion
react/no-unknown-propertyDisallow attributes on DOM elements that React does not knowyes
react/no-unsafeDisallow the UNSAFE_ lifecycle methods of class components
react/no-unstable-nested-componentsDisallow defining a component inside another component
react/no-unused-class-component-methodsDisallow methods and properties of a class component that the class never uses
react/no-unused-prop-typesDisallow props that are declared but never used in the component
react/no-unused-stateDisallow fields of a class component's state that are never read
react/no-will-update-set-stateDisallow this.setState in componentWillUpdate
react/only-export-componentsRequire files with components to export only components, so Fast Refresh works
react/prefer-es6-classEnforce one way to write class components: class or createReactClass
react/prefer-exact-propsRequire propTypes to be wrapped in a function that rejects unknown props
react/prefer-function-componentRequire function components instead of class components
react/prefer-read-only-propsRequire the props in a component's type to be readonlyyes
react/prefer-stateless-functionRequire class components that only render from props to be functions
react/prop-typesRequire every prop that a component uses to be declared
react/react-in-jsx-scopeRequire React to be in scope in files that use JSX
react/require-default-propsRequire a default value for every prop that is not required
react/require-optimizationRequire class components to define shouldComponentUpdate or extend PureComponent
react/require-render-returnRequire the render method of a class component to return something
react/self-closing-compRequire elements without children to be self-closingyes
react/sort-compEnforce the order of methods and properties in a class component
react/sort-default-propsRequire the keys of defaultProps to be sorted alphabetically
react/sort-prop-typesRequire the keys of propTypes to be sorted alphabeticallyyes
react/state-in-constructorEnforce where a class component sets its initial state: in the constructor or in a class field
react/static-property-placementEnforce where a class component declares propTypes, defaultProps and other static properties
react/style-prop-objectRequire the value of the style prop to be an object
react/void-dom-elements-no-childrenDisallow children on void DOM elements such as <img /> and <br />

React performance#

4 rules.

RuleDescriptionDefaultFixableNeeds types
react-perf/jsx-no-jsx-as-propDisallow JSX elements created during render as the value of a JSX prop
react-perf/jsx-no-new-array-as-propDisallow arrays created during render as the value of a JSX prop
react-perf/jsx-no-new-function-as-propDisallow functions created during render as the value of a JSX prop
react-perf/jsx-no-new-object-as-propDisallow objects created during render as the value of a JSX prop

Accessibility (jsx-a11y)#

36 rules.

RuleDescriptionDefaultFixableNeeds types
jsx-a11y/alt-textRequire alternative text on img, area, object and input type="image"
jsx-a11y/anchor-ambiguous-textDisallow link text such as "click here" that says nothing about the target
jsx-a11y/anchor-has-contentRequire links to have content that a screen reader can readyes
jsx-a11y/anchor-is-validRequire links to have a real href, and buttons to be button elements
jsx-a11y/aria-activedescendant-has-tabindexRequire elements with aria-activedescendant to be focusable
jsx-a11y/aria-propsDisallow aria-* attributes that do not existyes
jsx-a11y/aria-proptypesRequire aria-* attributes to have a value of the right kind
jsx-a11y/aria-roleRequire role to be a real ARIA role that is not abstract
jsx-a11y/aria-unsupported-elementsDisallow role and aria-* attributes on elements that do not support themyes
jsx-a11y/autocomplete-validRequire autoComplete on an input to be a value that browsers know
jsx-a11y/click-events-have-key-eventsRequire a keyboard handler next to onClick on elements that are not controls
jsx-a11y/control-has-associated-labelRequire buttons, links and other controls to have a text label
jsx-a11y/heading-has-contentRequire headings to have content that a screen reader can read
jsx-a11y/html-has-langRequire a lang attribute on the html element
jsx-a11y/iframe-has-titleRequire a title on iframe elements
jsx-a11y/img-redundant-altDisallow the words "image", "photo" and "picture" in alt text
jsx-a11y/interactive-supports-focusRequire elements with an interactive role and an event handler to be focusablesuggestion
jsx-a11y/label-has-associated-controlRequire every <label> to have text and a form control it belongs to
jsx-a11y/langRequire the lang attribute of <html> to be a valid language tag
jsx-a11y/media-has-captionRequire <audio> and <video> to have a <track> with captions
jsx-a11y/mouse-events-have-key-eventsRequire onFocus with onMouseOver and onBlur with onMouseOut
jsx-a11y/no-access-keyDisallow the accessKey attributesuggestion
jsx-a11y/no-aria-hidden-on-focusableDisallow aria-hidden="true" on elements that can receive focusyes
jsx-a11y/no-autofocusDisallow the autoFocus attributesuggestion
jsx-a11y/no-distracting-elementsDisallow <marquee> and <blink>
jsx-a11y/no-interactive-element-to-noninteractive-roleDisallow non-interactive ARIA roles on interactive elements
jsx-a11y/no-noninteractive-element-interactionsDisallow mouse and keyboard handlers on non-interactive elements
jsx-a11y/no-noninteractive-element-to-interactive-roleDisallow interactive ARIA roles on non-interactive elements
jsx-a11y/no-noninteractive-tabindexDisallow tabIndex of 0 or more on non-interactive elements
jsx-a11y/no-redundant-rolesDisallow a role that the element already hasyes
jsx-a11y/no-static-element-interactionsRequire a role on <div>, <span> and similar elements that have event handlers
jsx-a11y/prefer-tag-over-roleRequire the HTML element instead of a role that imitates it
jsx-a11y/role-has-required-aria-propsRequire the aria-* attributes that an element's role needs
jsx-a11y/role-supports-aria-propsDisallow aria-* attributes that the element's role does not support
jsx-a11y/scopeDisallow the scope attribute on elements other than <th>yes
jsx-a11y/tabindex-no-positiveDisallow tabIndex values greater than 0suggestion

Next.js#

21 rules.

RuleDescriptionDefaultFixableNeeds types
@next/next/google-font-displayRequire a display parameter other than auto, block or fallback on Google Fonts URLs
@next/next/google-font-preconnectRequire rel="preconnect" on <link> elements that point to fonts.gstatic.com
@next/next/inline-script-idRequire an id on next/script components that have inline content
@next/next/next-script-for-gaRequire next/script instead of <script> to load Google Analytics
@next/next/no-assign-module-variableDisallow declaring a variable named module
@next/next/no-async-client-componentDisallow async components in files that start with "use client"
@next/next/no-before-interactive-script-outside-documentDisallow the beforeInteractive strategy of next/script outside pages/_document.js
@next/next/no-css-tagsDisallow <link rel="stylesheet"> for your own CSS files
@next/next/no-document-import-in-pageDisallow importing next/document outside pages/_document.js
@next/next/no-duplicate-headDisallow more than one <Head> element in a file
@next/next/no-head-elementDisallow the <head> element in favor of Head from next/head
@next/next/no-head-import-in-documentDisallow importing next/head in pages/_document.js
@next/next/no-html-link-for-pagesDisallow <a> elements that link to another page of the app
@next/next/no-img-elementDisallow the <img> element in favor of Image from next/image
@next/next/no-page-custom-fontDisallow Google Fonts <link> elements outside pages/_document.js
@next/next/no-script-component-in-headDisallow <Script> as a child of Head from next/head
@next/next/no-styled-jsx-in-documentDisallow <style jsx> in pages/_document.js
@next/next/no-sync-scriptsDisallow <script src> without async or defer
@next/next/no-title-in-document-headDisallow <title> in the Head of next/document
@next/next/no-typosDisallow misspellings of getStaticProps, getStaticPaths and getServerSidePropssuggestion
@next/next/no-unwanted-polyfillioDisallow scripts from polyfill.io, and polyfills that Next.js already ships

import#

46 rules.

RuleDescriptionDefaultFixableNeeds types
import/consistent-type-specifier-styleEnforce one way to mark type-only imports: import type { A } or import { type A }yes
import/defaultRequire a default import to match a default export in the imported file
import/dynamic-import-chunknameRequire a webpackChunkName comment in every dynamic import()suggestion
import/enforce-node-protocol-usageEnforce either node:fs or fs when importing Node.js built-in modulesyes
import/exportDisallow exporting the same name twice, and export * from a file with no named exports
import/exports-lastRequire all exports to come after every other statement in the file
import/extensionsEnforce that import paths always include the file extension, or never do
import/firstRequire all imports to come before every other statement in the fileyes
import/group-exportsRequire all named exports to be in a single export declaration
import/imports-firstRequire all imports to come before every other statement (old name of import/first)yes
import/max-dependenciesEnforce a maximum number of modules that a file can import
import/namedRequire each named import to match a named export in the imported file
import/namespaceRequire each property read from an import * as namespace to be exported by that file
import/newline-after-importRequire an empty line between the last import and the code that followsyes
import/no-absolute-pathDisallow importing a module by an absolute file system pathyes
import/no-amdDisallow AMD define() and require() calls
import/no-anonymous-default-exportDisallow default exports that have no name
import/no-commonjsDisallow require(), module.exports and exports.* in favor of import and export
import/no-cycleDisallow importing a module that imports this file back, directly or through other modules
import/no-default-exportDisallow default exports
import/no-deprecatedDisallow importing and using names that are marked @deprecated
import/no-duplicatesDisallow importing the same module more than once in a fileyes
import/no-dynamic-requireDisallow require() with an argument that is not a string literal
import/no-empty-named-blocksDisallow import {} from with nothing between the bracesyes
import/no-extraneous-dependenciesDisallow importing a package that package.json does not list
import/no-import-module-exportsDisallow import declarations in a file that exports with module.exports or exports.*yes
import/no-internal-modulesDisallow importing a file from inside another directory or package
import/no-mutable-exportsDisallow exporting a variable declared with let or var
import/no-named-as-defaultDisallow naming a default import after a named export of the same module
import/no-named-as-default-memberDisallow reading a property of a default import that is also a named export of the module
import/no-named-defaultDisallow import { default as name } in favor of import name
import/no-named-exportDisallow named exports, so that a module only has a default export
import/no-namespaceDisallow import * as name in favor of named importsyes
import/no-nodejs-modulesDisallow importing Node.js builtin modules such as fs and path
import/no-relative-packagesDisallow relative imports that reach into another packageyes
import/no-relative-parent-importsDisallow relative imports from parent directories
import/no-restricted-pathsDisallow files in one folder from importing files in another
import/no-self-importDisallow a module from importing itself
import/no-unassigned-importDisallow imports that bind no name
import/no-unresolvedRequire every import to point to a file or package that exists
import/no-unused-modulesDisallow exports that no other file imports, and files that export nothing
import/no-useless-path-segmentsDisallow path segments in imports that can be removedyes
import/no-webpack-loader-syntaxDisallow webpack loader syntax such as style-loader!./app.css in imports
import/orderEnforce a consistent order of imports, by group and optionally by nameyes
import/prefer-default-exportRequire a default export in a file that exports a single name
import/unambiguousRequire a module to have an import or export so it cannot be read as a script

unicorn#

138 rules.

RuleDescriptionDefaultFixableNeeds types
unicorn/catch-error-nameEnforce one name for the error in catch clauses and promise handlersyes
unicorn/consistent-assertRequire assert.ok(value) instead of assert(value) with node:assertyes
unicorn/consistent-date-cloneRequire new Date(date) instead of new Date(date.getTime()) to copy a dateyes
unicorn/consistent-empty-array-spreadRequire both branches of a spread ternary in an array to have the same typesuggestion
unicorn/consistent-existence-index-checkRequire === -1 and !== -1 to test the result of indexOf() and findIndex()yes
unicorn/consistent-function-scopingRequire functions that use nothing from the enclosing function to be moved out of it
unicorn/consistent-template-literal-escapeEnforce one way to escape ${ in template literalsyes
unicorn/custom-error-definitionEnforce that subclasses of Error set name and pass the message to super()
unicorn/empty-brace-spacesDisallow spaces and line breaks inside empty bracesyes
unicorn/error-messageRequire a message when creating a built-in error
unicorn/escape-caseRequire uppercase hexadecimal digits in escape sequencesyes
unicorn/explicit-length-checkRequire length and size to be compared with a numberyes
unicorn/explicit-timer-delayRequire or disallow an explicit delay for setTimeout() and setInterval()yes
unicorn/filename-caseEnforce one case style for file names
unicorn/import-styleEnforce how each module is imported: named, default, namespace, or for side effects
unicorn/max-nested-callsEnforce a maximum depth of calls nested in the arguments of other calls
unicorn/new-for-builtinsRequire new for built-in classes and disallow it for String, Number, Boolean, Symbol, BigInt
unicorn/no-abusive-eslint-disableRequire eslint-disable comments to name the rules they turn off
unicorn/no-accessor-recursionDisallow a getter or setter that uses its own property on this
unicorn/no-anonymous-default-exportRequire a name for a function or class that is the default export
unicorn/no-array-callback-referenceDisallow passing a function by name to array methods such as map and filter
unicorn/no-array-fill-with-reference-typeDisallow filling an array with one object, array, or class instance
unicorn/no-array-for-eachRequire a for...of loop instead of .forEach()
unicorn/no-array-method-this-argumentDisallow the thisArg argument of array methods such as map and filter
unicorn/no-array-reduceDisallow reduce() and reduceRight() in favor of a loop
unicorn/no-array-reverseRequire toReversed() instead of reverse(), which changes the arraysuggestion
unicorn/no-array-sortRequire toSorted() instead of sort(), which changes the arraysuggestion
unicorn/no-await-expression-memberDisallow reading a property directly from an await expressionyes
unicorn/no-await-in-promise-methodsDisallow await on the elements of the array passed to Promise.all() and similar methodssuggestion
unicorn/no-confusing-array-withDisallow a negative index and .length as the index of Array#with()
unicorn/no-console-spacesDisallow spaces at the edges of strings where console.log() already adds oneyes
unicorn/no-document-cookieDisallow assigning to document.cookie
unicorn/no-empty-fileDisallow files that contain no code
unicorn/no-hex-escapeRequire Unicode escapes such as \u001B instead of hexadecimal escapes such as \x1Byes
unicorn/no-immediate-mutationDisallow changing an array, object, Set, or Map in the statement right after creating it
unicorn/no-instanceof-arrayRequire Array.isArray() instead of instanceof Arrayyes
unicorn/no-instanceof-builtinsDisallow instanceof with built-in constructors such as Array, String, and Functionsuggestion
unicorn/no-invalid-fetch-optionsDisallow a body in fetch() and new Request() when the method is GET or HEAD
unicorn/no-invalid-remove-event-listenerDisallow passing a new function to removeEventListener()
unicorn/no-length-as-slice-endDisallow passing .length as the end argument of .slice()yes
unicorn/no-lonely-ifDisallow an if as the only statement in another if when neither has an else
unicorn/no-magic-array-flat-depthDisallow an unexplained number as the depth of .flat()
unicorn/no-negated-conditionDisallow a negated condition in an if with an else and in a ternaryyes
unicorn/no-negation-in-equality-checkDisallow ! on the left side of ===, !==, ==, and !=suggestion
unicorn/no-nested-ternaryDisallow deeply nested ternaries, and require parentheses around a ternary in a ternaryyes
unicorn/no-new-arrayDisallow new Array() with a single argumentsuggestion
unicorn/no-new-bufferRequire Buffer.from() or Buffer.alloc() instead of the deprecated new Buffer()suggestion
unicorn/no-nullDisallow the null literal in favor of undefinedyes
unicorn/no-object-as-default-parameterDisallow an object literal with properties as the default value of a parameter
unicorn/no-process-exitDisallow process.exit()
unicorn/no-single-promise-in-promise-methodsDisallow an array with one item in Promise.all(), Promise.any(), and Promise.race()yes
unicorn/no-static-only-classDisallow classes that have only static membersyes
unicorn/no-thenableDisallow a then property on objects, classes, and module exports
unicorn/no-this-assignmentDisallow assigning this to a variable
unicorn/no-typeof-undefinedRequire comparing with undefined directly instead of typeof x === "undefined"yes
unicorn/no-unnecessary-array-flat-depthDisallow passing 1 as the depth to Array#flat()suggestion
unicorn/no-unnecessary-array-splice-countDisallow .length or Infinity as the count of splice() and toSpliced()yes
unicorn/no-unnecessary-awaitDisallow await on a value that cannot be a promiseyes
unicorn/no-unnecessary-slice-endDisallow .length or Infinity as the end of slice()yes
unicorn/no-unreadable-array-destructuringDisallow array destructuring that skips two or more values in a row
unicorn/no-unreadable-iifeDisallow calling an arrow function in place when its body is in parenthesessuggestion
unicorn/no-useless-collection-argumentDisallow empty arguments and fallbacks in new Set(), Map, WeakSet, and WeakMapsuggestion
unicorn/no-useless-error-capture-stack-traceDisallow Error.captureStackTrace() in the constructor of an Error subclasssuggestion
unicorn/no-useless-fallback-in-spreadDisallow an empty object as the fallback when spreading into an object literalyes
unicorn/no-useless-iterator-to-arrayDisallow .toArray() on an iterator where the iterator itself worksyes
unicorn/no-useless-length-checkDisallow checking an array's length next to .some() or .every() where it changes nothing
unicorn/no-useless-promise-resolve-rejectDisallow returning Promise.resolve() or Promise.reject() from an async function or promise callbackyes
unicorn/no-useless-spreadDisallow spreads that only build an array or object to take it apart or copy it againyes
unicorn/no-useless-switch-caseDisallow empty case clauses that fall through to the last defaultsuggestion
unicorn/no-useless-undefinedDisallow undefined where leaving it out means the sameyes
unicorn/no-zero-fractionsDisallow numbers with a zero fraction or a dangling dotyes
unicorn/number-literal-caseRequire lowercase prefixes and exponents, and uppercase hexadecimal digits, in numbersyes
unicorn/numeric-separators-styleEnforce how digits are grouped with _ in numbersyes
unicorn/prefer-add-event-listenerRequire addEventListener() instead of assigning to on properties such as onclick
unicorn/prefer-array-findRequire .find() or .findLast() instead of taking one element from .filter()
unicorn/prefer-array-flatRequire .flat() instead of flattening an array with concat, reduce or flatMapyes
unicorn/prefer-array-flat-mapRequire one .flatMap() instead of .map().flat() or .filter().flatMap()yes
unicorn/prefer-array-index-ofRequire .indexOf() instead of .findIndex() when looking for a value
unicorn/prefer-array-someRequire .some() to test whether an array has a matching elementsuggestion
unicorn/prefer-atRequire .at() to read an element counted from the end of an array or stringyes
unicorn/prefer-bigint-literalsRequire BigInt literals such as 123n instead of BigInt(123)yes
unicorn/prefer-blob-reading-methodsRequire blob.text() and blob.arrayBuffer() instead of a FileReader
unicorn/prefer-class-fieldsRequire class fields instead of this assignments of fixed values in the constructoryes
unicorn/prefer-classlist-toggleRequire classList.toggle() instead of choosing between add() and remove()yes
unicorn/prefer-code-pointRequire codePointAt() and String.fromCodePoint() over charCodeAt() and String.fromCharCode()yes
unicorn/prefer-date-nowRequire Date.now() to get the current time in millisecondsyes
unicorn/prefer-default-parametersRequire default parameters instead of reassigning a parameter in the function bodysuggestion
unicorn/prefer-dom-node-appendRequire .append() instead of .appendChild() on DOM nodesyes
unicorn/prefer-dom-node-datasetRequire .dataset instead of the attribute methods for data-* attributesyes
unicorn/prefer-dom-node-removeRequire child.remove() instead of parent.removeChild(child)
unicorn/prefer-dom-node-text-contentRequire .textContent instead of .innerTextyes
unicorn/prefer-event-targetRequire EventTarget instead of EventEmitter
unicorn/prefer-export-fromRequire export ... from to re-export instead of an import and a separate exportsuggestion
unicorn/prefer-global-thisRequire globalThis instead of window, self and globalsuggestion
unicorn/prefer-import-meta-propertiesRequire import.meta.dirname and import.meta.filename instead of building them from the URLyes
unicorn/prefer-includesRequire .includes() instead of comparing .indexOf() with -1 or 0suggestion
unicorn/prefer-keyboard-event-keyRequire event.key instead of keyCode, charCode and whichyes
unicorn/prefer-logical-operator-over-ternaryRequire || or ?? instead of a ternary that repeats its conditionsuggestion
unicorn/prefer-math-min-maxRequire Math.min() and Math.max() instead of a ternary that picks the smaller or larger valuesuggestion
unicorn/prefer-math-truncRequire Math.trunc() instead of bitwise tricks to drop the fraction of a numbersuggestion
unicorn/prefer-modern-dom-apisRequire .before(), .after(), .append(), .prepend() and .replaceWith() over older DOM methodssuggestion
unicorn/prefer-modern-math-apisRequire Math.log10(), Math.log2(), Math.hypot() and Math.abs() over hand-written formulas
unicorn/prefer-moduleRequire ES modules instead of CommonJS
unicorn/prefer-native-coercion-functionsRequire passing String, Number, BigInt, Boolean and Symbol directly instead of wrapping them
unicorn/prefer-negative-indexRequire a negative index instead of .length - indexyes
unicorn/prefer-node-protocolRequire the node: prefix when importing Node.js built-in modulesyes
unicorn/prefer-number-coercionRequire Number() instead of parseFloat() and base-10 parseInt()suggestion
unicorn/prefer-number-propertiesRequire Number.isNaN, Number.parseInt and the like instead of the globalsyes
unicorn/prefer-object-from-entriesRequire Object.fromEntries() to turn key-value pairs into an object
unicorn/prefer-optional-catch-bindingRequire catch {} without a parameter when the error is not usedyes
unicorn/prefer-prototype-methodsRequire borrowing a method from the prototype instead of from an empty [] or {}yes
unicorn/prefer-query-selectorRequire querySelector() and querySelectorAll() instead of the getElement... methodsyes
unicorn/prefer-reflect-applyRequire Reflect.apply() instead of Function.prototype.apply()suggestion
unicorn/prefer-regexp-testRequire RegExp#test() instead of String#match() and RegExp#exec() for a yes or no answeryes
unicorn/prefer-response-static-jsonRequire Response.json() instead of new Response(JSON.stringify())suggestion
unicorn/prefer-set-hasRequire Set#has() instead of Array#includes() for an array that is only searchedyes
unicorn/prefer-set-sizeRequire Set#size instead of converting the Set to an array to read lengthyes
unicorn/prefer-single-callRequire one call instead of several in a row to push(), unshift(), classList.add() and the likeyes
unicorn/prefer-spreadRequire the spread operator instead of Array.from(), concat(), slice() and toSpliced()yes
unicorn/prefer-string-rawRequire String.raw for strings that escape backslashesyes
unicorn/prefer-string-replace-allRequire replaceAll() instead of replace() with a global regexyes
unicorn/prefer-string-sliceRequire slice() instead of substr() and substring()yes
unicorn/prefer-string-starts-ends-withRequire startsWith() and endsWith() instead of a regex with ^ or $yes
unicorn/prefer-string-trim-start-endRequire trimStart() and trimEnd() instead of trimLeft() and trimRight()yes
unicorn/prefer-structured-cloneRequire structuredClone() for deep clonessuggestion
unicorn/prefer-ternaryRequire a ternary instead of an if/else where both branches do the same kind of thing
unicorn/prefer-top-level-awaitRequire top-level await instead of promise chains and async wrappers at the top of a module
unicorn/prefer-type-errorRequire TypeError when the throw follows a type checkyes
unicorn/relative-url-styleEnforce one style for relative URLs in new URL(): with or without ./yes
unicorn/require-array-join-separatorRequire the separator argument of Array#join()yes
unicorn/require-module-attributesDisallow an empty attribute list in import, export and import()suggestion
unicorn/require-module-specifiersDisallow empty braces in import and export statementsyes
unicorn/require-number-to-fixed-digits-argumentRequire the digits argument of Number#toFixed()yes
unicorn/require-post-message-target-originRequire the targetOrigin argument of window.postMessage()suggestion
unicorn/switch-case-bracesEnforce braces, or no braces, around the body of each caseyes
unicorn/switch-case-break-positionRequire break, return, continue and throw inside the braces of a case
unicorn/text-encoding-identifier-caseEnforce one spelling for the encoding names utf8 and asciiyes
unicorn/throw-new-errorRequire new when creating an erroryes

promise#

16 rules.

RuleDescriptionDefaultFixableNeeds types
promise/always-returnRequire every then() callback to return a value or throw
promise/avoid-newDisallow creating promises with new Promise()
promise/catch-or-returnRequire a promise chain to end with catch() or to be returned
promise/no-callback-in-promiseDisallow calling a callback inside then() or catch()
promise/no-multiple-resolvedDisallow paths that call resolve or reject more than once in a new Promise() executor
promise/no-nestingDisallow then() and catch() nested inside another then() or catch()
promise/no-new-staticsDisallow new on static Promise methods such as Promise.allyes
promise/no-promise-in-callbackDisallow promises inside error-first callbacks
promise/no-return-in-finallyDisallow return in a finally() callback
promise/no-return-wrapDisallow returning Promise.resolve() or Promise.reject() from a promise callback
promise/param-namesRequire the parameters of a new Promise() executor to be named resolve and reject
promise/prefer-await-to-callbacksRequire async/await instead of error-first callbacks
promise/prefer-await-to-thenRequire await instead of then(), catch() and finally()
promise/prefer-catchRequire catch() instead of a second argument to then()
promise/spec-onlyDisallow Promise static methods that are not part of the language
promise/valid-paramsRequire the right number of arguments for Promise methods

Node.js (n)#

15 rules.

RuleDescriptionDefaultFixableNeeds types
n/callback-returnRequire a return with every call to a callback
n/exports-styleEnforce either module.exports or exports in CommonJS files
n/global-requireRequire require() calls to be at the top level of the file
n/handle-callback-errRequire callbacks to use their error parameter
n/no-exports-assignDisallow assigning to exportsyes
n/no-mixed-requiresDisallow require() calls mixed with other variables in one declaration
n/no-new-requireDisallow new require()
n/no-path-concatDisallow joining __dirname and __filename to a path with + or a template
n/no-process-envDisallow process.env
n/no-process-exitDisallow process.exit()
n/no-syncDisallow calls to functions with names that end in Sync
n/no-top-level-awaitDisallow await at the top level of a module
n/no-unsupported-features/es-builtinsDisallow JavaScript built-ins that the Node.js versions you support do not have
n/no-unsupported-features/es-syntaxDisallow JavaScript syntax that the Node.js versions you support do not have
n/no-unsupported-features/node-builtinsDisallow Node.js APIs that the Node.js versions you support do not have

oxc#

27 rules.

RuleDescriptionDefaultFixableNeeds types
oxc/approx-constantDisallow numbers that approximate a constant of the Math objectsuggestion
oxc/bad-array-method-on-argumentsDisallow calling array methods on the arguments object
oxc/bad-bitwise-operatorDisallow & and | where && and || were probably meantsuggestion
oxc/bad-char-at-comparisonDisallow comparing a single character with a longer string
oxc/bad-comparison-sequenceDisallow chained comparisons such as a < b < c
oxc/bad-match-all-argRequire the g flag on a regular expression passed to matchAll()
oxc/bad-min-max-funcDisallow Math.min and Math.max combinations that always give the same result
oxc/bad-object-literal-comparisonDisallow comparing a value with {} or []
oxc/bad-replace-all-argRequire the g flag on a regular expression passed to replaceAll()
oxc/branches-sharing-codeDisallow the same statements at the start or end of every branch of an ifsuggestion
oxc/const-comparisonsDisallow comparisons that are always true, always false, or repeated
oxc/double-comparisonsDisallow two comparisons of the same values that one operator can expresssuggestion
oxc/erasing-opDisallow operations with 0 that erase the other operandyes
oxc/misrefactored-assign-opDisallow a += a + b, where the target is repeated on the rightsuggestion
oxc/missing-throwRequire throw before a new Error() that is not usedsuggestion
oxc/no-accumulating-spreadDisallow spreading the accumulator in reduce() and in loops
oxc/no-async-awaitDisallow async functions
oxc/no-async-endpoint-handlersDisallow async functions as Express route handlers and middleware
oxc/no-barrel-fileDisallow files that load too many modules through export *
oxc/no-const-enumDisallow TypeScript const enumyes
oxc/no-map-spreadDisallow object and array spreads in the return value of map and flatMap callbackssuggestion
oxc/no-optional-chainingDisallow optional chaining (?.)
oxc/no-rest-spread-propertiesDisallow ... in object literals and object destructuring
oxc/no-this-in-exported-functionDisallow this in exported functions
oxc/number-arg-out-of-rangeDisallow out-of-range arguments to toString, toFixed, toExponential, and toPrecision
oxc/only-used-in-recursionDisallow parameters that are only passed on to the function's own recursive callsyes
oxc/uninvoked-array-callbackDisallow array methods with a callback directly on new Array(n)

Bun#

29 rules.

RuleDescriptionDefaultFixableNeeds types
bun/consistent-directive-prefixRequire comments that turn rules off to start with the same word, eslint or oxlintyes
bun/formatRequire code to be formatted the way bun fmt prints ityes
bun/jsx-no-forbidden-nestingDisallow a JSX element inside another element that cannot contain it
bun/no-array-just-to-countDisallow .split(separator).length with a one-character separatoryes
bun/no-cast-to-brandDisallow casts to a branded type outside the module that declares it
bun/no-console-window-flashRequire windowsHide for a child process that does not share a stream with its parent
bun/no-cwd-dependent-pathDisallow relative paths that depend on the directory the process was started in
bun/no-eager-dynamic-importDisallow import() that runs as soon as the module is loaded
bun/no-eager-native-addonDisallow loading a .node native addon as soon as the module is loaded
bun/no-env-at-module-scopeDisallow reading environment variables as soon as the module is loaded
bun/no-literal-temp-dirDisallow hard-coded temporary directories such as /tmp in favor of os.tmpdir()
bun/no-negative-repeat-countDisallow a repeat() count that comes from a subtraction and can be negativesuggestion
bun/no-redundant-catch-typeDisallow : unknown on the variable of a catch clauseyes
bun/no-restricted-textDisallow text that matches a pattern in strings, templates, JSX text, comments, and regular expressions
bun/no-side-effects-on-importDisallow top-level statements that call something or assign to a property
bun/no-unbounded-requestsRequire an axios request to have a timeout or a signal
bun/no-unhandled-emitter-errorsRequire an error listener on event emitters that Node.js functions return
bun/no-unportable-commandsDisallow starting a process with a command that does not work the same on every system
bun/no-unseeded-random-in-property-testDisallow Math.random() and fc.sample() inside a fast-check property
bun/no-useless-spread-fallbackDisallow an empty object as the fallback in ...(condition ? value : {})suggestion
bun/prefer-builtin-sleepPrefer Bun.sleep() to a promise that only waits for setTimeoutsuggestion
bun/prefer-lazy-schemaDisallow building a validation schema while the module loads
bun/prefer-local-moduleRequire importing a package through the module in your project that wraps ityes
bun/prefer-timeout-signalPrefer AbortSignal.timeout() to an AbortController that only a timer aborts
bun/prefer-url-for-sibling-filesPrefer new URL("./file", import.meta.url) to a path joined onto the module's directory
bun/react-no-latest-value-refDisallow a ref that is set to the latest value on every render
bun/react-no-local-render-helpersDisallow renderItem() functions that are defined inside a component and used in its JSX
bun/react-no-namespace-hooksRequire React hooks to be imported by name: useState(), not React.useState()yes
bun/react-prefer-updater-functionPrefer setItems(previous => ..) to a new array or object made from the state of the last render

bun:test#

65 rules.

RuleDescriptionDefaultFixableNeeds types
bun:test/consistent-test-filenameRequire test files to follow one naming pattern
bun:test/consistent-test-itEnforce one of test or it for defining testsyes
bun:test/expect-expectRequire every test to make at least one assertion
bun:test/max-expectsEnforce a maximum number of expect() calls in a test
bun:test/max-nested-describeEnforce a maximum depth of nested describe() calls
bun:test/no-alias-methodsDisallow matcher aliases such as toBeCalled in favor of toHaveBeenCalledyes
bun:test/no-commented-out-testsDisallow tests that are inside a comment
bun:test/no-conditional-expectDisallow expect inside if, catch and other code that only runs sometimes
bun:test/no-conditional-in-testDisallow if, switch, ? :, &&, || and ?? inside a test
bun:test/no-conditional-testsDisallow test and describe inside an if statement
bun:test/no-disabled-testsDisallow skipped tests such as test.skip, xtest and xdescribewarn
bun:test/no-done-callbackDisallow the done callback in tests and hooks in favor of promises
bun:test/no-duplicate-hooksDisallow using the same hook twice in one describe block
bun:test/no-exportDisallow exports from a file that has testswarn
bun:test/no-focused-testsDisallow test.only and describe.onlyerrorsuggestion
bun:test/no-hooksDisallow beforeAll, beforeEach, afterEach and afterAll
bun:test/no-identical-titleDisallow two tests or two describe blocks with the same title in one block
bun:test/no-interpolation-in-snapshotsDisallow ${} in inline snapshots
bun:test/no-large-snapshotsDisallow snapshots that are longer than a set number of lines
bun:test/no-restricted-jest-methodsDisallow the jest and vi methods that you list
bun:test/no-restricted-matchersDisallow the matchers and modifiers you list
bun:test/no-standalone-expectDisallow expect outside of a test or it block
bun:test/no-test-prefixesRequire .skip instead of the x prefixyes
bun:test/no-test-return-statementDisallow return expect(..) in a test
bun:test/no-unneeded-async-expect-functionDisallow an async function around a single awaited call in expectyes
bun:test/padding-around-after-all-blocksRequire a blank line before each afterAll callyes
bun:test/padding-around-test-blocksRequire a blank line before each test and it callyes
bun:test/prefer-called-onceRequire toHaveBeenCalledOnce() instead of toHaveBeenCalledTimes(1)yes
bun:test/prefer-called-timesRequire toHaveBeenCalledTimes(1) instead of toHaveBeenCalledOnce()yes
bun:test/prefer-called-withRequire toHaveBeenCalledWith() instead of toHaveBeenCalled()suggestion
bun:test/prefer-comparison-matcherRequire matchers such as toBeGreaterThan() instead of comparing inside expect()suggestion
bun:test/prefer-describe-function-titleRequire describe(fn, ...) instead of a string with the name of an imported functionsuggestion
bun:test/prefer-eachRequire test.each and describe.each instead of a loop around tests
bun:test/prefer-ending-with-an-expectRequire the last statement of a test to be an assertion
bun:test/prefer-equality-matcherRequire toBe or toEqual instead of comparing with === inside expectsuggestion
bun:test/prefer-expect-assertionsRequire expect.assertions() or expect.hasAssertions() at the start of every testsuggestion
bun:test/prefer-expect-resolvesRequire await expect(promise).resolves instead of expect(await promise)suggestion
bun:test/prefer-expect-type-ofRequire toBeTypeOf instead of expect(typeof value).toBe(...)yes
bun:test/prefer-hooks-in-orderRequire hooks to be written in the order they run
bun:test/prefer-hooks-on-topRequire hooks to come before the tests in their block
bun:test/prefer-lowercase-titleRequire the titles of tests and describe blocks to start with a lowercase letteryes
bun:test/prefer-mock-promise-shorthandRequire mockResolvedValue() and mockRejectedValue() for mocks that return a promiseyes
bun:test/prefer-mock-return-shorthandRequire mockReturnValue() for a mock that only returns a valueyes
bun:test/prefer-snapshot-hintRequire a hint on toMatchSnapshot() and toThrowErrorMatchingSnapshot()
bun:test/prefer-spy-onRequire spyOn() instead of assigning jest.fn() to a propertysuggestion
bun:test/prefer-strict-boolean-matchersRequire toBe(true) and toBe(false) instead of toBeTruthy() and toBeFalsy()suggestion
bun:test/prefer-strict-equalRequire toStrictEqual() instead of toEqual()suggestion
bun:test/prefer-to-beRequire toBe() for primitive literals, and toBeNull(), toBeUndefined(), toBeNaN()yes
bun:test/prefer-to-be-falsyRequire toBeFalsy() instead of toBe(false)suggestion
bun:test/prefer-to-be-truthyRequire toBeTruthy() instead of toBe(true)suggestion
bun:test/prefer-to-containRequire toContain() instead of comparing the result of includes() with a booleansuggestion
bun:test/prefer-to-have-been-calledRequire not.toHaveBeenCalled() instead of toHaveBeenCalledTimes(0)yes
bun:test/prefer-to-have-been-called-timesRequire toHaveBeenCalledTimes() instead of checking the length of mock.callsyes
bun:test/prefer-to-have-lengthRequire toHaveLength() instead of comparing the length propertyyes
bun:test/prefer-todoRequire test.todo for tests that have no body yetyes
bun:test/require-hookRequire setup and teardown code to be inside a hook
bun:test/require-mock-type-parametersRequire a type parameter on jest.fn() and vi.fn()
bun:test/require-test-timeoutRequire every test to set a timeout
bun:test/require-to-throw-messageRequire toThrow() to say which error it expects
bun:test/require-top-level-describeRequire tests and hooks to be inside a describe block
bun:test/valid-describe-callbackRequire describe to get a callback that is a function with no parameterserror
bun:test/valid-expectRequire expect to get a value, end in a called matcher, and be awaited when it is asyncerrorsuggestion
bun:test/valid-expect-in-promiseRequire a promise chain that contains expect to be awaited or returned from the testerror
bun:test/valid-titleRequire test and describe titles to be non-empty, with no stray spaces or repeated prefixyes
bun:test/warn-todoDisallow .todo on test, it and describe

Jest#

60 rules.

RuleDescriptionDefaultFixableNeeds types
jest/consistent-test-itEnforce one of test or it for defining testsyes
jest/expect-expectRequire every test to make at least one assertion
jest/max-expectsEnforce a maximum number of expect() calls in a test
jest/max-nested-describeEnforce a maximum depth of nested describe() calls
jest/no-alias-methodsDisallow matcher aliases such as toBeCalled in favor of toHaveBeenCalledyes
jest/no-commented-out-testsDisallow tests that are inside a comment
jest/no-conditional-expectDisallow expect inside if, catch and other code that only runs sometimes
jest/no-conditional-in-testDisallow if, switch, ? :, &&, || and ?? inside a test
jest/no-confusing-set-timeoutDisallow jest.setTimeout inside a block, after a test, or more than once in a file
jest/no-deprecated-functionsDisallow Jest functions that have been renamed or replacedyes
jest/no-disabled-testsDisallow skipped tests such as test.skip, xtest and xdescribe
jest/no-done-callbackDisallow the done callback in tests and hooks in favor of promises
jest/no-duplicate-hooksDisallow using the same hook twice in one describe block
jest/no-exportDisallow exports from a file that has tests
jest/no-focused-testsDisallow test.only, describe.only, fit and fdescribesuggestion
jest/no-hooksDisallow beforeAll, beforeEach, afterEach and afterAll
jest/no-identical-titleDisallow two tests or two describe blocks with the same title in one block
jest/no-interpolation-in-snapshotsDisallow ${} in inline snapshots
jest/no-jasmine-globalsDisallow Jasmine globals such as jasmine.any, spyOn, fail and pendingyes
jest/no-large-snapshotsDisallow snapshots that are longer than a set number of lines
jest/no-mocks-importDisallow importing from a __mocks__ directory
jest/no-restricted-jest-methodsDisallow the jest methods that you list
jest/no-restricted-matchersDisallow the matchers and modifiers you list
jest/no-standalone-expectDisallow expect outside of a test or it block
jest/no-test-prefixesRequire .only and .skip instead of the f and x prefixesyes
jest/no-test-return-statementDisallow return expect(..) in a test
jest/no-unneeded-async-expect-functionDisallow an async function around a single awaited call in expectyes
jest/no-untyped-mock-factoryRequire a type parameter on jest.mock() and jest.doMock() with a factoryyes
jest/padding-around-after-all-blocksRequire a blank line before each afterAll callyes
jest/padding-around-test-blocksRequire a blank line before each test and it callyes
jest/prefer-called-withRequire toHaveBeenCalledWith() instead of toHaveBeenCalled()yes
jest/prefer-comparison-matcherRequire matchers such as toBeGreaterThan() instead of comparing inside expect()yes
jest/prefer-eachRequire test.each and describe.each instead of a loop around tests
jest/prefer-ending-with-an-expectRequire the last statement of a test to be an assertion
jest/prefer-equality-matcherRequire toBe or toEqual instead of comparing with === inside expectsuggestion
jest/prefer-expect-assertionsRequire expect.assertions() or expect.hasAssertions() at the start of every testsuggestion
jest/prefer-expect-resolvesRequire await expect(promise).resolves instead of expect(await promise)yes
jest/prefer-hooks-in-orderRequire hooks to be written in the order they run
jest/prefer-hooks-on-topRequire hooks to come before the tests in their block
jest/prefer-importing-jest-globalsRequire describe, test, expect and jest to be imported from @jest/globalsyes
jest/prefer-jest-mockedRequire jest.mocked(fn) instead of fn as jest.Mockyes
jest/prefer-lowercase-titleRequire the titles of tests and describe blocks to start with a lowercase letteryes
jest/prefer-mock-promise-shorthandRequire mockResolvedValue() and mockRejectedValue() for mocks that return a promiseyes
jest/prefer-mock-return-shorthandRequire mockReturnValue() for a mock that only returns a valueyes
jest/prefer-snapshot-hintRequire a hint on toMatchSnapshot() and toThrowErrorMatchingSnapshot()
jest/prefer-spy-onRequire jest.spyOn() instead of assigning jest.fn() to a propertysuggestion
jest/prefer-strict-equalRequire toStrictEqual() instead of toEqual()suggestion
jest/prefer-to-beRequire toBe() for primitive literals, and toBeNull(), toBeUndefined(), toBeNaN()yes
jest/prefer-to-containRequire toContain() instead of comparing the result of includes() with a booleanyes
jest/prefer-to-have-been-calledRequire not.toHaveBeenCalled() instead of toHaveBeenCalledTimes(0)yes
jest/prefer-to-have-been-called-timesRequire toHaveBeenCalledTimes() instead of checking the length of mock.callsyes
jest/prefer-to-have-lengthRequire toHaveLength() instead of comparing the length propertyyes
jest/prefer-todoRequire test.todo for tests that have no body yetyes
jest/require-hookRequire setup and teardown code to be inside a hook
jest/require-to-throw-messageRequire toThrow() to say which error it expects
jest/require-top-level-describeRequire tests and hooks to be inside a describe block
jest/valid-describe-callbackRequire describe to get a title and a plain synchronous callback
jest/valid-expectRequire expect to get a value, end in a called matcher, and be awaited when it is asyncsuggestion
jest/valid-expect-in-promiseRequire a promise chain that contains expect to be awaited or returned from the test
jest/valid-titleRequire test and describe titles to be non-empty strings with no stray spaces or repeated prefixyes

Vitest#

73 rules.

RuleDescriptionDefaultFixableNeeds types
vitest/consistent-each-forEnforce either .each or .for for parameterized tests
vitest/consistent-test-filenameRequire test files to follow one naming pattern
vitest/consistent-test-itEnforce one of test or it for defining testsyes
vitest/consistent-vitest-viEnforce one of vi or vitest for Vitest's helper objectyes
vitest/expect-expectRequire every test to make at least one assertion
vitest/hoisted-apis-on-topRequire vi.mock, vi.unmock and vi.hoisted at the top level of the filesuggestion
vitest/max-expectsEnforce a maximum number of expect() calls in a test
vitest/max-nested-describeEnforce a maximum depth of nested describe() calls
vitest/no-alias-methodsDisallow matcher aliases such as toBeCalled in favor of toHaveBeenCalledyes
vitest/no-commented-out-testsDisallow tests that are inside a comment
vitest/no-conditional-expectDisallow expect inside if, catch and other code that only runs sometimes
vitest/no-conditional-in-testDisallow if, switch, ? :, &&, || and ?? inside a test
vitest/no-conditional-testsDisallow test and describe inside an if statement
vitest/no-disabled-testsDisallow skipped tests such as test.skip and describe.skip
vitest/no-duplicate-hooksDisallow using the same hook twice in one describe block
vitest/no-focused-testsDisallow test.only and describe.onlysuggestion
vitest/no-hooksDisallow beforeAll, beforeEach, afterEach and afterAll
vitest/no-identical-titleDisallow two tests or two describe blocks with the same title in one block
vitest/no-import-node-testDisallow importing from node:test in a project that uses Vitestsuggestion
vitest/no-importing-vitest-globalsDisallow importing test, expect, vi and the other Vitest globalsyes
vitest/no-interpolation-in-snapshotsDisallow ${} in inline snapshots
vitest/no-large-snapshotsDisallow snapshots that are longer than a set number of lines
vitest/no-mocks-importDisallow importing from a __mocks__ directory
vitest/no-restricted-matchersDisallow the matchers and modifiers you list
vitest/no-restricted-vi-methodsDisallow the vi methods you list
vitest/no-standalone-expectDisallow expect outside of a test or it block
vitest/no-test-prefixesRequire .only and .skip instead of the f and x prefixesyes
vitest/no-test-return-statementDisallow return expect(..) in a test
vitest/no-unneeded-async-expect-functionDisallow an async function around a single awaited call in expectyes
vitest/padding-around-after-all-blocksRequire a blank line before each afterAll callyes
vitest/padding-around-test-blocksRequire a blank line before each test and it callyes
vitest/prefer-called-exactly-once-withRequire toHaveBeenCalledExactlyOnceWith() over separate call count and argument checksyes
vitest/prefer-called-onceRequire toHaveBeenCalledOnce() instead of toHaveBeenCalledTimes(1)yes
vitest/prefer-called-timesRequire toHaveBeenCalledTimes(1) instead of toHaveBeenCalledOnce()yes
vitest/prefer-called-withRequire toHaveBeenCalledWith() instead of toHaveBeenCalled()yes
vitest/prefer-comparison-matcherRequire matchers such as toBeGreaterThan() instead of comparing inside expect()yes
vitest/prefer-describe-function-titleRequire describe(fn, ...) instead of a string with the name of an imported functionyes
vitest/prefer-eachRequire test.each and describe.each instead of a loop around tests
vitest/prefer-equality-matcherRequire toBe or toEqual instead of comparing with === inside expectsuggestion
vitest/prefer-expect-assertionsRequire expect.assertions() or expect.hasAssertions() at the start of every testsuggestion
vitest/prefer-expect-resolvesRequire await expect(promise).resolves instead of expect(await promise)yes
vitest/prefer-expect-type-ofRequire toBeTypeOf instead of expect(typeof value).toBe(...)yes
vitest/prefer-hooks-in-orderRequire hooks to be written in the order they run
vitest/prefer-hooks-on-topRequire hooks to come before the tests in their block
vitest/prefer-import-in-mockRequire import() instead of a string path in vi.mock() and vi.doMock()yes
vitest/prefer-importing-vitest-globalsRequire describe, test, expect and vi to be imported from vitestyes
vitest/prefer-lowercase-titleRequire the titles of tests and describe blocks to start with a lowercase letteryes
vitest/prefer-mock-promise-shorthandRequire mockResolvedValue() and mockRejectedValue() for mocks that return a promiseyes
vitest/prefer-mock-return-shorthandRequire mockReturnValue() for a mock that only returns a valueyes
vitest/prefer-snapshot-hintRequire a hint on toMatchSnapshot() and toThrowErrorMatchingSnapshot()
vitest/prefer-spy-onRequire vi.spyOn() instead of assigning vi.fn() to a propertysuggestion
vitest/prefer-strict-boolean-matchersRequire toBe(true) and toBe(false) instead of toBeTruthy() and toBeFalsy()yes
vitest/prefer-strict-equalRequire toStrictEqual() instead of toEqual()suggestion
vitest/prefer-to-beRequire toBe() for primitive literals, and toBeNull(), toBeUndefined(), toBeNaN()yes
vitest/prefer-to-be-falsyRequire toBeFalsy() instead of toBe(false)suggestion
vitest/prefer-to-be-objectRequire toBeObject() when expectTypeOf() checks for an objectyes
vitest/prefer-to-be-truthyRequire toBeTruthy() instead of toBe(true)suggestion
vitest/prefer-to-containRequire toContain() instead of comparing the result of includes() with a booleanyes
vitest/prefer-to-have-been-called-timesRequire toHaveBeenCalledTimes() instead of checking the length of mock.callsyes
vitest/prefer-to-have-lengthRequire toHaveLength() instead of comparing the length propertyyes
vitest/prefer-todoRequire test.todo for tests that have no body yetyes
vitest/require-awaited-expect-pollRequire expect.poll and expect.element assertions to be awaited or returned
vitest/require-hookRequire setup and teardown code to be inside a hook
vitest/require-local-test-context-for-concurrent-snapshotsRequire the expect of the test context for snapshots in concurrent tests
vitest/require-mock-type-parametersRequire a type parameter on vi.fn()
vitest/require-test-timeoutRequire every test to set a timeout
vitest/require-to-throw-messageRequire toThrow() to say which error it expects
vitest/require-top-level-describeRequire tests and hooks to be inside a describe block
vitest/valid-describe-callbackRequire describe to get a title and a callback with no parameters and no return
vitest/valid-expectRequire expect to get a value, end in a called matcher, and be awaited when it is asyncsuggestion
vitest/valid-expect-in-promiseRequire a promise chain that contains expect to be awaited or returned from the test
vitest/valid-titleRequire test and describe titles to be non-empty strings with no stray spaces or repeated prefixyes
vitest/warn-todoDisallow .todo on test, it and describe

Prettier#

1 rules.

RuleDescriptionDefaultFixableNeeds types
prettier/prettierRequire code to be formatted the way Prettier prints ityes