Skip to content

Fix(Validator): False positives on min()/max()/clamp() and modern CSS - #418

Closed
0Miles wants to merge 1 commit into
master-co:rcfrom
0Miles:fix/eslint-validator-min-max-clamp
Closed

0Miles wants to merge 1 commit into
master-co:rcfrom
0Miles:fix/eslint-validator-min-max-clamp

Conversation

@0Miles

@0Miles 0Miles commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Closes #405, #323, #331.

Summary

The validator's existing TODO-marked workaround for math functions only checked the error fragment (`error.css`) for `min(`/`max(`/`clamp(` substrings. Some mismatches surface only a sub-token (e.g. `right: max(0px, 1rem)` reports the bare `0px` arg), so the suppression missed valid usages and the user saw false positives.

Changes

  • `packages/validator/src/validate-css.ts` — (a) check the FULL value text in addition to `error.css` (b) extended math-fn list to all CSS Values 4 functions: `calc`/`min`/`max`/`clamp`/`sin`/`cos`/`tan`/`asin`/`acos`/`atan`/`atan2`/`exp`/`log`/`pow`/`sqrt`/`hypot`/`abs`/`sign`/`round`/`mod`/`rem`
  • New `packages/validator/tests/issue-405-math-fns.test.ts` — 16 cases (min/max/clamp/calc/oklch/rotate/aspect-ratio/contain/container-type all valid; truly invalid still errors)
  • New `packages/eslint-plugin/tests/issues/405/test.ts` — 7 RuleTester cases including `right:max(0px,1rem)` (🐞 Invalid value for right property #323), `font-size:clamp(1rem,calc(2vw+1rem),3rem)`, `aspect:16/9`, `rotate:45deg`

Scope note

`#338` was originally tagged in the same umbrella but it's a separate feature (recommended-syntax warnings, new lint rules), not a validator suppression issue. Shipped separately as PR #420 (feat/338-eslint-recommended-syntax).

Testing

  • 16/16 validator tests pass; 7/7 eslint-plugin tests pass; all 14 plugin test files + all 3 validator test files green

@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

@0Miles is attempting to deploy a commit to the Aoyue Team on Vercel.

A member of the Team first needs to authorize it.

@0Miles 0Miles changed the title fix(validator): broaden math-fn suppression to full value text + sin/cos/etc, resolve #405 #323 #331 Fix(Validator): False positives on min()/max()/clamp() and modern CSS Apr 30, 2026
The validator's existing TODO-marked workaround for math functions
only checked the error fragment (error.css) for min(/max(/clamp(
substrings. Some mismatches surface only a sub-token (e.g.
right: max(0px, 1rem) reports the bare 0px arg), so the suppression
missed valid usages and users saw false positives.

- validate-css.ts: check FULL value text in addition to error.css
- Extended math-fn list to all CSS Values 4 functions: calc, min,
  max, clamp, sin, cos, tan, asin, acos, atan, atan2, exp, log,
  pow, sqrt, hypot, abs, sign, round, mod, rem
- 16 validator test cases (min/max/clamp/calc/oklch/rotate/
  aspect-ratio/contain/container-type valid; truly invalid still
  errors) + 7 eslint-plugin RuleTester cases including right:max(),
  font-size:clamp(calc()), aspect:16/9

Scope: master-co#338 was originally tagged in the same umbrella but it's a
separate feature (recommended-syntax warnings, new lint rules) — see
PR master-co#428.

Closes master-co#405
Closes master-co#323
Closes master-co#331
@0Miles
0Miles force-pushed the fix/eslint-validator-min-max-clamp branch from a0a7eef to c04aa46 Compare April 30, 2026 19:02
@0Miles

0Miles commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

Retracting for further design verification. The fix is an extension of the existing math-fn suppression hack (broader scope, full value text scan), but issue #331 originally only included a screenshot — no repro string — so my test cases approximated the symptom. Before re-submitting I want to: (a) get a concrete #331 repro from the reporter or upstream, (b) decide whether the proper fix is a deeper css-tree spec-data update vs continuing the suppression-list approach.

Code is preserved on branch fix/eslint-validator-min-max-clamp for re-submission once the design is firmer.

@0Miles 0Miles closed this Apr 30, 2026
1aron added a commit that referenced this pull request May 3, 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.

ESlint does not support min max clamp and other functions

1 participant