sonarjs/no-empty-after-reluctant
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-empty-after-reluctant": "error",
},
},
];Reluctant quantifiers in regular expressions should be followed by an expression that can't match the empty string
str.split(/.*?x?/); // Noncompliant, this will behave just like "x?"
/^.*?$/.test(str); // Noncompliant, replace with ".*"str.split(/.*?x/);
/^.*$/.test(str);Examples from the ESLint documentation.
sonarjs/no-empty-after-reluctant
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-empty-after-reluctant": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Collection elements should not be replaced unconditionally
Alternation in regular expressions should not contain empty alternatives
Two branches in a conditional structure should not have exactly the same implementation
Empty character classes should not be used
Test titles should be unique within the same suite
Empty collections should not be accessed or iterated