Skip to content

Latest commit

 

History

History
56 lines (37 loc) · 1.45 KB

prefer-named-backreference.md

File metadata and controls

56 lines (37 loc) · 1.45 KB
pageClass sidebarDepth title description since
rule-details
0
regexp/prefer-named-backreference
enforce using named backreferences
v0.9.0

regexp/prefer-named-backreference

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

enforce using named backreferences

📖 Rule Details

This rule reports and fixes backreferences that do not use the name of their referenced capturing group.

/* eslint regexp/prefer-named-backreference: "error" */

/* ✓ GOOD */
var foo = /(a)\1/
var foo = /(?<foo>a)\k<foo>/

/* ✗ BAD */
var foo = /(?<foo>a)\1/

🔧 Options

Nothing.

👫 Related rules

🚀 Version

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

🔍 Implementation