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.
noLabelWithoutControlEnforce that a label element or component has a text label and an associated input.
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
useFocusableInteractiveElements with an interactive role and interaction handlers must be focusable.
useGenericFontNamesDisallow a missing generic family keyword within font families.
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.
useSemanticElementsIt detects the use of attributes in JSX elements and suggests using semantic elements instead.
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.
noUselessStringConcatDisallow unnecessary concatenation of string or template literals.
noUselessSwitchCaseDisallow useless in statements.
noUselessTernaryDisallow ternary operators when simpler alternatives exist.
noUselessThisAliasDisallow useless aliasing.
noUselessTypeConstraintDisallow using or as type constraint.
noUselessUndefinedInitializationDisallow initializing variables to .
noVoidDisallow the use of operators, which is not a familiar operator.
noWithDisallow statements in non-strict contexts.
useArrowFunctionUse arrow functions over function expressions.
useDateNowUse to get the number of milliseconds since the Unix Epoch.
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.
noInvalidBuiltinInstantiationEnsure that builtins are correctly instantiated.
noInvalidConstructorSuperPrevents the incorrect use of inside classes. It also checks whether a call is missing from classes that extends other constructors.
noInvalidDirectionInLinearGradientDisallow non-standard direction values for linear gradient functions.
noInvalidGridAreasDisallows invalid named grid areas in CSS Grid Layouts.
noInvalidNewBuiltinDisallow operators with global non-constructor functions.
noInvalidPositionAtImportRuleDisallow the use of at-rules in invalid positions.
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.
noUndeclaredDependenciesDisallow the use of dependencies that aren’t specified in the .
noUndeclaredVariablesPrevents the usage of variables that haven’t been declared inside the document.
noUnknownFunctionDisallow unknown CSS value functions.
noUnknownMediaFeatureNameDisallow unknown media feature names.
noUnknownPropertyDisallow unknown properties.
noUnknownUnitDisallow unknown CSS units.
noUnmatchableAnbSelectorDisallow unmatchable An+B selectors.
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.
noUnusedFunctionParametersDisallow unused function parameters.
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.
useImportExtensionsEnforce file extensions for relative imports.
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
noCommonJsDisallow use of CommonJs module system in favor of ESM style imports.
noDuplicateCustomPropertiesDisallow duplicate custom properties within declaration blocks.
noDuplicateElseIfDisallow duplicate conditions in if-else-if chains
noDuplicatedFieldsNo duplicated fields in GraphQL operations.
noDynamicNamespaceImportAccessDisallow accessing namespace imports dynamically.
noEnumDisallow TypeScript enum.
noExportedImportsDisallow exporting an imported variable.
noIrregularWhitespaceDisallows the use of irregular whitespace characters.
noIrregularWhitespaceDisallows the use of irregular whitespace characters.
noRestrictedImportsDisallow specified modules when loaded by import or require.
noRestrictedTypesDisallow user defined types.
noSecretsDisallow usage of sensitive data such as API keys and tokens.
noStaticElementInteractionsEnforce that static, visible elements (such as ) that have click handlers use the valid role attribute.
noSubstrEnforce the use of over and .
noUnknownPseudoClassDisallow unknown pseudo-class selectors.
noUnknownPseudoElementDisallow unknown pseudo-element selectors.
noUselessEscapeInRegexDisallow unnecessary escape sequence in regular expression literals.
noValueAtRuleDisallow use of rule in css modules.
useAdjacentOverloadSignaturesDisallow the use of overload signatures that are not next to each other.
useAriaPropsSupportedByRoleEnforce that ARIA properties are valid for the roles that are supported by the element.
useConsistentCurlyBracesThis rule enforces consistent use of curly braces inside JSX attributes and JSX children.
useConsistentMemberAccessibilityRequire consistent accessibility modifiers on class properties and methods.
useDeprecatedReasonRequire specifying the reason argument when using @deprecated directive
useImportRestrictionsDisallows package private imports.
useSortedClassesEnforce the sorting of CSS utility classes.
useStrictModeEnforce the use of the directive in script files.
useTrimStartEndEnforce the use of and over and .
useValidAutocompleteUse valid values for the attribute on elements.

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.
useTopLevelRegexRequire regex literals to be declared at the top level.

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.
noDoneCallbackDisallow using a callback in asynchronous tests and hooks.
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
noYodaExpressionDisallow the use of yoda expressions.
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
useConsistentBuiltinInstantiationEnforce the use of for all builtins, except , and .
useConstRequire declarations for variables that are only assigned once.
useDefaultParameterLastEnforce default function parameters and optional function parameters to be last.
useDefaultSwitchClauseRequire the default clause in switch statements.
useEnumInitializersRequire that each enum member value be explicitly initialized.
useExplicitLengthCheckEnforce explicitly comparing the , , or property of a value.
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.
useThrowNewErrorRequire when throwing an error.
useThrowOnlyErrorDisallow throwing non- values.
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.
noConsoleDisallow the use of .
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 .
noDuplicateAtImportRulesDisallow duplicate rules.
noDuplicateCaseDisallow duplicate case labels.
noDuplicateClassMembersDisallow duplicate class members.
noDuplicateFontNamesDisallow duplicate names within font families.
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.
noDuplicateSelectorsKeyframeBlockDisallow duplicate selectors within keyframe blocks.
noDuplicateTestHooksA block should not contain duplicate hooks.
noEmptyBlockDisallow CSS empty blocks.
noEmptyBlockStatementsDisallow empty block statements and static blocks.
noEmptyInterfaceDisallow the declaration of empty interfaces.
noEvolvingTypesDisallow variables from evolving into type through reassignments.
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
noImportantInKeyframeDisallow invalid within keyframe declarations
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 .
noMisplacedAssertionChecks that the assertion function, for example , is placed inside an function call.
noMisrefactoredShorthandAssignDisallow shorthand assign when variable appears on both sides.
noPrototypeBuiltinsDisallow direct use of builtins.
noReactSpecificPropsPrevents React-specific JSX properties from being used.
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.
noShorthandPropertyOverridesDisallow shorthand properties that override related longhand properties.
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
useErrorMessageEnforce passing a message value when creating a built-in error.
useGetterReturnEnforce methods to always return a value.
useIsArrayUse instead of .
useNamespaceKeywordRequire using the keyword over the keyword to declare TypeScript namespaces.
useNumberToFixedDigitsArgumentEnforce using the digits argument with .
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: