pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
regexp/negation |
enforce use of escapes on negation |
v0.4.0 |
💼 This rule is enabled in the ✅ plugin:regexp/recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
enforce use of escapes on negation
This rule enforces use of \D
, \W
, \S
and \P
on negation.
/* eslint regexp/negation: "error" */
/* ✓ GOOD */
var foo = /\D/
var foo = /\W/
var foo = /\S/
var foo = /\P{ASCII}/u
var foo = /\d/
var foo = /\w/
var foo = /\s/
var foo = /\p{ASCII}/u
/* ✗ BAD */
var foo = /[^\d]/
var foo = /[^\w]/
var foo = /[^\s]/
var foo = /[^\p{ASCII}]/u
var foo = /[^\D]/
var foo = /[^\W]/
var foo = /[^\S]/
var foo = /[^\P{ASCII}]/u
Nothing.
This rule was introduced in eslint-plugin-regexp v0.4.0