Skip to content

regexPlusQuantifiers

Reports quantifiers {1,} in regular expressions that should use + instead.

✅ This rule is included in the ts stylisticStrict presets.

Reports quantifiers using {1,} in regular expressions and suggests using the more concise + quantifier instead. Both forms are semantically equivalent (matching one or more of the preceding element), but + is the idiomatic form.

const
const pattern: RegExp
pattern
= /a{1,}/;
const
const pattern: RegExp
pattern
= /a{1,}?/;
const
const pattern: RegExp
pattern
= /(ab){1,}/;
const
const pattern: RegExp
pattern
= new
var RegExp: RegExpConstructor
new (pattern: RegExp | string, flags?: string) => RegExp (+2 overloads)
RegExp
("a{1,}");

This rule is not configurable.

If your project has a style guide that prefers the explicit {1,} syntax for clarity, or if you are programmatically generating regular expressions where {1,} is easier to produce, you might want to disable this rule.

Made with ❤️‍🔥 around the world by the Flint team and contributors.