CSS
css/nesting-no-concat
In native CSS nesting, never build class names from "&" plus a suffix (&__title); write the full selector.
seriousstaticfe-css-modern
Why
Sass taught a habit: &__title inside .card becomes .card__title. Native CSS nesting does not join text; & stands for the parent selector as a whole, so &__title is not a valid selector and the browser drops the whole rule. The styles silently disappear when a stylesheet moves from .scss to .css.
Fix
Write the full class name as its own rule or nested with a space (& .card__title for a descendant), and use &.modifier for a compound selector. Keep suffix joining in .scss files only, or in a build that runs postcss-nested.
Examples
/* bad */
.card { &__title { font-size: 1.25rem; } }
/* good */
.card__title { font-size: 1.25rem; }
.card { &.card--featured { border-color: gold; } }Sources
Facts
- Id
css/nesting-no-concat- Severity
- serious
- Check
- static checked in the source by
audit - Applies to
css- Taught by the skill
fe-css-modernModern CSS features- Since version
- 0.1.0
Read it in the terminal
npx github:dawidolko/frontend-skills explain css/nesting-no-concat