Skip to content

regexEmptyLookaroundsAssertions

Reports empty lookahead and lookbehind assertions in regular expressions.

✅ This rule is included in the ts logical 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 pattern = /(?=)/;
const pattern = /(?!)/;
const pattern = /(?<=)/;
const 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 ❤️‍🔥 in Boston by Josh Goldberg and contributors.