Skip to content

Files

Latest commit

 

History

History
47 lines (30 loc) · 1.03 KB

selector-pseudo-class-allowed-list.md

File metadata and controls

47 lines (30 loc) · 1.03 KB

Pattern: Use of non-allowed-listed pseudo-class selector

Issue: -

Description

Specify a whitelist of allowed pseudo-class selectors. This rule ignores selectors that use variable interpolation e.g. :#{$variable} {}.

Examples

array|string|regex: ["array", "of", "unprefixed", "pseudo-classes" or "regex"]|"pseudo-class"|/regex/

If a string is surrounded with "/" (e.g. "/^nth-/"), it is interpreted as a regular expression. This allows, for example, easy targeting of shorthands: /^nth-/ will match nth-child, nth-last-child, nth-of-type, etc.

Given:

["hover", "/^nth-/"]

The following patterns are considered violations:

a:focus {}
a:first-of-type {}

The following patterns are not considered violations:

a:hover {}
a:nth-of-type(5) {}
a:nth-child(2) {}

Further Reading