Skip to content

regexUnnecessaryLookaroundAssertions

Reports unnecessary nested lookaround assertions in regular expressions.

✅ This rule is included in the ts logical presets.

Reports unnecessary nested lookaround assertions in regular expressions. A positive lookahead at the end of another lookahead, or a positive lookbehind at the start of another lookbehind, is redundant because the nested assertion can be inlined into the parent.

const pattern = /(?=content(?=nested))/;
const pattern = /(?<=(?<=nested)content)/;
const pattern = /(?!content(?=nested))/;

This rule is not configurable.

If you are intentionally structuring patterns with nested lookarounds for clarity or readability, you might prefer to disable this rule.

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