Skip to content

fix(css): add missing CSS functions to noUnknownFunction#8926

Closed
andre-lmarinho wants to merge 3 commits intobiomejs:mainfrom
andre-lmarinho:fix/modern-css-functions
Closed

fix(css): add missing CSS functions to noUnknownFunction#8926
andre-lmarinho wants to merge 3 commits intobiomejs:mainfrom
andre-lmarinho:fix/modern-css-functions

Conversation

@andre-lmarinho
Copy link
Copy Markdown

@andre-lmarinho andre-lmarinho commented Jan 31, 2026

Summary

This PR extends the noUnknownFunction CSS linter rule to recognize five additional modern CSS functions that were previously being flagged as unknown:

  • contrast-color() - Calculates a contrasting color value
  • dynamic-range-limit-mix() - Mixes dynamic range limits for HDR content
  • progress() - Progress notation for scroll-driven animations
  • superellipse() - Defines corner shapes using superellipse curves

Motivation: Similar to PR #8924 which added sibling-count() and sibling-index(), these are valid CSS functions defined in various CSS specification modules (CSS Color Module Level 5, CSS Values and Units Module Level 5, CSS Borders Module Level 4). Currently, Biome incorrectly reports these as unknown functions, causing false positives in projects using modern CSS features.

Related: This extends the work from #8920 to cover additional CSS functions that have emerged in recent specifications.

Browser Compatibility

Function Status Chrome Firefox Safari Experimental
contrast-color() Standard Track ✅ 146+ ✅ 26+ No
dynamic-range-limit-mix() Standard Track ✅ 136+ Yes
progress() Standard Track ✅ 138+ ✅ 26+ No
superellipse() Standard Track ✅ 139+ Yes

Note: While some of these functions are marked as experimental and have limited browser support, they are part of official CSS specifications. Including them in Biome's function list allows developers working with cutting-edge CSS features or progressive enhancement to avoid false positives in linting.

Documentation

Changeset

A changeset has been created in .changeset/brave-lions-smile.md.

Test Plan

Added test cases for all five functions in valid.css:

a { color: contrast-color(#000); }
a { color: dynamic-range-limit-mix(standard 50%, high 50%); }
a { animation-delay: progress(scroll() from 0% to 100%); }
a { clip-path: superellipse(50% 50%, 80% 80%, 2.5); }

The functions were added to the FUNCTION_KEYWORDS array in keywords.rs in alphabetical order, following the existing pattern.

When tests are run, these functions should no longer trigger the noUnknownFunction diagnostic.

Docs

No additional documentation needed - this is an additive change to the existing noUnknownFunction rule's keyword list. The rule behavior remains unchanged; it simply recognizes additional valid CSS functions.

Disclaimer!

This PR was created with AI assistance (Claude Code). Claude Code was used to explore the repository structure and review existing CSS functions. The results were then manually validated against the official MDN documentation to confirm accuracy and identify gaps.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 31, 2026

🦋 Changeset detected

Latest commit: 9b6f999

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-Linter Area: linter L-CSS Language: CSS and super languages labels Jan 31, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 31, 2026

Walkthrough

Adds four CSS function names — contrast-color, dynamic-range-limit-mix, progress, and superellipse — to the FUNCTION_KEYWORDS constant in the Biome CSS analyser. Adds corresponding valid tests to noUnknownFunction and a changeset patch entry for the @biomejs/biome release note documenting recognition of these functions.

Possibly related PRs

  • biomejs/biome PR 8846: Modifies the same FUNCTION_KEYWORDS constant to recognise additional CSS functions.
  • biomejs/biome PR 8924: Extends FUNCTION_KEYWORDS and adds noUnknownFunction tests for new function names.

Suggested reviewers

  • ematipico
  • siketyan
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: adding missing CSS functions to the noUnknownFunction linter rule.
Description check ✅ Passed The pull request description clearly explains the addition of four CSS functions to the noUnknownFunction rule, with motivation, browser compatibility, documentation links, and test cases.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
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 `@crates/biome_css_analyze/src/keywords.rs`:
- Around line 681-685: The FUNCTION_KEYWORDS array is out of alphabetical order:
the entry "if" must come before the "image", "image-rect", and "image-set"
entries to satisfy test_function_keywords_sorted; update the FUNCTION_KEYWORDS
definition by moving "if" so the list is alphabetically sorted (ensure the
symbol FUNCTION_KEYWORDS is updated accordingly).

Comment thread crates/biome_css_analyze/src/keywords.rs
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jan 31, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing andre-lmarinho:fix/modern-css-functions (98f5421) with main (871b45e)

Summary

✅ 29 untouched benchmarks
⏩ 126 skipped benchmarks1

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 previously approved these changes Jan 31, 2026
@andre-lmarinho
Copy link
Copy Markdown
Author

Question for Reviewers

I noticed that adding tests for these five new functions increased the parser diagnostic count from 3 to 5 in the valid.css.snap snapshot:

-Note: The parser emitted 3 diagnostics which are not shown here.
+Note: The parser emitted 5 diagnostics which are not shown here.

This suggests that some of the new CSS functions I added may have syntax that the Biome CSS parser doesn't fully recognize yet. The functions themselves are now recognized by noUnknownFunction (which was the goal), but the parser emits additional diagnostics when parsing them.

Questions:

  1. Is this acceptable, or should we only add functions that the parser can handle without emitting diagnostics?
  2. Should I adjust the test cases to use simpler syntax that doesn't trigger parser diagnostics?
  3. Alternatively, should we skip adding tests for functions that cause parser issues?

I'm happy to modify the PR based on your guidance. Let me know which approach you prefer.

@ematipico
Copy link
Copy Markdown
Member

Are you really asking us questions via claude code? Damn, that's so demoralising...

We shouldn't increase the diagnostics, so make sure the parser is correct

Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Blocking, since the issue is in the parser, not the linter only

@dyc3 dyc3 dismissed their stale review January 31, 2026 23:41

new info

@andre-lmarinho
Copy link
Copy Markdown
Author

I removed the functions both from the tests and from the keyword list, so there’s nothing in the codebase without proper parser support / coverage. Do you want me to document this function as an Issue?

@ematipico
Copy link
Copy Markdown
Member

Why was if added?

@andre-lmarinho
Copy link
Copy Markdown
Author

andre-lmarinho commented Feb 1, 2026

It's a valid CSS function. Doc | compatibility

But, tbh I'm not sure that this was the right way to implement it. Rust is not my expertise, just trying to help here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-CSS Language: CSS and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants