spiracss/page-layer
Validates page-layer boundaries in page entry SCSS.
Purpose
- Keep page entry SCSS focused on placement
- Require explicit links to component files for child Blocks
What it checks
- Applies only to page entry SCSS under
pageEntryAlias/pageEntrySubdirresolved viaaliasRoots - Rules that include a direct child Block selector (
> .child-block) must start with a link comment - Link comments must resolve inside
componentsDirs - External classes are ignored
selectorParseFailedwarns when selector parsing fails (coverage becomes partial)
Notes / limitations
These behaviors intentionally match spiracss/rel-comments:
- Direct child detection is limited to selectors that start with
> .child-block(or& > .child-block). It does not follow:is()or sibling combinators. - Link comments must be the first node in the rule body (declarations or
@includebefore it will still be reported). - Link targets are checked for being inside
componentsDirs, but this rule does not verify file existence. Usespiracss/rel-commentswithvalidatePath=truefor path existence checks. - If
pageEntryAliasdoes not resolve inaliasRoots, the rule is skipped (no warning). - Element selectors are not validated by this rule; use
spiracss/class-structureif you need structure checks.
OK
.main-container { > .about-content { // @components/pages/about/about-content/about-content.scss margin-top: 2rem; }}NG
.main-container { > .about-content { margin-top: 2rem; // NG: missing link comment }}.main-container { > .about-content { // @assets/css/about.scss // NG: outside componentsDirs margin-top: 2rem; }}Why
- Keep page entry SCSS as a placement-only boundary
- Keep navigation between page entries and components consistent
Error list
missingComponentLink (missing link comment for child Block)
Example:
// NG.main-container { > .about-content { margin-top: 2rem; }}
// OK.main-container { > .about-content { // @components/pages/about/about-content/about-content.scss margin-top: 2rem; }}Reason: child Blocks must link to their component file
nonComponentLink (link does not resolve to the component layer)
Example:
// NG.main-container { > .about-content { // @assets/css/about.scss margin-top: 2rem; }}
// OK.main-container { > .about-content { // @components/pages/about/about-content/about-content.scss margin-top: 2rem; }}Reason: link comments must point inside componentsDirs
selectorParseFailed (selector parse failed)
Example:
// NG.main-container { > : { margin-top: 2rem; }}
// OK.main-container { > .about-content { margin-top: 2rem; }}Reason: unparseable selectors cannot be validated