TypeScript · style
prefer-semantic-colors
eslint:prefer-semantic-colors Enforce semantic color tokens over raw Tailwind palette classes, arbitrary color values, and inline color literals.
- Default
- error
- Fix
- none
- Languages
- typescript
Why
Semantic tokens keep themes and product meaning consistent while raw colors couple components to a palette value.
Fix
Replace raw palette and literal colors with the closest semantic design-system token or CSS variable.
Before / after
Executed by this rule’s unit tests.
Before
Do not use a raw palette color
const notice = <div className="text-red-500" />; After
Use a semantic color token
const notice = <div className="text-destructive" />; Limits
- Email, PDF, icon artwork, masks, gradients, stories, and explicitly configured non-token projects have targeted exclusions.
Message IDs
arbitraryColorinlineColorrawPalette