pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
regexp/no-useless-character-class |
disallow character class with one character |
v0.3.0 |
💼 This rule is enabled in the ✅ plugin:regexp/recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
disallow character class with one character
This rule reports character classes that defines only one character.
Character classes that define only one character have the same effect even if you remove the brackets.
/* eslint regexp/no-useless-character-class: "error" */
/* ✓ GOOD */
var foo = /abc/;
/* ✗ BAD */
var foo = /a[b]c/;
{
"regexp/no-useless-character-class": ["error", {
"ignores": ["="]
}]
}
"ignores"
... An array of characters and character classes to ignores. Default["="]
.
The default value is "="
to prevent conflicts with the no-div-regex rule. Note that if you do not specify "="
, there may be conflicts with the no-div-regex rule.
/* eslint regexp/no-useless-character-class: ["error", { "ignores": ["a"] }] */
/* ✓ GOOD */
var foo = /[a]bc/;
/* ✗ BAD */
var foo = /a[b]c/;
This rule was introduced in eslint-plugin-regexp v0.3.0