Back to Biomejs

HTML Rules

src/content/docs/linter/html/rules.mdx

latest12.3 KB
Original Source

import { Icon } from "@astrojs/starlight/components";

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

  • The icon <span class='inline-icon' title="This rule is recommended"><Icon name="approve-check-circle" label="This rule is recommended" /></span> indicates that the rule is part of the recommended rules.
  • The icon <span class='inline-icon' title="This rule has a safe fix"><Icon name="seti:config" label="The rule has a safe fix" /></span> indicates that the rule provides a code action (fix) that is safe to apply.
  • The icon <span class='inline-icon' title="This rule has an unsafe fix"><Icon name="warning" label="The rule has an unsafe fix" /></span> indicates that the rule provides a code action (fix) that is unsafe to apply.
  • The icon <span class='inline-icon' title="This rule is not released yet"><Icon name="moon" label="This rule is not released yet" /></span> indicates that the rule has been implemented and scheduled for the next release.

a11y

Rule nameDescriptionProperties
noAccessKeyEnforce that the accesskey attribute is not used on any HTML element.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span><span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
noAutofocusEnforce that the autofocus attribute is not used on elements.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span><span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
noDistractingElementsEnforces that no distracting elements are used.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span><span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
noHeaderScopeThe scope prop should be used only on <th> elements.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span><span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
noPositiveTabindexPrevent the usage of positive integers on tabindex attribute.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span><span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
noRedundantAltEnforce img alt prop does not contain the word "image", "picture", or "photo".<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noSvgWithoutTitleEnforces the usage of the title element for the svg element.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
useAltTextEnforce that all elements that require alternative text have meaningful information to relay back to the end user.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
useAnchorContentEnforce that anchors have content and that the content is accessible to screen readers.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span><span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
useAriaPropsForRoleEnforce that elements with ARIA roles must have all required ARIA attributes for that role.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
useButtonTypeEnforces the usage and validity of the attribute type for the element button<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
useHtmlLangEnforce that html element has lang attribute.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
useIframeTitleEnforces the usage of the attribute title for the element iframe.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
useMediaCaptionEnforces that audio and video elements must have a track for captions.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
useValidAriaRoleElements with ARIA roles must use a valid, non-abstract ARIA role.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span><span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
useValidLangEnsure that the attribute passed to the lang attribute is a correct ISO language and/or country.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>

nursery

Rule nameDescriptionProperties
noAmbiguousAnchorTextDisallow ambiguous anchor descriptions.
noDuplicateAttributesDisallow duplication of attributes.
noScriptUrlDisallow javascript: URLs in HTML.
noSyncScriptsPrevent the usage of synchronous scripts.
noVueVIfWithVForDisallow using v-if and v-for directives on the same element.
useScopedStylesEnforce that <style> blocks in Vue SFCs have the scoped attribute and that <style> blocks in Astro components do not have the is:global directive.<span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
useVueConsistentVBindStyleEnforce a consistent style for v-bind in Vue templates.<span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
useVueConsistentVOnStyleEnforce a consistent style for v-on in Vue templates.<span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
useVueHyphenatedAttributesEnforce hyphenated (kebab-case) attribute names in Vue templates.<span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
useVueVForKeyEnforce that elements using v-for also specify a unique key.
useVueValidTemplateRootEnforce valid Vue <template> root usage.<span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
useVueValidVBindForbids v-bind directives with missing arguments or invalid modifiers.
useVueValidVCloakEnforce valid v-cloak Vue directives.<span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
useVueValidVElseEnforce valid usage of v-else.
useVueValidVElseIfEnforce valid v-else-if directives.
useVueValidVHtmlEnforce valid v-html directives.
useVueValidVIfEnforces valid v-if usage for Vue templates.
useVueValidVOnEnforce valid v-on directives with proper arguments, modifiers, and handlers.
useVueValidVOnceEnforce valid v-once Vue directives.<span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
useVueValidVPreEnforce valid v-pre Vue directives.<span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>
useVueValidVTextEnforce valid v-text Vue directives.
useVueVaporEnforce opting in to Vue Vapor mode in <script setup> blocks.<span class='inline-icon' title="The rule has an unsafe fix" ><Icon name="warning" label="The rule has an unsafe fix" size="1.2rem" /></span>

Missing a rule? Help us by contributing to the analyzer or create a rule suggestion here.