Rules
Below the list of rules supported by Biome, divided by group. Here’s a legend of the emojis:
- The emoji ✅ indicates that the rule is part of the recommended rules.
- The emoji 🔧 indicates that the rule provides a code action (fix) that is safe to apply.
- The emoji ⚠️ indicates that the rule provides a code action (fix) that is unsafe to apply.
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. | ✅ ⚠️ |
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 | ✅ |
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. | ✅ |
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. | ✅ 🔧 |
noExcessiveCognitiveComplexity | Disallow functions that exceed a given Cognitive Complexity score. | |
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. | ✅ 🔧 |
noUselessRename | Disallow renaming import, export, and destructured assignments to the same name. | ✅ 🔧 |
noUselessSwitchCase | Disallow useless case in switch statements. | ✅ ⚠️ |
noUselessThisAlias | Disallow useless this aliasing. | ✅ 🔧 |
noUselessTypeConstraint | Disallow using any or unknown as type constraint. | ✅ 🔧 |
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. | ✅ 🔧 |
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 | ✅ |
noConstructorReturn | Disallow returning a value from a constructor . | ✅ |
noEmptyCharacterClassInRegex | Disallow empty character classes in regular expression literals. | ✅ |
noEmptyPattern | Disallows empty destructuring patterns. | ✅ |
noGlobalObjectCalls | Disallow calling global object properties as functions | ✅ |
noInnerDeclarations | Disallow function and var declarations that are accessible outside their block. | ✅ |
noInvalidConstructorSuper | Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors. | ✅ |
noInvalidNewBuiltin | Disallow new operators with global non-constructor functions. | ✅ ⚠️ |
noNewSymbol | Disallow new operators with the Symbol object. | ⚠️ |
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. | ✅ ⚠️ |
noUndeclaredVariables | Prevents the usage of variables that haven’t been declared inside the document. | |
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. | ✅ |
noUnusedLabels | Disallow unused labels. | ✅ ⚠️ |
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’ | ✅ |
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. | |
useIsNan | Require calls to isNaN() when checking for NaN . | ✅ ⚠️ |
useValidForDirection | Enforce “for” loop update clause moving the counter in the right direction. | ✅ |
useYield | Require generator functions to contain yield . | ✅ |
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. | ✅ |
noDelete | Disallow the use of the delete operator. | ✅ ⚠️ |
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. | ✅ |
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. | |
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. | |
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 | ✅ ⚠️ |
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. | 🔧 |
useConst | Require const declarations for variables that are never reassigned after declared. | ✅ 🔧 |
useDefaultParameterLast | Enforce default function parameters and optional function parameters to be last. | ✅ ⚠️ |
useEnumInitializers | 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> . | ⚠️ |
useLiteralEnumMembers | Require all enum members to be literal values. | ✅ |
useNamingConvention | Enforce naming conventions for everything across a codebase. | 🔧 |
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. | ⚠️ |
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. | ✅ ⚠️ |
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.
Rule name | Description | Properties |
---|---|---|
noApproximativeNumericConstant | Use standard constants instead of approximated literals. | ⚠️ |
noArrayIndexKey | Discourage the usage of Array index in keys. | ✅ |
noAssignInExpressions | Disallow assignments in expressions. | ✅ |
noAsyncPromiseExecutor | Disallows using an async function as a Promise executor. | ✅ |
noCatchAssign | Disallow reassigning exceptions in catch clauses. | ✅ |
noClassAssign | Disallow reassigning class members. | ✅ |
noCommentText | Prevent comments from being inserted as text nodes | ✅ ⚠️ |
noCompareNegZero | Disallow comparing against -0 | ✅ 🔧 |
noConfusingLabels | Disallow labeled statements that are not loops. | ✅ |
noConfusingVoidType | Disallow void type outside of generic or return types. | ✅ |
noConsoleLog | Disallow the use of console.log | ⚠️ |
noConstEnum | Disallow TypeScript const enum | ✅ 🔧 |
noControlCharactersInRegex | Prevents from having control characters and some escape sequences that match control characters in regular expressions. | ✅ |
noDebugger | Disallow the use of debugger | ✅ ⚠️ |
noDoubleEquals | Require the use of === and !== | ✅ ⚠️ |
noDuplicateCase | Disallow duplicate case labels. | ✅ |
noDuplicateClassMembers | Disallow duplicate class members. | ✅ |
noDuplicateJsxProps | Prevents JSX properties to be assigned multiple times. | ✅ |
noDuplicateObjectKeys | Prevents object literals having more than one property declaration for the same name. | ✅ ⚠️ |
noDuplicateParameters | Disallow duplicate function parameter name. | ✅ |
noEmptyInterface | Disallow the declaration of empty interfaces. | ✅ 🔧 |
noExplicitAny | Disallow the any type usage. | ✅ |
noExtraNonNullAssertion | Prevents the wrong usage of the non-null assertion operator (! ) in TypeScript files. | ✅ 🔧 |
noFallthroughSwitchClause | Disallow fallthrough of switch clauses. | ✅ |
noFunctionAssign | Disallow reassigning function declarations. | ✅ |
noGlobalIsFinite | Use Number.isFinite instead of global isFinite . | ✅ ⚠️ |
noGlobalIsNan | Use Number.isNaN instead of global isNaN . | ✅ ⚠️ |
noImplicitAnyLet | Disallow use of implicit any type on variable declarations. | ✅ |
noImportAssign | Disallow assigning to imported bindings | ✅ |
noLabelVar | Disallow labels that share a name with a variable | ✅ |
noMisleadingInstantiator | Enforce proper usage of new and constructor . | ✅ |
noMisrefactoredShorthandAssign | Disallow shorthand assign when variable appears on both sides. | ⚠️ |
noPrototypeBuiltins | Disallow direct use of Object.prototype builtins. | ✅ |
noRedeclare | Disallow variable, function, class, and type redeclarations in the same scope. | ✅ |
noRedundantUseStrict | Prevents from having redundant “use strict” . | ✅ 🔧 |
noSelfCompare | Disallow comparisons where both sides are exactly the same. | ✅ |
noShadowRestrictedNames | Disallow identifiers from shadowing restricted names. | ✅ |
noSparseArray | Disallow sparse arrays | ✅ ⚠️ |
noUnsafeDeclarationMerging | Disallow unsafe declaration merging between interfaces and classes. | ✅ |
noUnsafeNegation | Disallow using unsafe negation. | ✅ ⚠️ |
useDefaultSwitchClauseLast | Enforce default clauses in switch statements to be last | ✅ |
useGetterReturn | Enforce get methods to always return a value. | ✅ |
useIsArray | Use Array.isArray() instead of instanceof Array . | ✅ ⚠️ |
useNamespaceKeyword | Require using the namespace keyword over the module keyword to declare TypeScript namespaces. | ✅ 🔧 |
useValidTypeof | 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
Section titled NurseryNew 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 |
---|---|---|
noBarrelFile | Disallow the use of barrel file. | |
noConsole | Disallow the use of console . | ⚠️ |
noDuplicateJsonKeys | Disallow two keys with the same name inside a JSON object. | |
noDuplicateTestHooks | A describe block should not contain duplicate hooks. | |
noEmptyBlockStatements | Disallow empty block statements and static blocks. | |
noEmptyTypeParameters | Disallow empty type parameters in type aliases and interfaces. | |
noExcessiveNestedTestSuites | This rule enforces a maximum depth to nested describe() in test files. | |
noExportsInTest | Disallow using export or module.exports in files containing tests | |
noFocusedTests | Disallow focused tests. | ⚠️ |
noGlobalAssign | Disallow assignments to native objects and read-only global variables. | |
noGlobalEval | Disallow the use of global eval() . | |
noInvalidUseBeforeDeclaration | Disallow the use of variables and function parameters before their declaration | |
noMisleadingCharacterClass | Disallow characters made with multiple code points in character class syntax. | 🔧 |
noNamespaceImport | Disallow the use of namespace imports. | |
noNodejsModules | Forbid the use of Node.js builtin modules. | |
noReExportAll | Avoid re-export all. | |
noRestrictedImports | Disallow specified modules when loaded by import or require. | |
noSemicolonInJsx | It detects possible “wrong” semicolons inside JSX elements. | |
noSkippedTests | Disallow disabled tests. | ⚠️ |
noThenProperty | Disallow then property. | |
noUndeclaredDependencies | Disallow the use of dependencies that aren’t specified in the package.json . | |
noUnusedImports | Disallow unused imports. | 🔧 |
noUnusedPrivateClassMembers | Disallow unused private class members | ⚠️ |
noUselessLoneBlockStatements | Disallow unnecessary nested block statements. | ⚠️ |
noUselessTernary | Disallow ternary operators when simpler alternatives exist. | ⚠️ |
useAwait | Ensure async functions utilize await . | |
useConsistentArrayType | Require consistently using either T[] or Array<T> | ⚠️ |
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. | |
useGroupedTypeImport | Enforce the use of import type when an import only has specifiers with type qualifier. | ⚠️ |
useImportRestrictions | Disallows package private imports. | |
useImportType | Promotes the use of import type for types. | 🔧 |
useJsxKeyInIterable | Disallow missing key props in iterators/collection literals. | |
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. | ⚠️ |
useShorthandFunctionType | Enforce using function types instead of object type with call signatures. | 🔧 |
useSortedClasses | Enforce the sorting of CSS utility classes. | ⚠️ |