コンテンツにスキップ

JavaScript 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 has been implemented and scheduled for the next release.
Rule nameDescriptionProperties
noAccessKeyEnforce that the accessKey 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.
noDistractingElementsEnforces that no distracting elements are used.
noHeaderScopeThe scope prop should be used only on <th> 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.
noNoninteractiveElementInteractionsDisallow use event handlers on non-interactive elements.
noNoninteractiveElementToInteractiveRoleEnforce that interactive ARIA roles are not assigned to non-interactive HTML elements.
noNoninteractiveTabindexEnforce that tabIndex is not assigned to non-interactive HTML elements.
noPositiveTabindexPrevent the usage of positive integers on tabIndex property
noRedundantAltEnforce img alt prop does not contain the word “image”, “picture”, or “photo”.
noRedundantRolesEnforce explicit role property is not the same as implicit/default role property on an element.
noStaticElementInteractionsEnforce that static, visible elements (such as <div>) that have click handlers use the valid role attribute.
noSvgWithoutTitleEnforces the usage of the title element for the svg 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 tabIndex is assigned to non-interactive HTML elements with aria-activedescendant.
useAriaPropsForRoleEnforce that elements with ARIA roles must have all required ARIA attributes for that role.
useAriaPropsSupportedByRoleEnforce that ARIA properties are valid for the roles that are supported by the element.
useButtonTypeEnforces the usage of the attribute type for the element button
useFocusableInteractiveElements with an interactive role and interaction handlers must be focusable.
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 html element has lang attribute.
useIframeTitleEnforces the usage of the attribute title for the element iframe.
useKeyWithClickEventsEnforce onClick is accompanied by at least one of the following: onKeyUp, onKeyDown, onKeyPress.
useKeyWithMouseEventsEnforce onMouseOver / onMouseOut are accompanied by onFocus / onBlur.
useMediaCaptionEnforces that audio and video elements must have a track for captions.
useSemanticElementsIt detects the use of role 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 aria-* are all valid.
useValidAriaRoleElements with ARIA roles must use a valid, non-abstract ARIA role.
useValidAriaValuesEnforce that ARIA state and property values are valid.
useValidAutocompleteUse valid values for the autocomplete attribute on input elements.
useValidLangEnsure that the attribute passed to the lang attribute is a correct ISO language and/or country.
Rule nameDescriptionProperties
noAdjacentSpacesInRegexDisallow unclear usage of consecutive space characters in regular expression literals
noArgumentsDisallow the use of arguments.
noBannedTypesDisallow primitive type aliases and misleading types.
noCommaOperatorDisallow comma operator.
noEmptyTypeParametersDisallow empty type parameters in type aliases and interfaces.
noExcessiveCognitiveComplexityDisallow functions that exceed a given Cognitive Complexity score.
noExcessiveLinesPerFunctionRestrict the number of lines of code in a function.
noExcessiveNestedTestSuitesThis rule enforces a maximum depth to nested describe() in test files.
noExtraBooleanCastDisallow unnecessary boolean casts
noFlatMapIdentityDisallow to use unnecessary callback on flatMap.
noForEachPrefer for...of statement instead of Array.forEach.
noImplicitCoercionsDisallow shorthand type conversions.
noStaticOnlyClassThis rule reports when a class has no non-static members, such as for a class used exclusively as a static namespace.
noThisInStaticDisallow this and super in static contexts.
noUselessCatchDisallow unnecessary catch clauses.
noUselessConstructorDisallow unnecessary constructors.
noUselessContinueAvoid using unnecessary continue.
noUselessEmptyExportDisallow empty exports that don’t change anything in a module file.
noUselessEscapeInRegexDisallow unnecessary escape sequence in regular expression literals.
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.
noUselessStringRawDisallow unnecessary String.raw function in template string literals without any escape sequence.
noUselessSwitchCaseDisallow useless case in switch statements.
noUselessTernaryDisallow ternary operators when simpler alternatives exist.
noUselessThisAliasDisallow useless this aliasing.
noUselessTypeConstraintDisallow using any or unknown as type constraint.
noUselessUndefinedInitializationDisallow initializing variables to undefined.
noVoidDisallow the use of void operators, which is not a familiar operator.
useArrowFunctionUse arrow functions over function expressions.
useDateNowUse Date.now() to get the number of milliseconds since the Unix Epoch.
useFlatMapPromotes the use of .flatMap() when map().flat() are used together.
useIndexOfPrefer Array#{indexOf,lastIndexOf}() over Array#{findIndex,findLastIndex}() when looking for the index of an item.
useLiteralKeysEnforce the usage of a literal access to properties over computed property access.
useNumericLiteralsDisallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals
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 base 10 or use underscore as separator.
useSimplifiedLogicExpressionDiscard redundant terms from logical expressions.
useWhileEnforce the use of while loops instead of for loops when the initializer and update expressions are not needed.
Rule nameDescriptionProperties
noChildrenPropPrevent passing of children as props.
noConstAssignPrevents from having const variables being re-assigned.
noConstantConditionDisallow constant expressions in conditions
noConstantMathMinMaxClampDisallow the use of Math.min and Math.max to clamp a value where the result itself is constant.
noConstructorReturnDisallow returning a value from a constructor.
noEmptyCharacterClassInRegexDisallow empty character classes in regular expression literals.
noEmptyPatternDisallows empty destructuring patterns.
noGlobalDirnameFilenameDisallow the use of __dirname and __filename in the global scope.
noGlobalObjectCallsDisallow calling global object properties as functions
noInnerDeclarationsDisallow function and var declarations that are accessible outside their block.
noInvalidBuiltinInstantiationEnsure that builtins are correctly instantiated.
noInvalidConstructorSuperPrevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.
noInvalidUseBeforeDeclarationDisallow the use of variables, function parameters, classes, and enums before their declaration
noNestedComponentDefinitionsDisallows defining React components inside other components.
noNodejsModulesForbid the use of Node.js builtin modules.
noNonoctalDecimalEscapeDisallow \8 and \9 escape sequences in string literals.
noPrecisionLossDisallow literal numbers that lose precision
noPrivateImportsRestrict imports of private exports.
noProcessGlobalDisallow the use of process global.
noQwikUseVisibleTaskDisallow useVisibleTask$() functions in Qwik components.
noReactPropAssignmentsDisallow assigning to React component props.
noRenderReturnValuePrevent the usage of the return value of React.render.
noRestrictedElementsDisallow the use of configured elements.
noSelfAssignDisallow assignments where both sides are exactly the same.
noSetterReturnDisallow returning a value from a setter
noSolidDestructuredPropsDisallow destructuring props inside JSX components in Solid projects.
noStringCaseMismatchDisallow comparison of expressions modifying the string case with non-compliant value.
noSwitchDeclarationsDisallow lexical declarations in switch clauses.
noUndeclaredDependenciesDisallow the use of dependencies that aren’t specified in the package.json.
noUndeclaredVariablesPrevents the usage of variables that haven’t been declared inside the document.
noUnreachableDisallow unreachable code
noUnreachableSuperEnsures 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
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’
useExhaustiveDependenciesEnforce correct dependency usage within React hooks.
useHookAtTopLevelEnforce that all React hooks are being called from the Top Level component functions.
useImageSizeEnforces that <img> elements have both width and height attributes.
useImportExtensionsEnforce file extensions for relative imports.
useIsNanRequire calls to isNaN() when checking for NaN.
useJsonImportAttributesEnforces the use of with { type: "json" } for JSON module imports.
useJsxKeyInIterableDisallow missing key props in iterators/collection literals.
useParseIntRadixEnforce the consistent use of the radix argument when using parseInt().
useQwikClasslistPrefer using the class prop as a classlist over the classnames helper.
useSingleJsDocAsteriskEnforce JSDoc comment lines to start with a single asterisk, except for the first one.
useUniqueElementIdsPrevent the usage of static string literal id attribute on elements.
useValidForDirectionEnforce “for” loop update clause moving the counter in the right direction.
useValidTypeofThis rule checks that the result of a typeof expression is compared to a valid value.
useYieldRequire generator functions to contain yield.
Rule nameDescriptionProperties
noAmbiguousAnchorTextDisallow ambiguous anchor descriptions.
noBeforeInteractiveScriptOutsideDocumentPrevent usage of next/script’s beforeInteractive strategy outside of pages/_document.js in a Next.js project.
noContinueDisallow continue statements.
noDeprecatedImportsRestrict imports of deprecated exports.
noDuplicateEnumValuesDisallow duplicate enum member values.
noDuplicatedSpreadPropsDisallow JSX prop spreading the same identifier multiple times.
noEmptySourceDisallow empty sources.
noEqualsToNullRequire the use of === or !== for comparison with null.
noExcessiveLinesPerFileRestrict the number of lines in a file.
noFloatingPromisesRequire Promise-like statements to be handled appropriately.
noForInDisallow iterating using a for-in loop.
noImportCyclesPrevent import cycles.
noIncrementDecrementDisallows the usage of the unary operators ++ and —.
noJsxLiteralsDisallow string literals inside JSX elements.
noJsxPropsBindDisallow .bind(), arrow functions, or function expressions in JSX props
noLeakedRenderPrevent problematic leaked values from being rendered.
noMisusedPromisesDisallow Promises to be used in places where they are almost certainly a
noMultiAssignDisallow use of chained assignment expressions
noMultiStrDisallow creating multiline strings by escaping newlines.
noNextAsyncClientComponentPrevent client components from being async functions.
noParametersOnlyUsedInRecursionDisallow function parameters that are only used in recursive calls.
noProtoDisallow the use of the deprecated __proto__ object property.
noReactForwardRefReplaces usages of forwardRef with passing ref as a prop.
noReturnAssignDisallow assignments in return statements.
noScriptUrlDisallow javascript: URLs.
noShadowDisallow variable declarations from shadowing variables declared in the outer scope.
noSyncScriptsPrevent the usage of synchronous scripts.
noTernaryDisallow ternary operators.
noUndeclaredEnvVarsDisallow the use of undeclared environment variables.
noUnknownAttributeDisallow unknown DOM properties.
noUnnecessaryConditionsDisallow unnecessary type-based conditions that can be statically determined as redundant.
noUnresolvedImportsWarn when importing non-existing exports.
noUnusedExpressionsDisallow expression statements that are neither a function call nor an
noUselessCatchBindingDisallow unused catch bindings.
noUselessUndefinedDisallow the use of useless undefined.
noVueDataObjectDeclarationEnforce that Vue component data options are declared as functions.
noVueDuplicateKeysDisallow duplicate keys in Vue component data, methods, computed properties, and other options.
noVueOptionsApiDisallow the use of Vue Options API.
noVueReservedKeysDisallow reserved keys in Vue component data and computed properties.
noVueReservedPropsDisallow reserved names to be used as props.
noVueSetupPropsReactivityLossDisallow destructuring of props passed to setup in Vue projects.
useArraySortCompareRequire Array#sort and Array#toSorted calls to always provide a compareFunction.
useAwaitThenableEnforce that await is only used on Promise values.
useConsistentArrowReturnEnforce consistent arrow function bodies.
useDestructuringRequire destructuring from arrays and/or objects
useErrorCauseEnforce that new Error() is thrown with the original error as cause.
useExhaustiveSwitchCasesRequire switch-case statements to be exhaustive.
useExplicitTypeEnforce types in functions, methods, variables, and parameters.
useFindEnforce the use of Array.prototype.find() over Array.prototype.filter() followed by [0] when looking for a single result.
useMaxParamsEnforce a maximum number of parameters in function definitions.
useQwikMethodUsageDisallow use* hooks outside of component$ or other use* hooks in Qwik applications.
useQwikValidLexicalScopeDisallow unserializable expressions in Qwik dollar ($) scopes.
useRegexpExecEnforce RegExp#exec over String#match if no global flag is provided.
useSortedClassesEnforce the sorting of CSS utility classes.
useSpreadEnforce the use of the spread operator over .apply().
useVueConsistentDefinePropsDeclarationEnforce consistent defineProps declaration style.
useVueDefineMacrosOrderEnforce specific order of Vue compiler macros.
useVueMultiWordComponentNamesEnforce multi-word component names in Vue components.
Rule nameDescriptionProperties
noAccumulatingSpreadDisallow the use of spread (...) syntax on accumulators.
noAwaitInLoopsDisallow await inside loops.
noBarrelFileDisallow the use of barrel file.
noDeleteDisallow the use of the delete operator.
noDynamicNamespaceImportAccessDisallow accessing namespace imports dynamically.
noImgElementPrevent usage of <img> element in a Next.js project.
noNamespaceImportDisallow the use of namespace imports.
noReExportAllAvoid re-export all.
noUnwantedPolyfillioPrevent duplicate polyfills from Polyfill.io.