Skip to content

Add declaration-block-nesting-at-rule-required-list #8481

@jeddy3

Description

@jeddy3

What is the problem you're trying to solve?

I'd like to require @layer and other at-rules around my declarations.

Allow:

@layer defaults {
  a { color: red; }
}

Disallow:

a { color: red; }

What solution would you like to see?

We typically enable users to do this on the configuration level by adding generic and configurable rules rather than specific ones.

A new rule to do this.

  • Name: declaration-nesting-at-rule-required-list declaration-block-nesting-at-rule-required-list
  • Description: Specify a list of required nesting at-rules for declarations.
  • Message: Expected nesting at-rule "${atRule}" for declaration
  • Primary option: array[string|regex]|string|regex
  • Secondary options: None
  • Category: Enforce conventions > Allowed, disallowed & required
  • Autofix?: No
  • Included in sharable configs?: No
  • Expanded description: N/A
{ 
  "rules": {
     "declaration-nesting-at-rule-required-list": ["layer", "scope"]
  }
}

Prior art: use-layers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions