Require a specific class format

Rule ID:
class-pattern
Category:
Style
Standards:
-

Requires all classes to match a given pattern.

Rule details

Examples of incorrect code for this rule:

<div class="fooBar"></foobar>
error: class "fooBar" does not match the configured pattern "kebabcase" (class-pattern) at inline:1:13:
> 1 | <div class="fooBar"></foobar>
    |             ^^^^^^


1 error found.

Examples of correct code for this rule:

<div class="foo-bar"></div>

Options

This rule takes an optional object:

{
  "pattern": "kebabcase"
}

Pattern

Either one of the presets or a custom regular expression.

Read more about details and examples of predefined patterns.

Multiple patterns can be set as an array. If value matches either of the patterns it is considered valid.

Version history