Skip to content

Files

Latest commit

 

History

History
35 lines (26 loc) · 526 Bytes

negation.md

File metadata and controls

35 lines (26 loc) · 526 Bytes

Pattern: Missing use of escape on negation

Issue: -

Description

This rule enforces use of \D, \W, \S and \P on negation.

Examples

/* 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