sonarjs/no-empty-group
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-empty-group": "error",
},
},
];Regular expressions should not contain empty groups
const dateRegex = /^(?:0[1-9]|[12][0-9]|3[01])[- /.](?:0[1-9]|1[012])[- /.](?:19|20)\d\d(?:)$/; // Noncompliant, useless group at the end
const methodCallRegex = /foo()/; // Noncompliant, will match only 'foo'const dateRegex = /^(?:0[1-9]|[12][0-9]|3[01])[- /.](?:0[1-9]|1[012])[- /.](?:19|20)\d\d$/;
const methodCallRegex = /foo\(\)/; // OK, matches 'foo()'Examples from the ESLint documentation.
sonarjs/no-empty-group
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-empty-group": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Empty collections should not be accessed or iterated
Parameterized tests should not have empty datasets
Empty character classes should not be used
Test and suite titles should not be empty or whitespace-only
Alternation in regular expressions should not contain empty alternatives
Equality operators should not be used in "for" loop termination conditions