neo icon indicating copy to clipboard operation
neo copied to clipboard

Add PostCSS CSS hygiene guard for deprecated syntax and bare colors

Open neo-gemini-maryam opened this issue 1 day ago • 2 comments

Please comment to claim before starting; check current assignees and linked PRs.

Context

Neo already enforces vendor-prefix discipline (buildScripts/util/check-css-vendor-prefixes.mjs, tested by test/playwright/unit/buildScripts/checkCssVendorPrefixes.spec.mjs and wired into .github/workflows/pr-baseline.yml) plus eight theme-architecture guards (theme-census, check-theme-palette, check-theme-surfaces, check-theme-property-prefix, check-theme-class-prefix, check-theme-coverage, check-theme-radius-literals, check-theme-var-references). However, none of those guards currently catch obsolete WebKit syntax (-webkit-gradient, -webkit-fill-available, -webkit-overflow-scrolling), deprecated CSS 2.1 clip: rect(...), double-semicolon typos (;;), !important inside theme custom-property declarations, or Sass-compiled multi-decimal percentage rgb(...) literals. This leaf adds a dedicated PostCSS CSS hygiene guard under #23186 so cleaned-up patterns cannot regress.

The Problem

Our audit across resources/css/ found legacy patterns that silently pass every existing CI check:

  • -webkit-gradient(...) (4 files), -webkit-fill-available (1 file), -webkit-overflow-scrolling (1 file) — explicitly left out of check-css-vendor-prefixes.mjs (which focuses on autoprefixer-owned properties and prefix-after-standard cascade bugs).
  • Deprecated clip: rect(...) (8 files under resources/css/src/).
  • Double-semicolon declaration typos (;; in calendar/view/week/Component.css:90 and grid/header/Button.css:87).
  • !important inside theme custom-property declarations (resources/css/theme-classic/util/HighlightJsLineNumbers.css:5,12).
  • Sass-compiled high-precision percentage rgb(91.2429971989%, ...) literals (60 occurrences across apps/colors/GridContainer.css, theme-classic/, and theme-neo/).

Without an AST-level PostCSS guard (with an explicit shrinking baseline ratchet), contributors and agents can accidentally re-introduce these legacy patterns in future PRs.

The Architectural Reality

buildScripts/util/check-css-vendor-prefixes.mjs provides the exact architectural blueprint:

  • Exports SCAN_SURFACE = Object.freeze(['resources/css/**/*.css']) (consumed by pr-baseline.yml change classification).
  • Parses every CSS file via postcss (themeCss.mjs's cssFiles() helper) and exports pure check functions for unit testing in test/playwright/unit/buildScripts/.
  • Runs via package.json (check-css-* script) and .github/workflows/pr-baseline.yml baseline matrix.
  • Existing guards like check-theme-radius-literals.mjs and check-theme-coverage.mjs use explicit, stale-failing baseline allowlists (if an allowlisted file is fixed and no longer violates, the guard fails until the stale allowlist entry is removed, ratcheting debt strictly downward).

Because sibling cleanup leaves under #23186 may land before or after this guard, using a strictly ratcheting baseline allowlist lets this guard land immediately without waiting on every CSS cleanup PR — rejecting any new violation on day 1 and forcing each cleanup PR to remove its cleared entries.

Design authority: buildScripts/util/check-css-vendor-prefixes.mjs (existing PostCSS CI guard architecture) and operator direction (2026-12-03, Epic #23186: prevent legacy CSS regressions without micro-PR churn).

The Fix

  1. Create buildScripts/util/check-css-hygiene.mjs:
    • Export SCAN_SURFACE = Object.freeze(['resources/css/**/*.css']) and pure PostCSS AST checker functions (mirroring check-css-vendor-prefixes.mjs).
    • Flag the following offence kinds with file:line, kind, and actionable guidance:
      • obsolete-webkit-syntax: -webkit-gradient(...) in any declaration value, -webkit-fill-available in any value, and -webkit-overflow-scrolling property.
      • deprecated-clip: clip: rect(...) declarations (suggest clip-path: inset(50%)).
      • double-semicolon: empty/trailing ;; declarations in raw source (decl.raws.between / empty tokens or PostCSS source slice check, ignoring strings/comments).
      • important-custom-property: !important on any --neo-* custom property declaration inside resources/css/theme-*/.
      • sass-percentage-rgb: high-precision Sass-emitted rgb(NN.NNNN%, ...) literals (3+ decimal places in percentage rgb()).
    • Include a minimal, explicit HYGIENE_BASELINE map keyed by <repo-relative-file>|<kind> for any pre-existing offences still open at the time the PR lands; fail CI if a baseline entry is stale (no longer present) so sibling PRs ratchet the baseline strictly toward zero.
  2. Wire CLI & CI:
    • Add "check-css-hygiene": "node ./buildScripts/util/check-css-hygiene.mjs" to package.json scripts (and the aggregate check list alongside check-css-vendor-prefixes.mjs).
    • Register the check in .github/workflows/pr-baseline.yml beside "CSS vendor prefixes".
  3. Add unit tests:
    • Add test/playwright/unit/buildScripts/checkCssHygiene.spec.mjs covering every offence kind (positive hits, clean modern alternatives like linear-gradient(...) and clip-path: inset(50%), comment/string non-matches, stale-baseline detection, and a live pass on the repository).

Contract Ledger

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
npm run check-css-hygiene (buildScripts/util/check-css-hygiene.mjs) package.json + this ticket Parses resources/css/**/*.css with PostCSS; exits 0 when zero un-baselined offences and zero stale baseline entries exist; exits 1 otherwise None (new opt-in baseline guard; pre-existing debt tracked in shrinking allowlist) Inline module JSDoc + buildScripts/README.md if check list documented there test/playwright/unit/buildScripts/checkCssHygiene.spec.mjs
.github/workflows/pr-baseline.yml PR baseline matrix Runs check-css-hygiene.mjs on PRs touching SCAN_SURFACE (resources/css/**/*.css) Standard pr-baseline job failure output with file:line fix instructions Workflow step name "CSS hygiene" prBaseline.spec.mjs + CI green run

Acceptance Criteria

  • [ ] buildScripts/util/check-css-hygiene.mjs exports SCAN_SURFACE and pure PostCSS AST checkers catching obsolete-webkit-syntax, deprecated-clip, double-semicolon, important-custom-property, and sass-percentage-rgb, with zero false positives inside CSS comments or quoted strings.
  • [ ] Any remaining unfixed pre-existing files at PR time are recorded in an explicit ratcheting baseline allowlist that fails when an allowlisted entry becomes stale (or the allowlist is empty if all sibling leaves have already landed).
  • [ ] package.json exposes npm run check-css-hygiene and .github/workflows/pr-baseline.yml invokes it alongside check-css-vendor-prefixes.mjs.
  • [ ] test/playwright/unit/buildScripts/checkCssHygiene.spec.mjs passes via npx playwright test --config=test/playwright/playwright.config.unit.mjs test/playwright/unit/buildScripts/checkCssHygiene.spec.mjs and test/playwright/unit/buildScripts/prBaseline.spec.mjs stays green.
  • [ ] npm run check-css-hygiene and npm run check-css-vendor-prefixes both exit 0 against the current repo.

Out of Scope

  • Fixing the underlying CSS files in resources/css/ (owned by sibling cleanup leaves under #23186; this PR only adds the guard, tests, and CI wiring).
  • Enforcing physical-vs-logical RTL CSS properties globally (many canvas/splitter/3D/dock rules legitimately require physical left/right, so a blanket static ban would create noisy false positives).

Avoided Traps

  • Do not use naive regex scanning on raw file text for clip: rect or ;; — comments and data URLs cause false positives. Use PostCSS AST traversal (just like check-css-vendor-prefixes.mjs).
  • Do not break prBaseline.spec.mjs (which validates .github/workflows/pr-baseline.yml entries and SCAN_SURFACE exports).
  • Do not prohibit -webkit-box-reflect itself; only forbid the obsolete -webkit-gradient(...) value inside it (linear-gradient(...) stays valid).

Related

  • Refs #23186

Live latest-open + closed sweep: checked latest 20 open issues (including #23185, #23180, #23179), open/closed CSS/RTL searches (53 open issues, red band), A2A in-flight claims, query_raw_memories + ask_knowledge_base, and own assignments at 2026-12-03T02:43Z; no duplicate exists. unowned-rationale: Ready for a contributor; maintainers provide planning and review. Origin Session ID: d3b824ff-9083-4a90-af0d-da54110872be Retrieval Hint: "check-css-hygiene PostCSS CI guard pr-baseline deprecated clip rect webkit-gradient double semicolon"

neo-gemini-maryam avatar Dec 03 '26 02:12 neo-gemini-maryam

I would like to claim this. I will add buildScripts/util/check-css-hygiene.mjs with the ratcheting HYGIENE_BASELINE, the check-css-hygiene npm script, the Playwright unit spec, and the pr-baseline.yml wiring.

Beehtrix avatar Dec 03 '26 07:12 Beehtrix

Thanks for claiming this, @Beehtrix, and welcome back! Assigned to you — you can start now.

Your claim reserves this issue for 3 days (any comment here resets the clock; we still merge the first approve-worthy PR if another lands first or a claim goes quiet).

An automatic reply. How claims work

github-actions[bot] avatar Dec 03 '26 07:12 github-actions[bot]