useNamedLayer
Summary
Section titled “Summary”- Rule available since:
v2.5.9 - Diagnostic Category:
lint/nursery/useNamedLayer - This rule doesn’t have a fix.
- The default severity of this rule is warning.
- Sources:
- Inspired from
css/use-layers
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useNamedLayer": "error" } } }}Description
Section titled “Description”Disallow anonymous cascade layers.
A cascade layer created with @layer { ... } or imported with
@import "..." layer has no name. Anonymous layers get their own place
in the cascade order, but because they cannot be referred to by name,
no later rule can add styles to them or reorder them. This makes the
cascade harder to reason about and prevents reusing the layer.
Give every layer a name so it can be referenced, appended to, and
ordered explicitly through a @layer statement.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”@layer { a { color: red; }}code-block.css:1:2 lint/nursery/useNamedLayer ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Missing cascade layer name.
> 1 │ @layer {
│ ^^^^^^^
> 2 │ a {
> 3 │ color: red;
> 4 │ }
> 5 │ }
│ ^
6 │
ℹ An anonymous layer cannot be referenced, so later rules cannot append to it or reorder it.
ℹ Give the layer a name, for example @layer base { … }.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
@import "theme.css" layer;code-block.css:1:21 lint/nursery/useNamedLayer ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Missing cascade layer name.
> 1 │ @import “theme.css” layer;
│ ^^^^^
2 │
ℹ An anonymous layer cannot be referenced, so later rules cannot append to it or reorder it.
ℹ Give the layer a name, for example @layer base { … }.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
@layer base { a { color: red; }}@import "theme.css" layer(base);Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.