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}.
Examples
Section titled “Examples”Simple Cases
Section titled “Simple Cases”const pattern = /a{1,1}/;const pattern = /a{42,42}/;const pattern = /a{1,1}?/;const pattern = /(?:ab){2,2}/;const pattern = /a{1}/;const pattern = /a{42}/;const pattern = /a{1}?/;const pattern = /(?:ab){2}/;Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you prefer to keep unnecessary numeric quantifiers for readability or organizational purposes, you might want to disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.