Skip to content

Rules

Below the list of rules supported by Biome, divided by group. Here’s a legend of the emojis:

  • The icon indicates that the rule is part of the recommended rules.
  • The icon indicates that the rule provides a code action (fix) that is safe to apply.
  • The icon indicates that the rule provides a code action (fix) that is unsafe to apply.
  • The icon indicates that the rule is applied to JavaScript and super languages files.
  • The icon indicates that the rule is applied to TypeScript and TSX files.
  • The icon indicates that the rule is applied to JSON files.
  • The icon indicates that the rule is applied to CSS files.
  • The icon indicates that the rule is applied to GraphQL files.

Rules focused on preventing accessibility problems.

Rule nameDescriptionProperties
noAccessKeyEnforce that the attribute is not used on any HTML element.
noAriaHiddenOnFocusableEnforce that aria-hidden=“true” is not set on focusable elements.
noAriaUnsupportedElementsEnforce that elements that do not support ARIA roles, states, and properties do not have those attributes.
noAutofocusEnforce that autoFocus prop is not used on elements.
noBlankTargetDisallow attribute without
noDistractingElementsEnforces that no distracting elements are used.
noHeaderScopeThe scope prop should be used only on elements.
noInteractiveElementToNoninteractiveRoleEnforce that non-interactive ARIA roles are not assigned to interactive HTML elements.
noNoninteractiveElementToInteractiveRoleEnforce that interactive ARIA roles are not assigned to non-interactive HTML elements.
noNoninteractiveTabindexEnforce that is not assigned to non-interactive HTML elements.
noPositiveTabindexPrevent the usage of positive integers on property
noRedundantAltEnforce alt prop does not contain the word “image”, “picture”, or “photo”.
noRedundantRolesEnforce explicit property is not the same as implicit/default role property on an element.
noSvgWithoutTitleEnforces the usage of the element for the element.
useAltTextEnforce that all elements that require alternative text have meaningful information to relay back to the end user.
useAnchorContentEnforce that anchors have content and that the content is accessible to screen readers.
useAriaActivedescendantWithTabindexEnforce that is assigned to non-interactive HTML elements with .
useAriaPropsForRoleEnforce that elements with ARIA roles must have all required ARIA attributes for that role.
useButtonTypeEnforces the usage of the attribute for the element
useHeadingContentEnforce 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.
useHtmlLangEnforce that element has attribute.
useIframeTitleEnforces the usage of the attribute for the element .
useKeyWithClickEventsEnforce onClick is accompanied by at least one of the following: , , .
useKeyWithMouseEventsEnforce / are accompanied by / .
useMediaCaptionEnforces that and elements must have a for captions.
useValidAnchorEnforce that all anchors are valid, and they are navigable elements.
useValidAriaPropsEnsures that ARIA properties are all valid.
useValidAriaRoleElements with ARIA roles must use a valid, non-abstract ARIA role.
useValidAriaValuesEnforce that ARIA state and property values are valid.
useValidLangEnsure that the attribute passed to the attribute is a correct ISO language and/or country.

Rules that focus on inspecting complex code that could be simplified.

Rule nameDescriptionProperties
noBannedTypesDisallow primitive type aliases and misleading types.
noEmptyTypeParametersDisallow empty type parameters in type aliases and interfaces.
noExcessiveCognitiveComplexityDisallow functions that exceed a given Cognitive Complexity score.
noExcessiveNestedTestSuitesThis rule enforces a maximum depth to nested in test files.
noExtraBooleanCastDisallow unnecessary boolean casts
noForEachPrefer statement instead of .
noMultipleSpacesInRegularExpressionLiteralsDisallow unclear usage of consecutive space characters in regular expression literals
noStaticOnlyClassThis rule reports when a class has no non-static members, such as for a class used exclusively as a static namespace.
noThisInStaticDisallow and in contexts.
noUselessCatchDisallow unnecessary clauses.
noUselessConstructorDisallow unnecessary constructors.
noUselessEmptyExportDisallow empty exports that don’t change anything in a module file.
noUselessFragmentsDisallow unnecessary fragments
noUselessLabelDisallow unnecessary labels.
noUselessLoneBlockStatementsDisallow unnecessary nested block statements.
noUselessRenameDisallow renaming import, export, and destructured assignments to the same name.
noUselessSwitchCaseDisallow useless in statements.
noUselessTernaryDisallow ternary operators when simpler alternatives exist.
noUselessThisAliasDisallow useless aliasing.
noUselessTypeConstraintDisallow using or as type constraint.
noVoidDisallow the use of operators, which is not a familiar operator.
noWithDisallow statements in non-strict contexts.
useArrowFunctionUse arrow functions over function expressions.
useFlatMapPromotes the use of when are used together.
useLiteralKeysEnforce the usage of a literal access to properties over computed property access.
useOptionalChainEnforce using concise optional chain instead of chained logical expressions.
useRegexLiteralsEnforce the use of the regular expression literals instead of the RegExp constructor if possible.
useSimpleNumberKeysDisallow number literal object member names which are not base10 or uses underscore as separator
useSimplifiedLogicExpressionDiscard redundant terms from logical expressions.

Rules that detect code that is guaranteed to be incorrect or useless.

Rule nameDescriptionProperties
noChildrenPropPrevent passing of children as props.
noConstAssignPrevents from having variables being re-assigned.
noConstantConditionDisallow constant expressions in conditions
noConstantMathMinMaxClampDisallow the use of and to clamp a value where the result itself is constant.
noConstructorReturnDisallow returning a value from a .
noEmptyCharacterClassInRegexDisallow empty character classes in regular expression literals.
noEmptyPatternDisallows empty destructuring patterns.
noFlatMapIdentityDisallow to use unnecessary callback on .
noGlobalObjectCallsDisallow calling global object properties as functions
noInnerDeclarationsDisallow and declarations that are accessible outside their block.
noInvalidConstructorSuperPrevents the incorrect use of inside classes. It also checks whether a call is missing from classes that extends other constructors.
noInvalidNewBuiltinDisallow operators with global non-constructor functions.
noInvalidUseBeforeDeclarationDisallow the use of variables and function parameters before their declaration
noNewSymbolDisallow operators with the object.
noNodejsModulesForbid the use of Node.js builtin modules.
noNonoctalDecimalEscapeDisallow and escape sequences in string literals.
noPrecisionLossDisallow literal numbers that lose precision
noRenderReturnValuePrevent the usage of the return value of .
noSelfAssignDisallow assignments where both sides are exactly the same.
noSetterReturnDisallow returning a value from a setter
noStringCaseMismatchDisallow comparison of expressions modifying the string case with non-compliant value.
noSwitchDeclarationsDisallow lexical declarations in clauses.
noUndeclaredVariablesPrevents the usage of variables that haven’t been declared inside the document.
noUnnecessaryContinueAvoid using unnecessary .
noUnreachableDisallow unreachable code
noUnreachableSuperEnsures the constructor is called exactly once on every code path in a class constructor before is accessed if the class has a superclass
noUnsafeFinallyDisallow control flow statements in finally blocks.
noUnsafeOptionalChainingDisallow the use of optional chaining in contexts where the undefined value is not allowed.
noUnusedImportsDisallow unused imports.
noUnusedLabelsDisallow unused labels.
noUnusedPrivateClassMembersDisallow unused private class members
noUnusedVariablesDisallow unused variables.
noVoidElementsWithChildrenThis rules prevents void elements (AKA self-closing elements) from having children.
noVoidTypeReturnDisallow returning a value from a function with the return type ‘void’
useArrayLiteralsDisallow Array constructors.
useExhaustiveDependenciesEnforce all dependencies are correctly specified in a React hook.
useHookAtTopLevelEnforce that all React hooks are being called from the Top Level component functions.
useIsNanRequire calls to when checking for .
useJsxKeyInIterableDisallow missing key props in iterators/collection literals.
useValidForDirectionEnforce “for” loop update clause moving the counter in the right direction.
useYieldRequire generator functions to contain .

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 nameDescriptionProperties
noConsoleDisallow the use of .
noDoneCallbackDisallow using a callback in asynchronous tests and hooks.
noDuplicateAtImportRulesDisallow duplicate rules.
noDuplicateElseIfDisallow duplicate conditions in if-else-if chains
noDuplicateFontNamesDisallow duplicate names within font families.
noDuplicateSelectorsKeyframeBlockDisallow duplicate selectors within keyframe blocks.
noEmptyBlockDisallow CSS empty blocks.
noEvolvingTypesDisallow variables from evolving into type through reassignments.
noImportantInKeyframeDisallow invalid within keyframe declarations
noInvalidPositionAtImportRuleDisallow the use of at-rules in invalid positions.
noLabelWithoutControlEnforce that a label element or component has a text label and an associated input.
noMisplacedAssertionChecks that the assertion function, for example , is placed inside an function call.
noReactSpecificPropsPrevents React-specific JSX properties from being used.
noRestrictedImportsDisallow specified modules when loaded by import or require.
noUndeclaredDependenciesDisallow the use of dependencies that aren’t specified in the .
noUnknownFunctionDisallow unknown CSS value functions.
noUnknownMediaFeatureNameDisallow unknown media feature names.
noUnknownPropertyDisallow unknown properties.
noUnknownPseudoElementDisallow unknown pseudo-element selectors.
noUnknownUnitDisallow unknown CSS units.
noUnmatchableAnbSelectorDisallow unmatchable An+B selectors.
noUnusedFunctionParametersDisallow unused function parameters.
noUselessStringConcatDisallow unnecessary concatenation of string or template literals.
noUselessUndefinedInitializationDisallow initializing variables to .
noValueAtRuleDisallow use of rule in css modules.
noYodaExpressionDisallow the use of yoda expressions.
useAdjacentOverloadSignaturesDisallow the use of overload signatures that are not next to each other.
useConsistentBuiltinInstantiationEnforce the use of for all builtins, except , , , and .
useDateNowUse to get the number of milliseconds since the Unix Epoch.
useDefaultSwitchClauseRequire the default clause in switch statements.
useErrorMessageEnforce passing a message value when creating a built-in error.
useExplicitLengthCheckEnforce explicitly comparing the , , or property of a value.
useFocusableInteractiveElements with an interactive role and interaction handlers must be focusable.
useGenericFontNamesDisallow a missing generic family keyword within font families.
useImportExtensionsEnforce file extensions for relative imports.
useImportRestrictionsDisallows package private imports.
useNumberToFixedDigitsArgumentEnforce using the digits argument with .
useSemanticElementsIt detects the use of attributes in JSX elements and suggests using semantic elements instead.
useSortedClassesEnforce the sorting of CSS utility classes.
useStrictModeEnforce the use of the directive in script files.
useThrowNewErrorRequire when throwing an error.
useThrowOnlyErrorDisallow throwing non- values.
useTopLevelRegexRequire regex literals to be declared at the top level.

Rules catching ways your code could be written to run faster, or generally be more efficient.

Rule nameDescriptionProperties
noAccumulatingSpreadDisallow the use of spread () syntax on accumulators.
noBarrelFileDisallow the use of barrel file.
noDeleteDisallow the use of the operator.
noReExportAllAvoid re-export all.

Rules that detect potential security flaws.

Rule nameDescriptionProperties
noDangerouslySetInnerHtmlPrevent the usage of dangerous JSX props
noDangerouslySetInnerHtmlWithChildrenReport when a DOM element or a component uses both and prop.
noGlobalEvalDisallow the use of global .

Rules enforcing a consistent and idiomatic way of writing your code.

Rule nameDescriptionProperties
noArgumentsDisallow the use of .
noCommaOperatorDisallow comma operator.
noDefaultExportDisallow default exports.
noImplicitBooleanDisallow implicit values on JSX boolean attributes
noInferrableTypesDisallow type annotations for variables, parameters, and class properties initialized with a literal expression.
noNamespaceDisallow the use of TypeScript’s s.
noNamespaceImportDisallow the use of namespace imports.
noNegationElseDisallow negation in the condition of an statement if it has an clause.
noNonNullAssertionDisallow non-null assertions using the postfix operator.
noParameterAssignDisallow reassigning parameters.
noParameterPropertiesDisallow the use of parameter properties in class constructors.
noRestrictedGlobalsThis rule allows you to specify global variable names that you don’t want to use in your application.
noShoutyConstantsDisallow the use of constants which its value is the upper-case version of its name.
noUnusedTemplateLiteralDisallow template literals if interpolation and special-character handling are not needed
noUselessElseDisallow block when the block breaks early.
noVarDisallow the use of
useAsConstAssertionEnforce the use of over literal type and type annotation.
useBlockStatementsRequires following curly brace conventions.
useCollapsedElseIfEnforce using instead of nested in clauses.
useConsistentArrayTypeRequire consistently using either or
useConstRequire declarations for variables that are only assigned once.
useDefaultParameterLastEnforce default function parameters and optional function parameters to be last.
useEnumInitializersRequire that each enum member value be explicitly initialized.
useExponentiationOperatorDisallow the use of in favor of the operator.
useExportTypePromotes the use of for types.
useFilenamingConventionEnforce naming conventions for JavaScript and TypeScript filenames.
useForOfThis rule recommends a loop when in a loop, the index used to extract an item from the iterated array.
useFragmentSyntaxThis rule enforces the use of over .
useImportTypePromotes the use of for types.
useLiteralEnumMembersRequire all enum members to be literal values.
useNamingConventionEnforce naming conventions for everything across a codebase.
useNodeAssertStrictPromotes the usage of over .
useNodejsImportProtocolEnforces using the protocol for Node.js builtin modules.
useNumberNamespaceUse the properties instead of global ones.
useNumericLiteralsDisallow and in favor of binary, octal, and hexadecimal literals
useSelfClosingElementsPrevent extra closing tags for components without children
useShorthandArrayTypeWhen expressing array types, this rule promotes the usage of shorthand instead of .
useShorthandAssignRequire assignment operator shorthand where possible.
useShorthandFunctionTypeEnforce using function types instead of object type with call signatures.
useSingleCaseStatementEnforces switch clauses have a single statement, emits a quick fix wrapping the statements in a block.
useSingleVarDeclaratorDisallow multiple variable declarations in the same variable statement
useTemplatePrefer template literals over string concatenation.
useWhileEnforce the use of loops instead of loops when the initializer and update expressions are not needed.

Rules that detect code that is likely to be incorrect or useless.

Rule nameDescriptionProperties
noApproximativeNumericConstantUse standard constants instead of approximated literals.
noArrayIndexKeyDiscourage the usage of Array index in keys.
noAssignInExpressionsDisallow assignments in expressions.
noAsyncPromiseExecutorDisallows using an async function as a Promise executor.
noCatchAssignDisallow reassigning exceptions in catch clauses.
noClassAssignDisallow reassigning class members.
noCommentTextPrevent comments from being inserted as text nodes
noCompareNegZeroDisallow comparing against
noConfusingLabelsDisallow labeled statements that are not loops.
noConfusingVoidTypeDisallow type outside of generic or return types.
noConsoleLogDisallow the use of
noConstEnumDisallow TypeScript
noControlCharactersInRegexPrevents from having control characters and some escape sequences that match control characters in regular expressions.
noDebuggerDisallow the use of
noDoubleEqualsRequire the use of and .
noDuplicateCaseDisallow duplicate case labels.
noDuplicateClassMembersDisallow duplicate class members.
noDuplicateJsxPropsPrevents JSX properties to be assigned multiple times.
noDuplicateObjectKeysDisallow two keys with the same name inside objects.
noDuplicateObjectKeysDisallow two keys with the same name inside objects.
noDuplicateParametersDisallow duplicate function parameter name.
noDuplicateTestHooksA block should not contain duplicate hooks.
noEmptyBlockStatementsDisallow empty block statements and static blocks.
noEmptyInterfaceDisallow the declaration of empty interfaces.
noExplicitAnyDisallow the type usage.
noExportsInTestDisallow using or in files containing tests
noExtraNonNullAssertionPrevents the wrong usage of the non-null assertion operator () in TypeScript files.
noFallthroughSwitchClauseDisallow fallthrough of clauses.
noFocusedTestsDisallow focused tests.
noFunctionAssignDisallow reassigning function declarations.
noGlobalAssignDisallow assignments to native objects and read-only global variables.
noGlobalIsFiniteUse instead of global .
noGlobalIsNanUse instead of global .
noImplicitAnyLetDisallow use of implicit type on variable declarations.
noImportAssignDisallow assigning to imported bindings
noLabelVarDisallow labels that share a name with a variable
noMisleadingCharacterClassDisallow characters made with multiple code points in character class syntax.
noMisleadingInstantiatorEnforce proper usage of and .
noMisrefactoredShorthandAssignDisallow shorthand assign when variable appears on both sides.
noPrototypeBuiltinsDisallow direct use of builtins.
noRedeclareDisallow variable, function, class, and type redeclarations in the same scope.
noRedundantUseStrictPrevents from having redundant .
noSelfCompareDisallow comparisons where both sides are exactly the same.
noShadowRestrictedNamesDisallow identifiers from shadowing restricted names.
noSkippedTestsDisallow disabled tests.
noSparseArrayDisallow sparse arrays
noSuspiciousSemicolonInJsxIt detects possible “wrong” semicolons inside JSX elements.
noThenPropertyDisallow property.
noUnsafeDeclarationMergingDisallow unsafe declaration merging between interfaces and classes.
noUnsafeNegationDisallow using unsafe negation.
useAwaitEnsure functions utilize .
useDefaultSwitchClauseLastEnforce default clauses in switch statements to be last
useGetterReturnEnforce methods to always return a value.
useIsArrayUse instead of .
useNamespaceKeywordRequire using the keyword over the keyword to declare TypeScript namespaces.
useValidTypeofThis rule verifies the result of unary expressions is being compared to valid values, either string literals containing valid type names or other expressions

The recommended rules are: