Skip to content

Latest commit

 

History

History
62 lines (40 loc) · 1.57 KB

prefer-named-capture-group.md

File metadata and controls

62 lines (40 loc) · 1.57 KB
pageClass sidebarDepth title description since
rule-details
0
regexp/prefer-named-capture-group
enforce using named capture groups
v1.2.0

regexp/prefer-named-capture-group

enforce using named capture groups

📖 Rule Details

This rule reports capturing groups without a name.

This rule is inspired by the prefer-named-capture-group rule. The positions of reports are improved over the core rule and arguments of new RegExp() are also checked.

/* eslint regexp/prefer-named-capture-group: "error" */

/* ✓ GOOD */
var foo = /(?<foo>ba+r)/;
var foo = /\b(?:foo)+\b/;

/* ✗ BAD */
var foo = /\b(foo)+\b/;

🔧 Options

Nothing.

👫 Related rules

📚 Further reading

🚀 Version

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

🔍 Implementation