Skip to content

regexUnnecessaryNumericQuantifiers

Reports numeric quantifiers like '{n,n}' that can be simplified to '{n}'.

✅ This rule is included in the ts logical presets.

Reports numeric quantifiers like {n,n} where the minimum and maximum are the same, which can be simplified to {n}.

const pattern = /a{1,1}/;
const pattern = /a{42,42}/;
const pattern = /a{1,1}?/;
const pattern = /(?:ab){2,2}/;

This rule is not configurable.

If you prefer to keep unnecessary numeric quantifiers for readability or organizational purposes, you might want to disable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.