pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
regexp/match-any |
enforce match any character style |
v0.1.0 |
💼 This rule is enabled in the ✅ plugin:regexp/recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
enforce match any character style
This rule enforces the regular expression notation to match any character.
e.g. [\s\S]
, [^]
, /./s
(dotAll) and more.
/* eslint regexp/match-any: "error" */
/* ✓ GOOD */
var foo = /[\s\S]/;
var foo = /./s;
/* ✗ BAD */
var foo = /[\S\s]/;
var foo = /[^]/;
var foo = /[\d\D]/;
var foo = /[\w\W]/;
{
"regexp/match-any": ["error", {
"allows": ["[\\s\\S]", "dotAll"]
}]
}
"allows"
... An array of notations that any characters that are allowed.
"[\\s\\S]"
,"[\\S\\s]"
,"[^]"
and"dotAll"
can be set.
/* eslint regexp/match-any: ["error", { "allows": ["[^]"] }] */
/* ✓ GOOD */
var foo = /[^]/;
/* ✗ BAD */
var foo = /[\s\S]/;
var foo = /[\S\s]/;
var foo = /./s;
var foo = /[\d\D]/;
var foo = /[\w\W]/;
This rule was introduced in eslint-plugin-regexp v0.1.0