Skip to content

regexEmptyLookaroundsAssertions

Reports empty lookahead and lookbehind assertions in regular expressions.

✅ This rule is included in the ts logical and logicalStrict presets.

Reports empty lookahead and lookbehind assertions in regular expressions. Empty lookarounds like (?=) or (?!) will trivially accept or reject all inputs since they match the empty string.

const
const pattern: RegExp
pattern
= /(?=)/;
const
const pattern: RegExp
pattern
= /(?!)/;
const
const pattern: RegExp
pattern
= /(?<=)/;
const
const pattern: RegExp
pattern
= /(?=a?)/;

This rule is not configurable.

If you have a legitimate use case for empty lookarounds in generated or experimental regex patterns, you may disable this rule.

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