Skip to content

feat(stylelint-config): let a color function derive a color from tokens in flat-layers - #229

Merged
dangreen merged 1 commit into
mainfrom
feat/stylelint-derived-colors
Nov 25, 2026
Merged

dangreen merged 1 commit into
mainfrom
feat/stylelint-derived-colors

Conversation

@dangreen

Copy link
Copy Markdown
Member

flat-layers keeps colors in the tokens' file. Outside it, function-disallowed-list banned every color function by name, color-mix() and rgb() included. A color function that only derives a color from what the page already has is no new color, though. Examples:

  • an underline at 40% of the words' ink: color-mix(in srgb, currentcolor 40%, transparent);
  • a mark's hairline in its own ink;
  • a scrim's colour at another alpha: rgb(from var(--colorOverlayScrim) r g b / …).

A new rule, trigen/no-bare-color-function, takes the color functions out of that list. A color function passes when every color it takes is a var(), currentcolor, transparent or a color function that passes in turn:

  • color-mix(): the colors after the color space, their percentages aside;
  • the relative syntax, as rgb(from …): the color after from.

Channels written out, a named color or a hex inside make a color of its own and are reported, as before. This is decided by the value's syntax alone, with postcss-value-parser. The tokens' file, variables.css, stays free of the rule, as it is of the list. cubic-bezier() and steps() stay in the list.

On plant1t-web this clears 7 findings (color-mix() ×6, rgb(from …) ×1), and the rule finds nothing else in its 131 stylesheets.

🤖 Generated with Claude Code

@dangreen
dangreen merged commit fc2602f into main Nov 25, 2026
6 checks passed
@dangreen
dangreen deleted the feat/stylelint-derived-colors branch November 25, 2026 21:01
@github-actions github-actions Bot mentioned this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant