Skip to content

Latest commit

 

History

History
59 lines (38 loc) · 1.54 KB

no-empty-character-class.md

File metadata and controls

59 lines (38 loc) · 1.54 KB
pageClass sidebarDepth title description since
rule-details
0
regexp/no-empty-character-class
disallow character classes that match no characters
v1.2.0

regexp/no-empty-character-class

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

disallow character classes that match no characters

📖 Rule Details

This rule reports character classes that cannot match any characters.

Character classes that cannot match any characters are either empty or negated character classes of elements that contain all characters.

The reports for this rule include reports for the ESLint core no-empty-character-class rule. That is, if you use this rule, you can turn off the ESLint core no-empty-character-class rule.

/* eslint regexp/no-empty-character-class: "error" */

/* ✓ GOOD */
var foo = /abc[d]/;
var foo = /abc[a-z]/;
var foo = /[^]/;
var foo = /[\s\S]/;

/* ✗ BAD */
var foo = /abc[]/;
var foo = /[^\s\S]/;

🔧 Options

Nothing.

📚 Further reading

🚀 Version

This rule was introduced in eslint-plugin-regexp v1.2.0

🔍 Implementation