Skip to content

Add layer-name-pattern #8431

@jeddy3

Description

@jeddy3

What is the problem you're trying to solve?

I want to enforce consistent naming conventions for my layer names.

@layer foo {};
@layer bar;
@import "foo.css" layer(baz)

Ref: #7732 (comment)

What solution would you like to see?

A new rule:

  • Name: layer-name-pattern
  • Description: Specify a pattern for layer names.
  • Message: Expected "${name}" to match pattern "${pattern}"
  • Primary option: string|regex
  • Secondary options: None
  • Category: Enforce conventions > Patterns
  • Autofix?: No
  • Included in sharable configs?: Yes (kebab case)
  • Expanded description: N/A

Do we want to check the whole layer name or split the period-separated list of <ident>s first?:

@layer framework.theme {}

My hunch is that we should check the whole name, as we can add a separate rule for enforcing specific idents, e.g., layer-name-ident-allowed-list: ["base", "framework", "theme"]. The layer-name-pattern is for users wanting to enforce a general pattern, e.g. kebab case, without enforcing specific names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions