Rules
Accessibility
Rules focused on preventing accessibility problems.
noAccessKey
Enforce that the accessKey
attribute is not used on any HTML element.
noAutofocusrecommended
Enforce that autoFocus prop is not used on elements.
noBlankTargetrecommended
Disallow target=“_blank”
attribute without rel=“noreferrer”
noDistractingElementsrecommended
Enforces that no distracting elements are used.
noHeaderScoperecommended
The scope prop should be used only on <th>
elements.
noNoninteractiveElementToInteractiveRolerecommended
Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements.
noPositiveTabindexrecommended
Prevent the usage of positive integers on tabIndex
property
noRedundantAltrecommended
Enforce img
alt prop does not contain the word “image”, “picture”, or “photo”.
noSvgWithoutTitlerecommended
Enforces the usage of the title
element for the svg
element.
useAltTextrecommended
Enforce that all elements that require alternative text have meaningful information to relay back to the end user.
useAnchorContentrecommended
Enforce that anchors have content and that the content is accessible to screen readers.
useAriaPropsForRolerecommended
Enforce that elements with ARIA roles must have all required ARIA attributes for that role.
useButtonTyperecommended
Enforces the usage of the attribute type
for the element button
useHtmlLangrecommended
Enforce that html
element has lang
attribute.
useIframeTitlerecommended
Enforces the usage of the attribute title
for the element iframe
.
useKeyWithClickEventsrecommended
Enforce onClick is accompanied by at least one of the following: onKeyUp
, onKeyDown
, onKeyPress
.
useKeyWithMouseEventsrecommended
Enforce onMouseOver
/ onMouseOut
are accompanied by onFocus
/ onBlur
.
useMediaCaptionrecommended
Enforces that audio
and video
elements must have a track
for captions.
useValidAnchorrecommended
Enforce that all anchors are valid, and they are navigable elements.
useValidAriaPropsrecommended
Ensures that ARIA properties aria-*
are all valid.
useValidLangrecommended
Ensure that the attribute passed to the lang
attribute is a correct ISO language and/or country.
Complexity
Rules that focus on inspecting complex code that could be simplified.
noExtraBooleanCastrecommended
Disallow unnecessary boolean casts
noExtraSemicolonrecommended
Typing mistakes and misunderstandings about where semicolons are required can lead to semicolons that are unnecessary. While not technically an error, extra semicolons can cause confusion when reading code.
noMultipleSpacesInRegularExpressionLiteralsrecommended
Disallow unclear usage of multiple space characters in regular expression literals
noUselessCatchrecommended
Disallow unnecessary catch
clauses.
noUselessConstructorrecommended
Disallow unnecessary constructors.
noUselessFragments
Disallow unnecessary fragments
noUselessLabelrecommended
Disallow unnecessary labels.
noUselessRenamerecommended
Disallow renaming import, export, and destructured assignments to the same name.
noUselessSwitchCaserecommended
Disallow useless case
in switch
statements.
noUselessTypeConstraintrecommended
Disallow using any
or unknown
as type constraint.
noWithrecommended
Disallow with
statements in non-strict contexts.
useFlatMaprecommended
Promotes the use of .flatMap()
when map().flat()
are used together.
useOptionalChainrecommended
Enforce using concise optional chain instead of chained logical expressions.
useSimplifiedLogicExpression
Discard redundant terms from logical expressions.
Correctness
Rules that detect code that is guaranteed to be incorrect or useless.
noChildrenProprecommended
Prevent passing of children as props.
noConstAssignrecommended
Prevents from having const
variables being re-assigned.
noConstructorReturnrecommended
Disallow returning a value from a constructor
.
noEmptyPatternrecommended
Disallows empty destructuring patterns.
noGlobalObjectCallsrecommended
Disallow calling global object properties as functions
noInnerDeclarationsrecommended
Disallow function
and var
declarations that are accessible outside their block.
noInvalidConstructorSuperrecommended
Prevents the incorrect use of super()
inside classes. It also checks whether a call super()
is missing from classes that extends other constructors.
noNewSymbolrecommended
Disallow new
operators with the Symbol
object
noPrecisionLossrecommended
Disallow literal numbers that lose precision
noRenderReturnValuerecommended
Prevent the usage of the return value of React.render
.
noSetterReturnrecommended
Disallow returning a value from a setter
noStringCaseMismatchrecommended
Disallow comparison of expressions modifying the string case with non-compliant value.
noSwitchDeclarationsrecommended
Disallow lexical declarations in switch
clauses.
noUndeclaredVariables
Prevents the usage of variables that haven’t been declared inside the document
noUnnecessaryContinuerecommended
Avoid using unnecessary continue
.
noUnreachablerecommended
Disallow unreachable code
noUnreachableSuperrecommended
Ensures the super()
constructor is called exactly once on every code path in a class constructor before this
is accessed if the class has a superclass
noUnsafeFinallyrecommended
Disallow control flow statements in finally blocks.
noUnsafeOptionalChainingrecommended
Disallow the use of optional chaining in contexts where the undefined value is not allowed.
noUnusedLabelsrecommended
Disallow unused labels.
noUnusedVariables
Disallow unused variables.
noVoidElementsWithChildrenrecommended
This rules prevents void elements (AKA self-closing elements) from having children.
noVoidTypeReturnrecommended
Disallow returning a value from a function with the return type ‘void’
useValidForDirectionrecommended
Enforce “for” loop update clause moving the counter in the right direction.
useYieldrecommended
Require generator functions to contain yield
.
Performance
Rules catching ways your code could be written to run faster, or generally be more efficient.
noDeleterecommended
Disallow the use of the delete
operator.
Security
Rules that detect potential security flaws.
noDangerouslySetInnerHtmlrecommended
Prevent the usage of dangerous JSX props
noDangerouslySetInnerHtmlWithChildrenrecommended
Report when a DOM element or a component uses both children
and dangerouslySetInnerHTML
prop.
Style
Rules enforcing a consistent and idiomatic way of writing your code.
noArgumentsrecommended
Disallow the use of arguments
noCommaOperatorrecommended
Disallow comma operator.
noImplicitBoolean
Disallow implicit true
values on JSX boolean attributes
noInferrableTypesrecommended
Disallow type annotations for variables, parameters, and class properties initialized with a literal expression.
noNamespace
Disallow the use of TypeScript’s namespace
s.
noNegationElse
Disallow negation in the condition of an if
statement if it has an else
clause
noNonNullAssertionrecommended
Disallow non-null assertions using the !
postfix operator.
noParameterAssignrecommended
Disallow reassigning function
parameters.
noParameterProperties
Disallow the use of parameter properties in class constructors.
noRestrictedGlobals
This rule allows you to specify global variable names that you don’t want to use in your application.
noShoutyConstants
Disallow the use of constants which its value is the upper-case version of its name.
noUnusedTemplateLiteralrecommended
Disallow template literals if interpolation and special-character handling are not needed
noVarrecommended
Disallow the use of var
useBlockStatements
Requires following curly brace conventions. JavaScript allows the omission of curly braces when a block contains only one statement. However, it is considered by many to be best practice to never omit curly braces around blocks, even when they are optional, because it can lead to bugs and reduces code clarity.
useConstrecommended
Require const
declarations for variables that are never reassigned after declared.
useDefaultParameterLastrecommended
Enforce default function parameters and optional parameters to be last.
useEnumInitializersrecommended
Require that each enum member value be explicitly initialized.
useExponentiationOperator
Disallow the use of Math.pow
in favor of the **
operator.
useFragmentSyntax
This rule enforces the use of <>…</>
over <Fragment>…</Fragment>
.
useNumericLiteralsrecommended
Disallow parseInt()
and Number.parseInt()
in favor of binary, octal, and hexadecimal literals
useSelfClosingElementsrecommended
Prevent extra closing tags for components without children
useShorthandArrayType
When expressing array types, this rule promotes the usage of T[]
shorthand instead of Array<T>
.
useSingleCaseStatement
Enforces switch clauses have a single statement, emits a quick fix wrapping the statements in a block.
useSingleVarDeclaratorrecommended
Disallow multiple variable declarations in the same variable statement
useTemplaterecommended
Template literals are preferred over string concatenation.
useWhilerecommended
Enforce the use of while
loops instead of for
loops when the initializer and update expressions are not needed
Suspicious
Rules that detect code that is likely to be incorrect or useless.
noArrayIndexKeyrecommended
Discourage the usage of Array index in keys.
noAssignInExpressionsrecommended
Disallow assignments in expressions.
noAsyncPromiseExecutorrecommended
Disallows using an async function as a Promise executor.
noCatchAssignrecommended
Disallow reassigning exceptions in catch clauses.
noClassAssignrecommended
Disallow reassigning class members.
noCommentTextrecommended
Prevent comments from being inserted as text nodes
noCompareNegZerorecommended
Disallow comparing against -0
noConfusingLabelsrecommended
Disallow labeled statements that are not loops.
noConstEnumrecommended
Disallow TypeScript const enum
noDebuggerrecommended
Disallow the use of debugger
noDoubleEqualsrecommended
Require the use of ===
and !==
noDuplicateCaserecommended
Disallow duplicate case labels. If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.
noDuplicateClassMembersrecommended
Disallow duplicate class members.
noDuplicateObjectKeysrecommended
Prevents object literals having more than one property declaration for the same name. If an object property with the same name is defined multiple times (except when combining a getter with a setter), only the last definition makes it into the object and previous definitions are ignored, which is likely a mistake.
noDuplicateParametersrecommended
Disallow duplicate function parameter name.
noEmptyInterfacerecommended
Disallow the declaration of empty interfaces.
noExplicitAnyrecommended
Disallow the any
type usage.
noExtraNonNullAssertionrecommended
Prevents the wrong usage of the non-null assertion operator (!
) in TypeScript files.
noFunctionAssignrecommended
Disallow reassigning function declarations.
noImportAssignrecommended
Disallow assigning to imported bindings
noLabelVarrecommended
Disallow labels that share a name with a variable
noPrototypeBuiltinsrecommended
Disallow direct use of Object.prototype
builtins.
noRedeclarerecommended
Disallow variable, function, class, and type redeclarations in the same scope.
noRedundantUseStrict
Prevents from having redundant “use strict”
.
noSelfComparerecommended
Disallow comparisons where both sides are exactly the same.
noShadowRestrictedNamesrecommended
Disallow identifiers from shadowing restricted names.
noSparseArrayrecommended
Disallow sparse arrays
noUnsafeNegationrecommended
Disallow using unsafe negation.
useDefaultSwitchClauseLastrecommended
Enforce default clauses in switch statements to be last
useNamespaceKeywordrecommended
Require using the namespace
keyword over the module
keyword to declare TypeScript namespaces.
useValidTypeofrecommended
This rule verifies the result of typeof $expr
unary expressions is being compared to valid values, either string literals containing valid type names or other typeof
expressions
Nursery
New rules that are still under development.
Nursery rules require explicit opt-in via configuration on stable versions because they may still have bugs or performance problems. They are enabled by default on nightly builds, but as they are unstable their diagnostic severity may be set to either error or warning, depending on whether we intend for the rule to be recommended or not when it eventually gets stabilized. Nursery rules get promoted to other groups once they become stable or may be removed.
Rules that belong to this group are not subject to semantic version.
noAccumulatingSpread
Disallow the use of spread (…
) syntax on accumulators.
noAriaUnsupportedElements
Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.
noBannedTypes
Disallow certain types.
noConfusingArrow
Disallow arrow functions where they could be confused with comparisons.
noConsoleLog
Disallow the use of console.log
noConstantCondition
Disallow constant expressions in conditions
noDuplicateJsxProps
Prevents JSX properties to be assigned multiple times.
noForEach
Prefer for…of
statement instead of Array.forEach
.
noNoninteractiveTabindex
Enforce that tabIndex
is not assigned to non-interactive HTML elements.
noRedundantRoles
Enforce explicit role
property is not the same as implicit/default role property on an element.
noSelfAssign
Disallow assignments where both sides are exactly the same.
useAriaPropTypes
Enforce that ARIA state and property values are valid.
useCamelCase
Enforce camel case naming convention.
useExhaustiveDependencies
Enforce all dependencies are correctly specified.
useGroupedTypeImport
Enforce the use of import type
when an import
only has specifiers with type
qualifier.
useHeadingContent
Enforce that heading elements (h1, h2, etc.) have content and that the content is accessible to screen readers. Accessible means that it is not hidden using the aria-hidden prop.
useHookAtTopLevel
Enforce that all React hooks are being called from the Top Level component functions.
useIsNan
Require calls to isNaN()
when checking for NaN
.
useLiteralEnumMembers
Require all enum members to be literal values.
useLiteralKeys
Enforce the usage of a literal access to properties over computed property access.
useSimpleNumberKeys
Disallow number literal object member names which are not base10 or uses underscore as separator