Skip to content

design-token/font-size

Summary

Ensures font-size declarations use values from your fontSizes tokens.

Configuration

Enable the rule in designlint.config.*. See configuration for defining tokens.

json
{
  "tokens": {
    "$version": "1.0.0",
    "fontSizes": {
      "base": {
        "$type": "dimension",
        "$value": { "dimensionType": "length", "value": 1, "unit": "rem" }
      },
      "lg": { "$type": "dimension", "$ref": "#/fontSizes/base" }
    }
  },
  "rules": { "design-token/font-size": "error" }
}

Font-size tokens use the dimension type with dimensionType set to length and explicit units.

Options

No additional options.

This rule is not auto-fixable.

Examples

Invalid

css
.title { font-size: 18px; }

Valid

css
.title { font-size: 1rem; }
.title { font-size: 20px; }

When Not To Use

If font sizes are not managed via tokens, disable this rule.

See also

Released under the MIT License.