Rules
Below the list of rules supported by Biome, divided by group. Here’s a legend of the emojis:
Accessibility
Section titled AccessibilityRules focused on preventing accessibility problems.
Rule name | Description | Properties |
---|---|---|
noAccessKey |
Enforce that the
accessKey
attribute is not used on any HTML element.
|
|
noAriaHiddenOnFocusable | Enforce that aria-hidden=“true” is not set on focusable elements. | |
noAriaUnsupportedElements | Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes. | |
noAutofocus | Enforce that autoFocus prop is not used on elements. | |
noBlankTarget |
Disallow
target="_blank"
attribute without
rel="noreferrer"
|
|
noDistractingElements | Enforces that no distracting elements are used. | |
noHeaderScope |
The scope prop should be used only on
<th>
elements.
|
|
noInteractiveElementToNoninteractiveRole | Enforce that non-interactive ARIA roles are not assigned to interactive HTML elements. | |
noLabelWithoutControl | Enforce that a label element or component has a text label and an associated input. | |
noNoninteractiveElementToInteractiveRole | Enforce that interactive ARIA roles are not assigned to non-interactive HTML elements. | |
noNoninteractiveTabindex |
Enforce that
tabIndex
is not assigned to non-interactive HTML elements.
|
|
noPositiveTabindex |
Prevent the usage of positive integers on
tabIndex
property
|
|
noRedundantAlt |
Enforce
img
alt prop does not contain the word “image”, “picture”, or “photo”.
|
|
noRedundantRoles |
Enforce explicit
role
property is not the same as implicit/default role property on an element.
|
|
noSvgWithoutTitle |
Enforces the usage of the
title
element for the
svg
element.
|
|
useAltText | Enforce that all elements that require alternative text have meaningful information to relay back to the end user. | |
useAnchorContent | Enforce that anchors have content and that the content is accessible to screen readers. | |
useAriaActivedescendantWithTabindex |
Enforce that
tabIndex
is assigned to non-interactive HTML elements with
aria-activedescendant
.
|
|
useAriaPropsForRole | Enforce that elements with ARIA roles must have all required ARIA attributes for that role. | |
useButtonType |
Enforces the usage of the attribute
type
for the element
button
|
|
useFocusableInteractive | Elements with an interactive role and interaction handlers must be focusable. | |
useGenericFontNames | Disallow a missing generic family keyword within font families. | |
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. | |
useHtmlLang |
Enforce that
html
element has
lang
attribute.
|
|
useIframeTitle |
Enforces the usage of the attribute
title
for the element
iframe
.
|
|
useKeyWithClickEvents |
Enforce onClick is accompanied by at least one of the following:
onKeyUp
,
onKeyDown
,
onKeyPress
.
|
|
useKeyWithMouseEvents |
Enforce
onMouseOver
/
onMouseOut
are accompanied by
onFocus
/
onBlur
.
|
|
useMediaCaption |
Enforces that
audio
and
video
elements must have a
track
for captions.
|
|
useSemanticElements |
It detects the use of
role
attributes in JSX elements and suggests using semantic elements instead.
|
|
useValidAnchor | Enforce that all anchors are valid, and they are navigable elements. | |
useValidAriaProps |
Ensures that ARIA properties
aria-*
are all valid.
|
|
useValidAriaRole | Elements with ARIA roles must use a valid, non-abstract ARIA role. | |
useValidAriaValues | Enforce that ARIA state and property values are valid. | |
useValidLang |
Ensure that the attribute passed to the
lang
attribute is a correct ISO language and/or country.
|
Complexity
Section titled ComplexityRules that focus on inspecting complex code that could be simplified.
Rule name | Description | Properties |
---|---|---|
noBannedTypes | Disallow primitive type aliases and misleading types. | |
noEmptyTypeParameters | Disallow empty type parameters in type aliases and interfaces. | |
noExcessiveCognitiveComplexity | Disallow functions that exceed a given Cognitive Complexity score. | |
noExcessiveNestedTestSuites |
This rule enforces a maximum depth to nested
describe()
in test files.
|
|
noExtraBooleanCast | Disallow unnecessary boolean casts | |
noForEach |
Prefer
for...of
statement instead of
Array.forEach
.
|
|
noMultipleSpacesInRegularExpressionLiterals | Disallow unclear usage of consecutive space characters in regular expression literals | |
noStaticOnlyClass | This rule reports when a class has no non-static members, such as for a class used exclusively as a static namespace. | |
noThisInStatic |
Disallow
this
and
super
in
static
contexts.
|
|
noUselessCatch |
Disallow unnecessary
catch
clauses.
|
|
noUselessConstructor | Disallow unnecessary constructors. | |
noUselessEmptyExport | Disallow empty exports that don’t change anything in a module file. | |
noUselessFragments | Disallow unnecessary fragments | |
noUselessLabel | Disallow unnecessary labels. | |
noUselessLoneBlockStatements | Disallow unnecessary nested block statements. | |
noUselessRename | Disallow renaming import, export, and destructured assignments to the same name. | |
noUselessStringConcat | Disallow unnecessary concatenation of string or template literals. | |
noUselessSwitchCase |
Disallow useless
case
in
switch
statements.
|
|
noUselessTernary | Disallow ternary operators when simpler alternatives exist. | |
noUselessThisAlias |
Disallow useless
this
aliasing.
|
|
noUselessTypeConstraint |
Disallow using
any
or
unknown
as type constraint.
|
|
noUselessUndefinedInitialization |
Disallow initializing variables to
undefined
.
|
|
noVoid |
Disallow the use of
void
operators, which is not a familiar operator.
|
|
noWith |
Disallow
with
statements in non-strict contexts.
|
|
useArrowFunction | Use arrow functions over function expressions. | |
useDateNow |
Use
Date.now()
to get the number of milliseconds since the Unix Epoch.
|
|
useFlatMap |
Promotes the use of
.flatMap()
when
map().flat()
are used together.
|
|
useLiteralKeys | Enforce the usage of a literal access to properties over computed property access. | |
useOptionalChain | Enforce using concise optional chain instead of chained logical expressions. | |
useRegexLiterals | Enforce the use of the regular expression literals instead of the RegExp constructor if possible. | |
useSimpleNumberKeys | Disallow number literal object member names which are not base10 or uses underscore as separator | |
useSimplifiedLogicExpression | Discard redundant terms from logical expressions. |
Correctness
Section titled CorrectnessRules that detect code that is guaranteed to be incorrect or useless.
Rule name | Description | Properties |
---|---|---|
noChildrenProp | Prevent passing of children as props. | |
noConstAssign |
Prevents from having
const
variables being re-assigned.
|
|
noConstantCondition | Disallow constant expressions in conditions | |
noConstantMathMinMaxClamp |
Disallow the use of
Math.min
and
Math.max
to clamp a value where the result itself is constant.
|
|
noConstructorReturn |
Disallow returning a value from a
constructor
.
|
|
noEmptyCharacterClassInRegex | Disallow empty character classes in regular expression literals. | |
noEmptyPattern | Disallows empty destructuring patterns. | |
noFlatMapIdentity |
Disallow to use unnecessary callback on
flatMap
.
|
|
noGlobalObjectCalls | Disallow calling global object properties as functions | |
noInnerDeclarations |
Disallow
function
and
var
declarations that are accessible outside their block.
|
|
noInvalidBuiltinInstantiation | Ensure that builtins are correctly instantiated. | |
noInvalidConstructorSuper |
Prevents the incorrect use of
super()
inside classes. It also checks whether a call
super()
is missing from classes that extends other constructors.
|
|
noInvalidDirectionInLinearGradient | Disallow non-standard direction values for linear gradient functions. | |
noInvalidGridAreas | Disallows invalid named grid areas in CSS Grid Layouts. | |
noInvalidNewBuiltin |
Disallow
new
operators with global non-constructor functions.
|
|
noInvalidPositionAtImportRule |
Disallow the use of
@import
at-rules in invalid positions.
|
|
noInvalidUseBeforeDeclaration | Disallow the use of variables and function parameters before their declaration | |
noNewSymbol |
Disallow
new
operators with the
Symbol
object.
|
|
noNodejsModules | Forbid the use of Node.js builtin modules. | |
noNonoctalDecimalEscape |
Disallow
\8
and
\9
escape sequences in string literals.
|
|
noPrecisionLoss | Disallow literal numbers that lose precision | |
noRenderReturnValue |
Prevent the usage of the return value of
React.render
.
|
|
noSelfAssign | Disallow assignments where both sides are exactly the same. | |
noSetterReturn | Disallow returning a value from a setter | |
noStringCaseMismatch | Disallow comparison of expressions modifying the string case with non-compliant value. | |
noSwitchDeclarations |
Disallow lexical declarations in
switch
clauses.
|
|
noUndeclaredDependencies |
Disallow the use of dependencies that aren’t specified in the
package.json
.
|
|
noUndeclaredVariables | Prevents the usage of variables that haven’t been declared inside the document. | |
noUnknownFunction | Disallow unknown CSS value functions. | |
noUnknownMediaFeatureName | Disallow unknown media feature names. | |
noUnknownProperty | Disallow unknown properties. | |
noUnknownUnit | Disallow unknown CSS units. | |
noUnmatchableAnbSelector | Disallow unmatchable An+B selectors. | |
noUnnecessaryContinue |
Avoid using unnecessary
continue
.
|
|
noUnreachable | Disallow unreachable code | |
noUnreachableSuper |
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
|
|
noUnsafeFinally | Disallow control flow statements in finally blocks. | |
noUnsafeOptionalChaining | Disallow the use of optional chaining in contexts where the undefined value is not allowed. | |
noUnusedFunctionParameters | Disallow unused function parameters. | |
noUnusedImports | Disallow unused imports. | |
noUnusedLabels | Disallow unused labels. | |
noUnusedPrivateClassMembers | Disallow unused private class members | |
noUnusedVariables | Disallow unused variables. | |
noVoidElementsWithChildren | This rules prevents void elements (AKA self-closing elements) from having children. | |
noVoidTypeReturn | Disallow returning a value from a function with the return type ‘void’ | |
useArrayLiterals | Disallow Array constructors. | |
useExhaustiveDependencies | Enforce all dependencies are correctly specified in a React hook. | |
useHookAtTopLevel | Enforce that all React hooks are being called from the Top Level component functions. | |
useImportExtensions | Enforce file extensions for relative imports. | |
useIsNan |
Require calls to
isNaN()
when checking for
NaN
.
|
|
useJsxKeyInIterable | Disallow missing key props in iterators/collection literals. | |
useValidForDirection | Enforce “for” loop update clause moving the counter in the right direction. | |
useYield |
Require generator functions to contain
yield
.
|
Nursery
Section titled 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
.
Rule name | Description | Properties |
---|---|---|
noCommonJs | Disallow use of CommonJs module system in favor of ESM style imports. | |
noDescendingSpecificity | Disallow a lower specificity selector from coming after a higher specificity selector. | |
noDocumentCookie |
Disallow direct assignments to
document.cookie
.
|
|
noDocumentImportInPage |
Prevents importing
next/document
outside of
pages/_document.jsx
in Next.js projects.
|
|
noDuplicateCustomProperties | Disallow duplicate custom properties within declaration blocks. | |
noDuplicateElseIf | Disallow duplicate conditions in if-else-if chains | |
noDuplicateProperties | Disallow duplicate properties within declaration blocks. | |
noDuplicatedFields | No duplicated fields in GraphQL operations. | |
noDynamicNamespaceImportAccess | Disallow accessing namespace imports dynamically. | |
noEnum | Disallow TypeScript enum. | |
noExportedImports | Disallow exporting an imported variable. | |
noHeadElement |
Prevent usage of
<head>
element in a Next.js project.
|
|
noHeadImportInDocument |
Prevent using the
next/head
module in
pages/_document.js
on Next.js projects.
|
|
noImgElement |
Prevent usage of
<img>
element in a Next.js project.
|
|
noIrregularWhitespace | Disallows the use of irregular whitespace characters. | |
noIrregularWhitespace | Disallows the use of irregular whitespace characters. | |
noMissingVarFunction | Disallow missing var function for css variables. | |
noNestedTernary | Disallow nested ternary expressions. | |
noOctalEscape | Disallow octal escape sequences in string literals | |
noProcessEnv |
Disallow the use of
process.env
.
|
|
noRestrictedImports | Disallow specified modules when loaded by import or require. | |
noRestrictedTypes | Disallow user defined types. | |
noSecrets | Disallow usage of sensitive data such as API keys and tokens. | |
noStaticElementInteractions |
Enforce that static, visible elements (such as
<div>
) that have click handlers use the valid role attribute.
|
|
noSubstr |
Enforce the use of
String.slice()
over
String.substr()
and
String.substring()
.
|
|
noTemplateCurlyInString | Disallow template literal placeholder syntax in regular strings. | |
noUnknownPseudoClass | Disallow unknown pseudo-class selectors. | |
noUnknownPseudoElement | Disallow unknown pseudo-element selectors. | |
noUnknownTypeSelector | Disallow unknown type selectors. | |
noUselessEscapeInRegex | Disallow unnecessary escape sequence in regular expression literals. | |
noUselessStringRaw |
Disallow unnecessary
String.raw
function in template string literals without any escape sequence.
|
|
noValueAtRule |
Disallow use of
@value
rule in css modules.
|
|
useAdjacentOverloadSignatures | Disallow the use of overload signatures that are not next to each other. | |
useAriaPropsSupportedByRole | Enforce that ARIA properties are valid for the roles that are supported by the element. | |
useAtIndex |
Use
at()
instead of integer index access.
|
|
useCollapsedIf |
Enforce using single
if
instead of nested
if
clauses.
|
|
useComponentExportOnlyModules | Enforce declaring components only within modules that export React Components exclusively. | |
useConsistentCurlyBraces | This rule enforces consistent use of curly braces inside JSX attributes and JSX children. | |
useConsistentMemberAccessibility | Require consistent accessibility modifiers on class properties and methods. | |
useDeprecatedReason |
Require specifying the reason argument when using
@deprecated
directive
|
|
useExplicitType | Require explicit return types on functions and class methods. | |
useGoogleFontDisplay |
Enforces the use of a recommended
display
strategy with Google Fonts.
|
|
useGuardForIn |
Require
for-in
loops to include an
if
statement.
|
|
useImportRestrictions | Disallows package private imports. | |
useSortedClasses | Enforce the sorting of CSS utility classes. | |
useStrictMode |
Enforce the use of the directive
"use strict"
in script files.
|
|
useTrimStartEnd |
Enforce the use of
String.trimStart()
and
String.trimEnd()
over
String.trimLeft()
and
String.trimRight()
.
|
|
useValidAutocomplete |
Use valid values for the
autocomplete
attribute on
input
elements.
|
Performance
Section titled PerformanceRules catching ways your code could be written to run faster, or generally be more efficient.
Rule name | Description | Properties |
---|---|---|
noAccumulatingSpread |
Disallow the use of spread (
...
) syntax on accumulators.
|
|
noBarrelFile | Disallow the use of barrel file. | |
noDelete |
Disallow the use of the
delete
operator.
|
|
noReExportAll | Avoid re-export all. | |
useTopLevelRegex | Require regex literals to be declared at the top level. |
Security
Section titled SecurityRules that detect potential security flaws.
Rule name | Description | Properties |
---|---|---|
noDangerouslySetInnerHtml | Prevent the usage of dangerous JSX props | |
noDangerouslySetInnerHtmlWithChildren |
Report when a DOM element or a component uses both
children
and
dangerouslySetInnerHTML
prop.
|
|
noGlobalEval |
Disallow the use of global
eval()
.
|
Style
Section titled StyleRules enforcing a consistent and idiomatic way of writing your code.
Rule name | Description | Properties |
---|---|---|
noArguments |
Disallow the use of
arguments
.
|
|
noCommaOperator | Disallow comma operator. | |
noDefaultExport | Disallow default exports. | |
noDoneCallback | Disallow using a callback in asynchronous tests and hooks. | |
noImplicitBoolean |
Disallow implicit
true
values on JSX boolean attributes
|
|
noInferrableTypes | Disallow type annotations for variables, parameters, and class properties initialized with a literal expression. | |
noNamespace |
Disallow the use of TypeScript’s
namespace
s.
|
|
noNamespaceImport | Disallow the use of namespace imports. | |
noNegationElse |
Disallow negation in the condition of an
if
statement if it has an
else
clause.
|
|
noNonNullAssertion |
Disallow non-null assertions using the
!
postfix operator.
|
|
noParameterAssign |
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. | |
noUnusedTemplateLiteral | Disallow template literals if interpolation and special-character handling are not needed | |
noUselessElse |
Disallow
else
block when the
if
block breaks early.
|
|
noVar |
Disallow the use of
var
|
|
noYodaExpression | Disallow the use of yoda expressions. | |
useAsConstAssertion |
Enforce the use of
as const
over literal type and type annotation.
|
|
useBlockStatements | Requires following curly brace conventions. | |
useCollapsedElseIf |
Enforce using
else if
instead of nested
if
in
else
clauses.
|
|
useConsistentArrayType |
Require consistently using either
T[]
or
Array<T>
|
|
useConsistentBuiltinInstantiation |
Enforce the use of
new
for all builtins, except
String
,
Number
and
Boolean
.
|
|
useConst |
Require
const
declarations for variables that are only assigned once.
|
|
useDefaultParameterLast | Enforce default function parameters and optional function parameters to be last. | |
useDefaultSwitchClause | Require the default clause in switch statements. | |
useEnumInitializers | Require that each enum member value be explicitly initialized. | |
useExplicitLengthCheck |
Enforce explicitly comparing the
length
,
size
,
byteLength
or
byteOffset
property of a value.
|
|
useExponentiationOperator |
Disallow the use of
Math.pow
in favor of the
**
operator.
|
|
useExportType |
Promotes the use of
export type
for types.
|
|
useFilenamingConvention | Enforce naming conventions for JavaScript and TypeScript filenames. | |
useForOf |
This rule recommends a
for-of
loop when in a
for
loop, the index used to extract an item from the iterated array.
|
|
useFragmentSyntax |
This rule enforces the use of
<>...</>
over
<Fragment>...</Fragment>
.
|
|
useImportType |
Promotes the use of
import type
for types.
|
|
useLiteralEnumMembers | Require all enum members to be literal values. | |
useNamingConvention | Enforce naming conventions for everything across a codebase. | |
useNodeAssertStrict |
Promotes the usage of
node:assert/strict
over
node:assert
.
|
|
useNodejsImportProtocol |
Enforces using the
node:
protocol for Node.js builtin modules.
|
|
useNumberNamespace |
Use the
Number
properties instead of global ones.
|
|
useNumericLiterals |
Disallow
parseInt()
and
Number.parseInt()
in favor of binary, octal, and hexadecimal literals
|
|
useSelfClosingElements | 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>
.
|
|
useShorthandAssign | Require assignment operator shorthand where possible. | |
useShorthandFunctionType | Enforce using function types instead of object type with call signatures. | |
useSingleCaseStatement | Enforces switch clauses have a single statement, emits a quick fix wrapping the statements in a block. | |
useSingleVarDeclarator | Disallow multiple variable declarations in the same variable statement | |
useTemplate | Prefer template literals over string concatenation. | |
useThrowNewError |
Require
new
when throwing an error.
|
|
useThrowOnlyError |
Disallow throwing non-
Error
values.
|
|
useWhile |
Enforce the use of
while
loops instead of
for
loops when the initializer and update expressions are not needed.
|
Suspicious
Section titled SuspiciousRules that detect code that is likely to be incorrect or useless.