pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
regexp/no-dupe-characters-character-class |
disallow duplicate characters in the RegExp character class |
v0.1.0 |
💼 This rule is enabled in the ✅ plugin:regexp/recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
disallow duplicate characters in the RegExp character class
Because multiple same character classes in regular expressions only one is useful, they might be typing mistakes.
var foo = /\\(\\)/;
This rule disallows duplicate characters in the RegExp character class.
/* eslint regexp/no-dupe-characters-character-class: "error" */
/* ✓ GOOD */
var foo = /[\(\)]/;
var foo = /[a-z\s]/;
var foo = /[\w]/;
/* ✗ BAD */
var foo = /[\\(\\)]/;
// ^^ ^^ "\\" are duplicated
var foo = /[a-z\\s]/;
// ^^^ ^ "s" are duplicated
var foo = /[\w0-9]/;
// ^^^^^ "0-9" are duplicated
Nothing.
This rule was introduced in eslint-plugin-regexp v0.1.0