Repository navigation
feat: CSS-correctness diagnostics for scoped <style> blocks - #1212
jonkwheeler wants to merge 2 commits into
Conversation
New Octane-owned analyzeStyleCorrectness pass emits collected diagnostics on both compile() and compileToVolarMappings: - octane-css-unknown-property (error): declarations checked against the mdn-data property registry; custom properties and vendor prefixes exempt - octane-css-shorthand-longhand-clash: direction-aware cascade pairs across same-block declarations, co-matching rules, scope chains, and statically resolved same-module apply sheets. Provable co-matches are errors; speculative pairs are warnings (pseudo-element identity and reset-then-restitute handled) - octane-css-unused-selector (warning): pruneCss match metadata distinguishes stale scoped-block pruning from designed class-map pruning; :global, theme mode, and dynamic tags excluded Adds /* octane-ignore [codes] */ suppression on the collected channel and a styleCorrectness: false escape hatch. Diagnostics-only: production codegen is byte-equal with checks on/off. DocPage carries the dispositions this pass surfaces (longhand text-decoration-line, two octane-ignore resets). Re-cut from feat/typed-native-styling (slice O3, tracked in octanejs#1204). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit 041e91c. Configure here.
| if (Array.isArray(computed)) { | ||
| for (const sub of computed) expandWriteSet(sub, out, seen); | ||
| } | ||
| } |
There was a problem hiding this comment.
Intermediate shorthand clashes go undetected
Medium Severity
coversWrites requires every name in the loser's write set — including the loser's own shorthand token — to appear in the winner's expansion. expandWriteSet always inserts that token, but mdn-data computed lists only subproperties, so a broader shorthand such as border never contains an intermediate name like border-top. Pairs such as border-top then border therefore fail the subset check and are not reported, even though the later shorthand still resets everything the earlier one set.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 041e91c. Configure here.
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
First selector pair sets clash severity
Medium Severity
evaluatePair reports the first co-matching selector pair and then returns. Grouped selectors such as h1, .title vs .title therefore emit a speculative warning from the h1 / .title pair and never see the later .title / .title pair, which is a provable co-match and should be an error.
Reviewed by Cursor Bugbot for commit 041e91c. Configure here.
| } | ||
| } | ||
| return subject; | ||
| } |
There was a problem hiding this comment.
Subject matching overstates provable clashes
Medium Severity
readSubject only records type, id, class, :not(), :global(), and pseudo-elements. Attribute selectors, :is() / :where() / :has() arguments, and state pseudo-classes are ignored, so those selectors look empty or identical. subjectSubsumes then treats two empty subjects as equal, and subjectsMustCoMatch promotes the pair to an error even when the selectors cannot always (or ever) hit the same element.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 041e91c. Configure here.
|
Closing this slice draft for now: the typed-styling work is moving to an RFC first so the approach can be discussed with maintainers before asking for slice review. The branch and this re-cut remain intact; slices may be reopened or re-cut once the RFC settles the direction. Still tracked in the decomposition index (#1204). |


Summary
Slice O3 of the typed-native-styling decomposition (tracked in #1204). Re-cut from #1195 — the core analyzer, no slice dependencies.
New Octane-owned
analyzeStyleCorrectnesspass emits collected diagnostics on bothcompile()andcompileToVolarMappings:octane-css-unknown-property(error): declarations checked against the mdn-data property registry; custom properties and vendor prefixes exemptoctane-css-shorthand-longhand-clash: direction-aware cascade pairs across same-block declarations, co-matching rules, scope chains, and statically resolved same-moduleapplysheets. Provable co-matches are errors; speculative pairs downgrade to warnings (pseudo-element identity and reset-then-restitute handled)octane-css-unused-selector(warning): pruneCss match metadata distinguishes stale scoped-block pruning from designed class-map pruning;:global, theme mode, and dynamic tags excluded/* octane-ignore [codes] */before a rule or declaration suppresses a diagnostic on the collected channel;styleCorrectness: falsedisables the pass. Diagnostics-only: production codegen is byte-equal with checks on or off.DocPage.tsrxcarries the dispositions the pass surfaces in-repo (longhandtext-decoration-line, twooctane-ignoreresets) so the tree stays green.Depends on
mdn-data(added here). Editor/tsrx-tscseverity display is temporarily degraded until the@tsrx/*transport slice (tsrx T-A) publishes —octane analyzealready surfaces severity natively.Test plan
packages/octane/tests/style-correctness.test.ts(33 tests × octane + octane-prod)packages/cli/tests/analyze.test.js(incl. collected kebab-code propagation moved here from the O1 commit)scoped-styles-conformance(159×2),style-class-opt-in,return-style,deopt-style-patch— 354 testspnpm typecheck:files,pnpm format:files,pnpm sync(lockfile hash churn regenerated)Provenance
agent-authored)Re-cut mechanically from the validated diff in #1195; no redesign. Spike-token-seam test hunks deferred to the O5 slice (that file is added there).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
New compiler pass on every compile with scoped styles, but it is read-only and codegen is asserted byte-equal; main risk is false positives or perf on large style sheets and new diagnostic noise in CI/analyze.
Overview
Adds a diagnostics-only compile pass for scoped
<style>blocks:analyzeStyleCorrectnessruns on the adopted AST (before lowering) and attaches collected findings to bothcompile()andcompileToVolarMappingswithout changing codegen output.The pass reports
octane-css-unknown-property(againstmdn-data),octane-css-shorthand-longhand-clash(cascade-aware shorthand/longhand overlap, with errors vs warnings by provability), andoctane-css-unused-selector(via the same pruneCss pipeline as codegen). Authors can suppress withoctane-ignorecomments or disable entirely viastyleCorrectness: false.octane analyzenow surfaces these under their kebab codes (with a CLI test);mdn-datais a new dependency. Lockfile hash churn is refreshed across parity audit metadata and eval manifests.Reviewed by Cursor Bugbot for commit 041e91c. Bugbot is set up for automated code reviews on this repo. Configure here.