Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 1.47 KB

no-useless-set-operand.md

File metadata and controls

57 lines (39 loc) · 1.47 KB
pageClass sidebarDepth title description since
rule-details
0
regexp/no-useless-set-operand
disallow unnecessary elements in expression character classes
v2.0.0-next.10

regexp/no-useless-set-operand

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

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

disallow unnecessary elements in expression character classes

📖 Rule Details

The v flag added set operations for character classes, e.g. [\w&&\D] and [\w--\d], but there are no limitations on what operands can be used. This rule reports any unnecessary operands.

/* eslint regexp/no-useless-set-operand: "error" */

/* ✓ GOOD */
foo = /[\w--\d]/v
foo = /[\w--[\d_]]/v

/* ✗ BAD */
foo = /[\w--[\d$]]/v
foo = /[\w&&\d]/v
foo = /[\w&&\s]/v
foo = /[\w&&[\d\s]]/v
foo = /[\w&&[^\d\s]]/v
foo = /[\w--\s]/v
foo = /[\d--\w]/v
foo = /[\w--[\d\s]]/v
foo = /[\w--[^\d\s]]/v

🔧 Options

Nothing.

🚀 Version

This rule was introduced in eslint-plugin-regexp v2.0.0-next.10

🔍 Implementation