Skip to content

regexp/no-useless-character-class

💼 This rule is enabled in the following configs: 🟢 flat/recommended, 🔵 recommended.

🔧 This rule is automatically fixable by the --fix CLI option.

disallow character class with one character

📖 Rule Details

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.

Now loading...

🔧 Options

json
{
  "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.

"ignores": ["a"]

Now loading...

🚀 Version

This rule was introduced in eslint-plugin-regexp v0.3.0

🔍 Implementation