Sha256: a55f589b0b211430a2750ca271dba32e0a37a1d8b5d4d96a77fb5cbf67b1abba

Contents?: true

Size: 864 Bytes

Versions: 23

Compression:

Stored size: 864 Bytes

Contents

# Using regex in rules

The following classes of rules support regex:

- `*-blacklist`
- `*-whitelist`
- `*-pattern`

As does the `ignore*` secondary options.

## Enforce a case

You can use the regex that corresponds to your chosen case convention:

<!-- prettier-ignore -->
- kebab-case: `^([a-z][a-z0-9]*)(-[a-z0-9]+)*$`
- lowerCamelCase: `^[a-z][a-zA-Z0-9]+$`
- snake\_case: `^([a-z][a-z0-9]*)(_[a-z0-9]+)*$`
- UpperCamelCase: `^[A-Z][a-zA-Z0-9]+$`

For example, for lowerCamelCase class selectors use `"selector-class-pattern": "^[a-z][a-zA-Z0-9]+$"`.

All these patterns disallow CSS identifiers that start with a digit, two hyphens, or a hyphen followed by a digit.

## Enforce a prefix

You can ensure a prefix by using a negative lookahead regex.

For example, to ensure all custom properties begin with `my-` use `"custom-property-pattern": "^(?!my-)"`.

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
trusty-cms-5.0.7 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-5.0.6 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-5.0.5 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-5.0.4 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-5.0.3 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-5.0.2 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-5.0.1 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.3.5 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-5.0.0 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.3.4 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.3.3 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.3.2 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.3.1 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.3 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.2.3 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.2.2 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.2.1 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.2 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.1.9 node_modules/stylelint/docs/user-guide/rules/regex.md
trusty-cms-4.1.8 node_modules/stylelint/docs/user-guide/rules/regex.md