pageClass | sidebarDepth | title | description | since |
---|---|---|---|---|
rule-details |
0 |
regexp/no-empty-string-literal |
disallow empty string literals in character classes |
v2.0.0-next.11 |
💼 This rule is enabled in the ✅ plugin:regexp/recommended
config.
disallow empty string literals in character classes
This rule reports empty string literals in character classes.
If the empty string literal is supposed to match the empty string, then use a
quantifier instead. For example, [ab\q{}]
should be written as [ab]?
.
This rule does not report empty alternatives in string literals. (e.g. /[\q{a|}]/v
)
If you want to report empty alternatives in string literals, use the regexp/no-empty-alternative rule.
/* eslint regexp/no-empty-string-literal: "error" */
/* ✓ GOOD */
var foo = /[\q{a}]/v;
var foo = /[\q{abc}]/v;
var foo = /[\q{a|}]/v;
/* ✗ BAD */
var foo = /[\q{}]/v;
var foo = /[\q{|}]/v;
Nothing.
This rule was introduced in eslint-plugin-regexp v2.0.0-next.11