Skip to content

Latest commit

 

History

History
63 lines (44 loc) · 1.28 KB

negation.md

File metadata and controls

63 lines (44 loc) · 1.28 KB
pageClass sidebarDepth title description since
rule-details
0
regexp/negation
enforce use of escapes on negation
v0.4.0

regexp/negation

💼 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

📖 Rule Details

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

🔧 Options

Nothing.

🚀 Version

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

🔍 Implementation