sonarjs/slow-regex
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/slow-regex": "error",
},
},
];Regular expressions should not cause catastrophic backtracking
The documentation shows no incorrect example for this rule.
/((?=(a+))\2)+$/.test(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"aaaaaaaaaaaaaaa!"
); // CompliantExamples from the ESLint documentation.
sonarjs/slow-regex
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/slow-regex": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Single-character alternations in regular expressions should be replaced with character classes
Character classes in regular expressions should not contain only one character
A new session should be created during user authentication
Regular expressions with the global flag should be used with caution