]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/no-empty-class.md
bump version to 8.4.0-3
[pve-eslint.git] / eslint / docs / rules / no-empty-class.md
1 # no-empty-class: disallow empty character classes in regular expressions
2
3 (removed) This rule was **removed** in ESLint v1.0 and **replaced** by the [no-empty-character-class](no-empty-character-class.md) rule.
4
5 Empty character classes in regular expressions do not match anything and can result in code that may not work as intended.
6
7 ```js
8 var foo = /^abc[]/;
9 ```
10
11 ## Rule Details
12
13 This rule is aimed at highlighting possible typos and unexpected behavior in regular expressions which may arise from the use of empty character classes.
14
15 Examples of **incorrect** code for this rule:
16
17 ```js
18 var foo = /^abc[]/;
19
20 /^abc[]/.test(foo);
21
22 bar.match(/^abc[]/);
23 ```
24
25 Examples of **correct** code for this rule:
26
27 ```js
28 var foo = /^abc/;
29
30 var foo = /^abc[a-z]/;
31
32 var bar = new RegExp("^abc[]");
33 ```