sonarjs/empty-string-repetition
eslint-plugin-sonarjs
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/empty-string-repetition": "error",
},
},
];Repeated patterns in regular expressions should not match the empty string
/(?:)*/ // same as the empty regex, the '*' accomplishes nothing
/(?:|x)*/ // same as the empty regex, the alternative has no effect
/(?:x|)*/ // same as 'x*', the empty alternative has no effect
/(?:x*|y*)*/ // same as 'x*', the first alternative would always match, y* is never tried
/(?:x?)*/ // same as 'x*'
/(?:x?)+/ // same as 'x*'/x*/Examples from the ESLint documentation.
sonarjs/empty-string-repetition
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/empty-string-repetition": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Templates should not be constructed dynamically
Encryption algorithms should be used with secure mode and padding scheme
Character classes in regular expressions should not contain the same character twice
Replacement strings should reference existing regular expression groups
DOMPurify configuration should not be bypassable