Conversation
…i & Kilian Valkhof
Owner
Author
|
All milestones complete. Ready for review when you are. |
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. Milestone 3adds a nesting-complexity heatmap to the
lintoutput with a configurable--max-nesting-depththreshold.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
Milestone 3 detail
Added a nesting-complexity heatmap to the
mint-ds lintoutput:lib/css-lint-rules.mjs— newnestingDepthHeatmap(css, opts)function thataggregates
parseNestedRules()into a per-depth rule-count distribution(depth 0 through maxDepth) and flags every rule nested deeper than the
threshold (default 3) in
excessive.bin/mint-ds.mjs—cmdLintnow renders the heatmap as an ASCII bar chart(green below the threshold, yellow at it, red above it) and lists a WARN line
for each rule exceeding the threshold. New
--max-nesting-depth <n>flag(documented under LINT OPTIONS in
--help); invalid or missing values fallback to the default of 3.
lib/__tests__/css-lint-rules.test.mjs— 5 new tests covering flat CSS,multi-level distribution, default/custom thresholds, and empty input.
How to test: