sonarjs/single-character-alternation
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/single-character-alternation": "error",
},
},
];Single-character alternations in regular expressions should be replaced with character classes
/a|b|c/; // Noncompliant/[abc]/;
// or
/[a-c]/;Examples from the ESLint documentation.
sonarjs/single-character-alternation
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/single-character-alternation": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Character classes in regular expressions should not contain only one character
Regular expressions should not cause catastrophic backtracking
A new session should be created during user authentication
Wallet phrases should not be hard-coded