Skip to content

feat(lint/css): add noHexColors#8860

Merged
dyc3 merged 1 commit intomainfrom
dyc3/no-hex-colors
Jan 28, 2026
Merged

feat(lint/css): add noHexColors#8860
dyc3 merged 1 commit intomainfrom
dyc3/no-hex-colors

Conversation

@dyc3
Copy link
Contributor

@dyc3 dyc3 commented Jan 25, 2026

Summary

Port https://stylelint.io/user-guide/rules/color-no-hex/

Generated by gpt-5.2-codex

Test Plan

snapshots

Docs

@changeset-bot
Copy link

changeset-bot bot commented Jan 25, 2026

🦋 Changeset detected

Latest commit: 7c19ff3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter L-CSS Language: CSS A-Diagnostic Area: diagnostocis labels Jan 25, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 25, 2026

Walkthrough

A new CSS linter rule noHexColors was added to the nursery rules. The rule detects hexadecimal colour literals in CSS and reports them, recommending named colours or colour functions (rgb/rgba/hsl/hsla/oklch). Changes include the rule implementation, a NoHexColorsOptions options type, tests for valid and invalid cases, a changeset entry, and documentation/metadata tying the rule to Stylelint's color-no-hex.

Possibly related PRs

Suggested reviewers

  • ematipico
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a new CSS linter rule named noHexColors to Biome.
Description check ✅ Passed The description is related to the changeset, explaining the motivation (porting a Stylelint rule) and test approach, though it could be more detailed.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.changeset/quiet-hounds-shout.md:
- Line 5: Add a short inline "invalid example" to the changeset entry for the
new nursery rule noHexColors by inserting a concise code snippet that
demonstrates a hex color being flagged (for example a CSS declaration like
color: `#ff0000`;), so the changeset includes a clear invalid example for the
linter; update .changeset/quiet-hounds-shout.md near the rule description to
include this single-line invalid snippet.

"@biomejs/biome": patch
---

Added the nursery rule [`noHexColors`](https://biomejs.dev/linter/rules/no-hex-colors/), which flags the use of hexadecimal color codes in CSS and suggests using named colors or RGB/RGBA/HSL/HSLA formats instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Please add an invalid example to the changeset.

A short inline snippet is required for new lint rules in changesets. Based on learnings, please include one.

✍️ Suggested tweak
-Added the nursery rule [`noHexColors`](https://biomejs.dev/linter/rules/no-hex-colors/), which flags the use of hexadecimal color codes in CSS and suggests using named colors or RGB/RGBA/HSL/HSLA formats instead.
+Added the nursery rule [`noHexColors`](https://biomejs.dev/linter/rules/no-hex-colors/), which flags the use of hexadecimal color codes in CSS and suggests using named colors or RGB/RGBA/HSL/HSLA formats instead. Example (invalid): `a { color: `#000`; }`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Added the nursery rule [`noHexColors`](https://biomejs.dev/linter/rules/no-hex-colors/), which flags the use of hexadecimal color codes in CSS and suggests using named colors or RGB/RGBA/HSL/HSLA formats instead.
Added the nursery rule [`noHexColors`](https://biomejs.dev/linter/rules/no-hex-colors/), which flags the use of hexadecimal color codes in CSS and suggests using named colors or RGB/RGBA/HSL/HSLA formats instead. Example (invalid): `a { color: `#000`; }`
🤖 Prompt for AI Agents
In @.changeset/quiet-hounds-shout.md at line 5, Add a short inline "invalid
example" to the changeset entry for the new nursery rule noHexColors by
inserting a concise code snippet that demonstrates a hex color being flagged
(for example a CSS declaration like color: `#ff0000`;), so the changeset includes
a clear invalid example for the linter; update .changeset/quiet-hounds-shout.md
near the rule description to include this single-line invalid snippet.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 25, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 16.25%

Comparing dyc3/no-hex-colors (7c19ff3) with main (f924f23)

Summary

❌ 4 regressed benchmarks
✅ 25 untouched benchmarks
⏩ 126 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
css_analyzer[bootstrap_18416142857265205439.css] 515.5 ms 573.8 ms -10.15%
css_analyzer[tachyons_11778168428173736564.css] 140.9 ms 167.3 ms -15.76%
css_analyzer[foundation_11602414662825430680.css] 191.4 ms 228.5 ms -16.25%
css_analyzer[pure_9395922602181450299.css] 20.2 ms 22.1 ms -8.53%

Footnotes

  1. 126 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@dyc3 dyc3 force-pushed the dyc3/no-hex-colors branch from c5cc14a to 7c19ff3 Compare January 28, 2026 13:12
@dyc3 dyc3 merged commit 95f1eea into main Jan 28, 2026
19 of 20 checks passed
@dyc3 dyc3 deleted the dyc3/no-hex-colors branch January 28, 2026 14:26
@github-actions github-actions bot mentioned this pull request Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project L-CSS Language: CSS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants