Skip to content

regexp/prefer-predefined-assertion

💼 This rule is enabled in the ✅ plugin:regexp/recommended config.

🔧 This rule is automatically fixable by the --fix CLI option.

prefer predefined assertion over equivalent lookarounds

📖 Rule Details

All predefined assertions (\b, \B, ^, and $) can be expressed as lookaheads and lookbehinds. E.g. /a$/ is the same as /a(?![^])/.

In most cases, it's better to use the predefined assertions because they are better known.

Now loading...

🔧 Options

Nothing.

🚀 Version

This rule was introduced in eslint-plugin-regexp v0.10.0

🔍 Implementation