no-invalid-regexp
eslint
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"no-invalid-regexp": "error",
},
},
];Disallow invalid regular expression strings in RegExp constructors
RegExp('[')
RegExp('.', 'z')
new RegExp('\\')RegExp('.')
new RegExp
this.RegExp('[')Examples from the ESLint documentation.
no-invalid-regexp
eslint
export default [
{
rules: {
"no-invalid-regexp": "error",
},
},
];no-invalid-regexp
eslint plugin · correctness
{
"rules": {
"no-invalid-regexp": "error"
}
}Biome does not have this rule.
Regular expressions should be syntactically valid
Disallow expressions where the operation doesn't affect the value
Disallow empty static blocks
Disallow let or var variables that are read but never assigned
Disallow fallthrough of case statements