feat(mint): add CSS nesting depth audit - #114
Draft
nujovich wants to merge 3 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Card: https://github.com/nujovich/mint-radar/issues/23
What: Adds a CSS nesting audit that flags nesting depth and specificity
anti-patterns. Milestone 1 added the
NestingAudittype tolib/types.tswith
maxDepth,specificityGrowth, andunnecessaryAmpersandfields, plusa
nestingfield onAuditReport. Milestone 2 addsparseNestedRulesandlintNestingtolib/css-lint-rules.mjs, which walk nested selectors,measure maximum nesting depth, and flag redundant
&prefixes. Remainingmilestones add the complexity heatmap output and fixture tests.
Why: CSS nesting is widely available since 2024, but recent write-ups
(Piccalilli, Kilian Valkhof) warn about the same pitfalls teams hit with Sass
nesting: excessive depth, uncontrolled specificity growth, and redundant
&selectors. Stylelint has basic nesting rules but no dedicated auditor that
measures maximum depth or detects unnecessary specificity growth. This closes
that gap.
Decision: PLAN defined 4 concrete code milestones.
Milestones
NestingAudittype tolib/types.tswithmaxDepth,specificityGrowth, andunnecessaryAmpersandfields, plus anestingfield on
AuditReport&,measuring maximum depth and flagging unnecessary
&(when the nestedselector is already specific)
a configurable
--max-nesting-depththresholdValkhof nesting pitfalls
How to test:
npm run typecheck npm test