# Available Rules
The --fix
option on the command line (opens new window) automatically fixes problems reported by rules which have a wrench 🔧 below.
The rules with the following star ⭐️ are included in the plugin:regexp/recommended
config.
# Possible Errors
Rule ID | Description | |
---|---|---|
regexp/no-contradiction-with-assertion | disallow elements that contradict assertions | |
regexp/no-control-character | disallow control characters | |
regexp/no-dupe-disjunctions | disallow duplicate disjunctions | ⭐️ |
regexp/no-empty-alternative | disallow alternatives without elements | ⭐️ |
regexp/no-empty-capturing-group | disallow capturing group that captures empty. | ⭐️ |
regexp/no-empty-character-class | disallow character classes that match no characters | |
regexp/no-empty-group | disallow empty group | ⭐️ |
regexp/no-empty-lookarounds-assertion | disallow empty lookahead assertion or empty lookbehind assertion | ⭐️ |
regexp/no-escape-backspace | disallow escape backspace ([\b] ) | ⭐️ |
regexp/no-invalid-regexp | disallow invalid regular expression strings in RegExp constructors | ⭐️ |
regexp/no-lazy-ends | disallow lazy quantifiers at the end of an expression | ⭐️ |
regexp/no-misleading-unicode-character | disallow multi-code-point characters in character classes and quantifiers | 🔧 |
regexp/no-optional-assertion | disallow optional assertions | ⭐️ |
regexp/no-potentially-useless-backreference | disallow backreferences that reference a group that might not be matched | ⭐️ |
regexp/no-super-linear-backtracking | disallow exponential and polynomial backtracking | ⭐️🔧 |
regexp/no-super-linear-move | disallow quantifiers that cause quadratic moves | |
regexp/no-useless-assertions | disallow assertions that are known to always accept (or reject) | ⭐️ |
regexp/no-useless-backreference | disallow useless backreferences in regular expressions | ⭐️ |
regexp/no-useless-dollar-replacements | disallow useless $ replacements in replacement string | ⭐️ |
regexp/strict | disallow not strictly valid regular expressions | ⭐️🔧 |
# Best Practices
Rule ID | Description | |
---|---|---|
regexp/confusing-quantifier | disallow confusing quantifiers | ⭐️ |
regexp/control-character-escape | enforce consistent escaping of control characters | ⭐️🔧 |
regexp/negation | enforce use of escapes on negation | ⭐️🔧 |
regexp/no-dupe-characters-character-class | disallow duplicate characters in the RegExp character class | ⭐️🔧 |
regexp/no-invisible-character | disallow invisible raw character | ⭐️🔧 |
regexp/no-legacy-features | disallow legacy RegExp features | ⭐️ |
regexp/no-non-standard-flag | disallow non-standard flags | ⭐️ |
regexp/no-obscure-range | disallow obscure character ranges | ⭐️ |
regexp/no-octal | disallow octal escape sequence | |
regexp/no-standalone-backslash | disallow standalone backslashes (\ ) | |
regexp/no-trivially-nested-assertion | disallow trivially nested assertions | ⭐️🔧 |
regexp/no-trivially-nested-quantifier | disallow nested quantifiers that can be rewritten as one quantifier | ⭐️🔧 |
regexp/no-unused-capturing-group | disallow unused capturing group | ⭐️🔧 |
regexp/no-useless-character-class | disallow character class with one character | ⭐️🔧 |
regexp/no-useless-flag | disallow unnecessary regex flags | ⭐️🔧 |
regexp/no-useless-lazy | disallow unnecessarily non-greedy quantifiers | ⭐️🔧 |
regexp/no-useless-quantifier | disallow quantifiers that can be removed | ⭐️🔧 |
regexp/no-useless-range | disallow unnecessary range of characters by using a hyphen | ⭐️🔧 |
regexp/no-useless-two-nums-quantifier | disallow unnecessary {n,m} quantifier | ⭐️🔧 |
regexp/no-zero-quantifier | disallow quantifiers with a maximum of zero | ⭐️ |
regexp/optimal-lookaround-quantifier | disallow the alternatives of lookarounds that end with a non-constant quantifier | ⭐️ |
regexp/optimal-quantifier-concatenation | require optimal quantifiers for concatenated quantifiers | ⭐️🔧 |
regexp/prefer-escape-replacement-dollar-char | enforces escape of replacement $ character ($$ ). | |
regexp/prefer-predefined-assertion | prefer predefined assertion over equivalent lookarounds | ⭐️🔧 |
regexp/prefer-quantifier | enforce using quantifier | 🔧 |
regexp/prefer-range | enforce using character class range | ⭐️🔧 |
regexp/prefer-regexp-exec | enforce that RegExp#exec is used instead of String#match if no global flag is provided | |
regexp/prefer-regexp-test | enforce that RegExp#test is used instead of String#match and RegExp#exec | 🔧 |
regexp/require-unicode-regexp | enforce the use of the u flag | 🔧 |
regexp/sort-alternatives | sort alternatives if order doesn't matter | 🔧 |
regexp/use-ignore-case | use the i flag if it simplifies the pattern | 🔧 |
# Stylistic Issues
Rule ID | Description | |
---|---|---|
regexp/hexadecimal-escape | enforce consistent usage of hexadecimal escape | 🔧 |
regexp/letter-case | enforce into your favorite case | 🔧 |
regexp/match-any | enforce match any character style | ⭐️🔧 |
regexp/no-useless-escape | disallow unnecessary escape characters in RegExp | ⭐️🔧 |
regexp/no-useless-non-capturing-group | disallow unnecessary Non-capturing group | ⭐️🔧 |
regexp/prefer-character-class | enforce using character class | ⭐️🔧 |
regexp/prefer-d | enforce using \d | ⭐️🔧 |
regexp/prefer-lookaround | prefer lookarounds over capturing group that do not replace | 🔧 |
regexp/prefer-named-backreference | enforce using named backreferences | 🔧 |
regexp/prefer-named-capture-group | enforce using named capture groups | |
regexp/prefer-named-replacement | enforce using named replacement | 🔧 |
regexp/prefer-plus-quantifier | enforce using + quantifier | ⭐️🔧 |
regexp/prefer-question-quantifier | enforce using ? quantifier | ⭐️🔧 |
regexp/prefer-result-array-groups | enforce using result array groups | 🔧 |
regexp/prefer-star-quantifier | enforce using * quantifier | ⭐️🔧 |
regexp/prefer-unicode-codepoint-escapes | enforce use of unicode codepoint escapes | ⭐️🔧 |
regexp/prefer-w | enforce using \w | ⭐️🔧 |
regexp/sort-character-class-elements | enforces elements order in character class | 🔧 |
regexp/sort-flags | require regex flags to be sorted | ⭐️🔧 |
regexp/unicode-escape | enforce consistent usage of unicode escape or unicode codepoint escape | 🔧 |
# Deprecated
- ⚠️ We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules.
- 😇 We don't fix bugs which are in deprecated rules since we don't have enough resources.