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.
Accessibility
Section titled AccessibilityRules focused on preventing accessibility problems.
Rule name | Description | Properties |
---|---|---|
noAccessKey | Enforce that the 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 attribute without | |
noDistractingElements | Enforces that no distracting elements are used. | |
noHeaderScope | The scope prop should be used only on 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 is not assigned to non-interactive HTML elements. | |
noPositiveTabindex | Prevent the usage of positive integers on property | |
noRedundantAlt | Enforce alt prop does not contain the word “image”, “picture”, or “photo”. | |
noRedundantRoles | Enforce explicit property is not the same as implicit/default role property on an element. | |
noSvgWithoutTitle | Enforces the usage of the element for the 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 is assigned to non-interactive HTML elements with . | |
useAriaPropsForRole | Enforce that elements with ARIA roles must have all required ARIA attributes for that role. | |
useButtonType | Enforces the usage of the attribute for the element | |
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 element has attribute. | |
useIframeTitle | Enforces the usage of the attribute for the element . | |
useKeyWithClickEvents | Enforce onClick is accompanied by at least one of the following: , , . | |
useKeyWithMouseEvents | Enforce / are accompanied by / . | |
useMediaCaption | Enforces that and elements must have a for captions. | |
useValidAnchor | Enforce that all anchors are valid, and they are navigable elements. | |
useValidAriaProps | Ensures that ARIA properties 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 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 in test files. | |
noExtraBooleanCast | Disallow unnecessary boolean casts | |
noForEach | Prefer statement instead of . | |
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 and in contexts. | |
noUselessCatch | Disallow unnecessary 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. | |
noUselessSwitchCase | Disallow useless in statements. | |
noUselessTernary | Disallow ternary operators when simpler alternatives exist. | |
noUselessThisAlias | Disallow useless aliasing. | |
noUselessTypeConstraint | Disallow using or as type constraint. | |
noVoid | Disallow the use of operators, which is not a familiar operator. | |
noWith | Disallow statements in non-strict contexts. | |
useArrowFunction | Use arrow functions over function expressions. | |
useFlatMap | Promotes the use of when 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 variables being re-assigned. | |
noConstantCondition | Disallow constant expressions in conditions | |
noConstantMathMinMaxClamp | Disallow the use of and to clamp a value where the result itself is constant. | |
noConstructorReturn | Disallow returning a value from a . | |
noEmptyCharacterClassInRegex | Disallow empty character classes in regular expression literals. | |
noEmptyPattern | Disallows empty destructuring patterns. | |
noFlatMapIdentity | Disallow to use unnecessary callback on . | |
noGlobalObjectCalls | Disallow calling global object properties as functions | |
noInnerDeclarations | Disallow and declarations that are accessible outside their block. | |
noInvalidConstructorSuper | Prevents the incorrect use of inside classes. It also checks whether a call is missing from classes that extends other constructors. | |
noInvalidNewBuiltin | Disallow operators with global non-constructor functions. | |
noInvalidUseBeforeDeclaration | Disallow the use of variables and function parameters before their declaration | |
noNewSymbol | Disallow operators with the object. | |
noNodejsModules | Forbid the use of Node.js builtin modules. | |
noNonoctalDecimalEscape | Disallow and escape sequences in string literals. | |
noPrecisionLoss | Disallow literal numbers that lose precision | |
noRenderReturnValue | Prevent the usage of the return value of . | |
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 clauses. | |
noUndeclaredVariables | Prevents the usage of variables that haven’t been declared inside the document. | |
noUnnecessaryContinue | Avoid using unnecessary . | |
noUnreachable | Disallow unreachable code | |
noUnreachableSuper | Ensures the constructor is called exactly once on every code path in a class constructor before 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. | |
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. | |
useIsNan | Require calls to when checking for . | |
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 . |
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 |
---|---|---|
noConsole | Disallow the use of . | |
noDoneCallback | Disallow using a callback in asynchronous tests and hooks. | |
noDuplicateAtImportRules | Disallow duplicate rules. | |
noDuplicateElseIf | Disallow duplicate conditions in if-else-if chains | |
noDuplicateFontNames | Disallow duplicate names within font families. | |
noDuplicateSelectorsKeyframeBlock | Disallow duplicate selectors within keyframe blocks. | |
noEmptyBlock | Disallow CSS empty blocks. | |
noEvolvingTypes | Disallow variables from evolving into type through reassignments. | |
noImportantInKeyframe | Disallow invalid within keyframe declarations | |
noInvalidPositionAtImportRule | Disallow the use of at-rules in invalid positions. | |
noLabelWithoutControl | Enforce that a label element or component has a text label and an associated input. | |
noMisplacedAssertion | Checks that the assertion function, for example , is placed inside an function call. | |
noReactSpecificProps | Prevents React-specific JSX properties from being used. | |
noRestrictedImports | Disallow specified modules when loaded by import or require. | |
noUndeclaredDependencies | Disallow the use of dependencies that aren’t specified in the . | |
noUnknownFunction | Disallow unknown CSS value functions. | |
noUnknownMediaFeatureName | Disallow unknown media feature names. | |
noUnknownProperty | Disallow unknown properties. | |
noUnknownPseudoElement | Disallow unknown pseudo-element selectors. | |
noUnknownUnit | Disallow unknown CSS units. | |
noUnmatchableAnbSelector | Disallow unmatchable An+B selectors. | |
noUnusedFunctionParameters | Disallow unused function parameters. | |
noUselessStringConcat | Disallow unnecessary concatenation of string or template literals. | |
noUselessUndefinedInitialization | Disallow initializing variables to . | |
noValueAtRule | Disallow use of rule in css modules. | |
noYodaExpression | Disallow the use of yoda expressions. | |
useAdjacentOverloadSignatures | Disallow the use of overload signatures that are not next to each other. | |
useConsistentBuiltinInstantiation | Enforce the use of for all builtins, except , , , and . | |
useDateNow | Use to get the number of milliseconds since the Unix Epoch. | |
useDefaultSwitchClause | Require the default clause in switch statements. | |
useErrorMessage | Enforce passing a message value when creating a built-in error. | |
useExplicitLengthCheck | Enforce explicitly comparing the , , or property of a value. | |
useFocusableInteractive | Elements with an interactive role and interaction handlers must be focusable. | |
useGenericFontNames | Disallow a missing generic family keyword within font families. | |
useImportExtensions | Enforce file extensions for relative imports. | |
useImportRestrictions | Disallows package private imports. | |
useNumberToFixedDigitsArgument | Enforce using the digits argument with . | |
useSemanticElements | It detects the use of attributes in JSX elements and suggests using semantic elements instead. | |
useSortedClasses | Enforce the sorting of CSS utility classes. | |
useStrictMode | Enforce the use of the directive in script files. | |
useThrowNewError | Require when throwing an error. | |
useThrowOnlyError | Disallow throwing non- values. | |
useTopLevelRegex | Require regex literals to be declared at the top level. |
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 operator. | |
noReExportAll | Avoid re-export all. |
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 and prop. | |
noGlobalEval | Disallow the use of global . |
Style
Section titled StyleRules enforcing a consistent and idiomatic way of writing your code.
Rule name | Description | Properties |
---|---|---|
noArguments | Disallow the use of . | |
noCommaOperator | Disallow comma operator. | |
noDefaultExport | Disallow default exports. | |
noImplicitBoolean | Disallow implicit 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 s. | |
noNamespaceImport | Disallow the use of namespace imports. | |
noNegationElse | Disallow negation in the condition of an statement if it has an clause. | |
noNonNullAssertion | Disallow non-null assertions using the postfix operator. | |
noParameterAssign | Disallow reassigning 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 block when the block breaks early. | |
noVar | Disallow the use of | |
useAsConstAssertion | Enforce the use of over literal type and type annotation. | |
useBlockStatements | Requires following curly brace conventions. | |
useCollapsedElseIf | Enforce using instead of nested in clauses. | |
useConsistentArrayType | Require consistently using either or | |
useConst | Require declarations for variables that are only assigned once. | |
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 in favor of the operator. | |
useExportType | Promotes the use of for types. | |
useFilenamingConvention | Enforce naming conventions for JavaScript and TypeScript filenames. | |
useForOf | This rule recommends a loop when in a loop, the index used to extract an item from the iterated array. | |
useFragmentSyntax | This rule enforces the use of over . | |
useImportType | Promotes the use of 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 over . | |
useNodejsImportProtocol | Enforces using the protocol for Node.js builtin modules. | |
useNumberNamespace | Use the properties instead of global ones. | |
useNumericLiterals | Disallow and 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 shorthand instead of . | |
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. | |
useWhile | Enforce the use of loops instead of 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 | |
noConfusingLabels | Disallow labeled statements that are not loops. | |
noConfusingVoidType | Disallow type outside of generic or return types. | |
noConsoleLog | Disallow the use of | |
noConstEnum | Disallow TypeScript | |
noControlCharactersInRegex | Prevents from having control characters and some escape sequences that match control characters in regular expressions. | |
noDebugger | Disallow the use of | |
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 | Disallow two keys with the same name inside objects. | |
noDuplicateObjectKeys | Disallow two keys with the same name inside objects. | |
noDuplicateParameters | Disallow duplicate function parameter name. | |
noDuplicateTestHooks | A block should not contain duplicate hooks. | |
noEmptyBlockStatements | Disallow empty block statements and static blocks. | |
noEmptyInterface | Disallow the declaration of empty interfaces. | |
noExplicitAny | Disallow the type usage. | |
noExportsInTest | Disallow using or in files containing tests | |
noExtraNonNullAssertion | Prevents the wrong usage of the non-null assertion operator () in TypeScript files. | |
noFallthroughSwitchClause | Disallow fallthrough of clauses. | |
noFocusedTests | Disallow focused tests. | |
noFunctionAssign | Disallow reassigning function declarations. | |
noGlobalAssign | Disallow assignments to native objects and read-only global variables. | |
noGlobalIsFinite | Use instead of global . | |
noGlobalIsNan | Use instead of global . | |
noImplicitAnyLet | Disallow use of implicit type on variable declarations. | |
noImportAssign | Disallow assigning to imported bindings | |
noLabelVar | Disallow labels that share a name with a variable | |
noMisleadingCharacterClass | Disallow characters made with multiple code points in character class syntax. | |
noMisleadingInstantiator | Enforce proper usage of and . | |
noMisrefactoredShorthandAssign | Disallow shorthand assign when variable appears on both sides. | |
noPrototypeBuiltins | Disallow direct use of builtins. | |
noRedeclare | Disallow variable, function, class, and type redeclarations in the same scope. | |
noRedundantUseStrict | Prevents from having redundant . | |
noSelfCompare | Disallow comparisons where both sides are exactly the same. | |
noShadowRestrictedNames | Disallow identifiers from shadowing restricted names. | |
noSkippedTests | Disallow disabled tests. | |
noSparseArray | Disallow sparse arrays | |
noSuspiciousSemicolonInJsx | It detects possible “wrong” semicolons inside JSX elements. | |
noThenProperty | Disallow property. | |
noUnsafeDeclarationMerging | Disallow unsafe declaration merging between interfaces and classes. | |
noUnsafeNegation | Disallow using unsafe negation. | |
useAwait | Ensure functions utilize . | |
useDefaultSwitchClauseLast | Enforce default clauses in switch statements to be last | |
useGetterReturn | Enforce methods to always return a value. | |
useIsArray | Use instead of . | |
useNamespaceKeyword | Require using the keyword over the keyword to declare TypeScript namespaces. | |
useValidTypeof | This rule verifies the result of unary expressions is being compared to valid values, either string literals containing valid type names or other expressions |
Recommended rules
Section titled Recommended rulesThe recommended rules are:
- noAccessKey
- noAriaHiddenOnFocusable
- noAriaUnsupportedElements
- noAutofocus
- noBlankTarget
- noDistractingElements
- noHeaderScope
- noInteractiveElementToNoninteractiveRole
- noNoninteractiveElementToInteractiveRole
- noNoninteractiveTabindex
- noPositiveTabindex
- noRedundantAlt
- noRedundantRoles
- noSvgWithoutTitle
- useAltText
- useAnchorContent
- useAriaActivedescendantWithTabindex
- useAriaPropsForRole
- useButtonType
- useHeadingContent
- useHtmlLang
- useIframeTitle
- useKeyWithClickEvents
- useKeyWithMouseEvents
- useMediaCaption
- useValidAnchor
- useValidAriaProps
- useValidAriaRole
- useValidAriaValues
- useValidLang
- noBannedTypes
- noEmptyTypeParameters
- noExcessiveNestedTestSuites
- noExtraBooleanCast
- noForEach
- noMultipleSpacesInRegularExpressionLiterals
- noStaticOnlyClass
- noThisInStatic
- noUselessCatch
- noUselessConstructor
- noUselessEmptyExport
- noUselessFragments
- noUselessLabel
- noUselessLoneBlockStatements
- noUselessRename
- noUselessSwitchCase
- noUselessTernary
- noUselessThisAlias
- noUselessTypeConstraint
- noWith
- useArrowFunction
- useFlatMap
- useLiteralKeys
- useOptionalChain
- useRegexLiterals
- useSimpleNumberKeys
- noChildrenProp
- noConstAssign
- noConstantCondition
- noConstructorReturn
- noEmptyCharacterClassInRegex
- noEmptyPattern
- noFlatMapIdentity
- noGlobalObjectCalls
- noInnerDeclarations
- noInvalidConstructorSuper
- noInvalidNewBuiltin
- noInvalidUseBeforeDeclaration
- noNonoctalDecimalEscape
- noPrecisionLoss
- noRenderReturnValue
- noSelfAssign
- noSetterReturn
- noStringCaseMismatch
- noSwitchDeclarations
- noUnnecessaryContinue
- noUnreachable
- noUnreachableSuper
- noUnsafeFinally
- noUnsafeOptionalChaining
- noUnusedLabels
- noVoidElementsWithChildren
- noVoidTypeReturn
- useExhaustiveDependencies
- useIsNan
- useJsxKeyInIterable
- useValidForDirection
- useYield
- noAccumulatingSpread
- noDelete
- noDangerouslySetInnerHtml
- noDangerouslySetInnerHtmlWithChildren
- noGlobalEval
- noArguments
- noCommaOperator
- noInferrableTypes
- noNonNullAssertion
- noParameterAssign
- noUnusedTemplateLiteral
- noUselessElse
- noVar
- useAsConstAssertion
- useConst
- useDefaultParameterLast
- useEnumInitializers
- useExponentiationOperator
- useExportType
- useImportType
- useLiteralEnumMembers
- useNodejsImportProtocol
- useNumberNamespace
- useNumericLiterals
- useSelfClosingElements
- useShorthandFunctionType
- useSingleVarDeclarator
- useTemplate
- useWhile
- noApproximativeNumericConstant
- noArrayIndexKey
- noAssignInExpressions
- noAsyncPromiseExecutor
- noCatchAssign
- noClassAssign
- noCommentText
- noCompareNegZero
- noConfusingLabels
- noConfusingVoidType
- noConstEnum
- noControlCharactersInRegex
- noDebugger
- noDoubleEquals
- noDuplicateCase
- noDuplicateClassMembers
- noDuplicateJsxProps
- noDuplicateObjectKeys
- noDuplicateObjectKeys
- noDuplicateParameters
- noDuplicateTestHooks
- noEmptyInterface
- noExplicitAny
- noExportsInTest
- noExtraNonNullAssertion
- noFallthroughSwitchClause
- noFocusedTests
- noFunctionAssign
- noGlobalAssign
- noGlobalIsFinite
- noGlobalIsNan
- noImplicitAnyLet
- noImportAssign
- noLabelVar
- noMisleadingCharacterClass
- noMisleadingInstantiator
- noMisrefactoredShorthandAssign
- noPrototypeBuiltins
- noRedeclare
- noRedundantUseStrict
- noSelfCompare
- noShadowRestrictedNames
- noSparseArray
- noSuspiciousSemicolonInJsx
- noThenProperty
- noUnsafeDeclarationMerging
- noUnsafeNegation
- useDefaultSwitchClauseLast
- useGetterReturn
- useIsArray
- useNamespaceKeyword
- useValidTypeof