Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.08 KB

prefer-w.md

File metadata and controls

51 lines (34 loc) · 1.08 KB
pageClass sidebarDepth title description since
rule-details
0
regexp/prefer-w
enforce using `\w`
v0.1.0

regexp/prefer-w

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

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

enforce using \w

📖 Rule Details

This rule is aimed at using \w in regular expressions.

/* eslint regexp/prefer-w: "error" */

/* ✓ GOOD */
var foo = /\w/;
var foo = /\W/;

/* ✗ BAD */
var foo = /[0-9a-zA-Z_]/;
var foo = /[^0-9a-zA-Z_]/;
var foo = /[0-9a-z_]/i;
var foo = /[0-9a-z_-]/i;

🔧 Options

Nothing.

🚀 Version

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

🔍 Implementation