noEmptyCharacterClassInRegex (since v1.3.0)
Diagnostic Category: lint/correctness/noEmptyCharacterClassInRegex
Sources:
- Same as: 
no-empty-character-class 
Disallow empty character classes in regular expression literals.
Empty character classes don’t match anything. In contrast, negated empty classes match any character. They are often the result of a typing mistake.
Examples
Section titled ExamplesInvalid
Section titled Invalid/^a[]/.test("a"); // falsecode-block.js:1:4 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ The regular expression includes this empty character class.
  
  > 1 │ /^a[]/.test("a"); // false
      │    ^^
    2 │ 
  
  ℹ Empty character classes don't match anything.
    If you want to match against [, escape it \[.
    Otherwise, remove the character class or fill it.
  
/^a[^]/.test("ax"); // truecode-block.js:1:4 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ The regular expression includes this negated empty character class.
  
  > 1 │ /^a[^]/.test("ax"); // true
      │    ^^^
    2 │ 
  
  ℹ Negated empty character classes match anything.
    If you want to match against [, escape it \[.
    Otherwise, remove the character class or fill it.
  
Valid
Section titled Valid/^a[xy]/.test("ay"); // true/^a[^xy]/.test("ab"); // true/^a\[]/.test("a[]"); // true