Require a specific ID format

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

Requires all IDs to match a given pattern.

Rule details

Examples of incorrect code for this rule:

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


1 error found.

Examples of correct code for this rule:

<div id="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