pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
regexp/prefer-w |
enforce using `\w` |
v0.1.0 |
💼 This rule is enabled in the ✅ plugin:regexp/recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
enforce using
\w
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;
Nothing.
This rule was introduced in eslint-plugin-regexp v0.1.0