regexMatchNotation
Reports inconsistent notations for matching any character in regular expressions.
✅ This rule is included in the ts stylisticStrict presets.
Reports inconsistent notations for matching any character in regular expressions.
There are multiple ways to match any character: [\s\S], [\S\s], [\d\D], [\w\W], [^], and . with the s (dotAll) flag.
This rule enforces using [\s\S] as the standard notation.
Examples
Section titled “Examples”Non-Standard Character Class Order
Section titled “Non-Standard Character Class Order”const pattern = /[\S\s]/;const pattern = /[\s\S]/;Empty Negated Character Class
Section titled “Empty Negated Character Class”const pattern = /[^]/;const pattern = /[\s\S]/;Digit and Non-Digit
Section titled “Digit and Non-Digit”const pattern = /[\d\D]/;const pattern = /[\s\S]/;Word and Non-Word
Section titled “Word and Non-Word”const pattern = /[\w\W]/;const pattern = /[\s\S]/;Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If your team has established a different convention for matching any character, or if you prefer the flexibility of using different notations in different contexts, you might want to disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
regexp/match-any
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.