Back to Biomejs

CSS Rules

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

latest12.7 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
useGenericFontNamesDisallow a missing generic family keyword within font families.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>

complexity

Rule nameDescriptionProperties
noImportantStylesDisallow the use of the !important style.<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>

correctness

Rule nameDescriptionProperties
noInvalidDirectionInLinearGradientDisallow non-standard direction values for linear gradient functions.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noInvalidGridAreasDisallows invalid named grid areas in CSS Grid Layouts.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noInvalidPositionAtImportRuleDisallow the use of @import at-rules in invalid positions.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noMissingVarFunctionDisallow missing var function for css variables.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noUnknownFunctionDisallow unknown CSS value functions.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noUnknownMediaFeatureNameDisallow unknown media feature names.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noUnknownPropertyDisallow unknown properties.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noUnknownPseudoClassDisallow unknown pseudo-class selectors.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noUnknownPseudoElementDisallow unknown pseudo-element selectors.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noUnknownTypeSelectorDisallow unknown type selectors.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noUnknownUnitDisallow unknown CSS units.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noUnmatchableAnbSelectorDisallow unmatchable An+B selectors.<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
noDeprecatedMediaTypeDisallow deprecated media types.
noExcessiveLinesPerFileRestrict the number of lines in a file.
noHexColorsDisallow hex colors.
useBaselineDisallow CSS properties, values, at-rules, functions, and selectors that are not part of the configured Baseline.<span class='inline-icon' title="This rule is not released yet"><Icon name="moon" label="This rule is not released yet" size="1.2rem" /></span>

style

Rule nameDescriptionProperties
noDescendingSpecificityDisallow a lower specificity selector from coming after a higher specificity selector.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noValueAtRuleDisallow use of @value rule in CSS modules.

suspicious

Rule nameDescriptionProperties
noDuplicateAtImportRulesDisallow duplicate @import rules.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noDuplicateCustomPropertiesDisallow duplicate custom properties within declaration blocks.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noDuplicateFontNamesDisallow duplicate names within font families.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noDuplicatePropertiesDisallow duplicate properties within declaration blocks.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noDuplicateSelectorsKeyframeBlockDisallow duplicate selectors within keyframe blocks.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noEmptyBlockDisallow CSS empty blocks.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noEmptySourceDisallow empty sources.
noImportantInKeyframeDisallow invalid !important within keyframe declarations<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noIrregularWhitespaceDisallows the use of irregular whitespace characters.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noShorthandPropertyOverridesDisallow shorthand properties that override related longhand properties.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noUnknownAtRulesDisallow unknown at-rules.<span class='inline-icon' title="This rule is recommended" ><Icon name="approve-check-circle" size="1.2rem" label="This rule is recommended" /></span>
noUselessEscapeInStringDisallow unnecessary escapes in string literals.<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 a safe fix.'><Icon name="seti:config" label="The rule has a safe fix" size="1.2rem" /></span>

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