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.
Examples
Section titled “Examples”Unnecessary Lookahead at End
Section titled “Unnecessary Lookahead at End”const pattern = /(?=content(?=nested))/;const pattern = /(?<=(?<=nested)content)/;const pattern = /(?!content(?=nested))/;const pattern = /(?=contentNested)/;const pattern = /(?<=nestedContent)/;const pattern = /(?!contentNested)/;Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you are intentionally structuring patterns with nested lookarounds for clarity or readability, you might prefer 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.