Skip to content


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

enforce using named replacement

📖 Rule Details

This rule reports and fixes $n parameter in replacement string that do not use the name of their referenced capturing group.

Now loading...

🔧 Options

  "regexp/prefer-named-replacement": ["error", {
      "strictTypes": true
  • strictTypes ... If true, strictly check the type of object to determine if the string instance was used in replace() and replaceAll(). Default is true.
    This option is always on when using TypeScript.

🚀 Version

This rule was introduced in eslint-plugin-regexp v1.4.0

🔍 Implementation