Skip to content

Files

Latest commit

 

History

History
25 lines (17 loc) · 597 Bytes

no-empty-string-literal.md

File metadata and controls

25 lines (17 loc) · 597 Bytes

Pattern: Empty string literal in character class

Issue: -

Description

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)

Examples

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