--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: invalid.js --- # Input ```jsx /^abc[]/; /foo[]bar/; if (foo.match(/^abc[]/)) {} if (/^abc[]/.test(foo)) {} /[]]/; /\[[]/; /\[\[\]a-z[]/; /[]]/d; /[(]\u{0}*[]/u; /[]/v; /[[]]/v; /[[a][]]/v; /[a[[b[]c]]d]/v; /[a--[]]/v; /[[]--b]/v; /[a&&[]]/v; /[[]&&b]/v; // negated empty class /[^]/; /\[][^]/; /[\u200E\u2066-\u2069][]/gu; ``` # Diagnostics ``` invalid.js:1:6 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. > 1 │ /^abc[]/; │ ^^ 2 │ /foo[]bar/; 3 │ if (foo.match(/^abc[]/)) {} i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:2:5 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 1 │ /^abc[]/; > 2 │ /foo[]bar/; │ ^^ 3 │ if (foo.match(/^abc[]/)) {} 4 │ if (/^abc[]/.test(foo)) {} i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:3:20 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 1 │ /^abc[]/; 2 │ /foo[]bar/; > 3 │ if (foo.match(/^abc[]/)) {} │ ^^ 4 │ if (/^abc[]/.test(foo)) {} 5 │ /[]]/; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:4:10 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 2 │ /foo[]bar/; 3 │ if (foo.match(/^abc[]/)) {} > 4 │ if (/^abc[]/.test(foo)) {} │ ^^ 5 │ /[]]/; 6 │ /\[[]/; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:5:2 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 3 │ if (foo.match(/^abc[]/)) {} 4 │ if (/^abc[]/.test(foo)) {} > 5 │ /[]]/; │ ^^ 6 │ /\[[]/; 7 │ /\[\[\]a-z[]/; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:6:4 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 4 │ if (/^abc[]/.test(foo)) {} 5 │ /[]]/; > 6 │ /\[[]/; │ ^^ 7 │ /\[\[\]a-z[]/; 8 │ /[]]/d; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:7:11 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 5 │ /[]]/; 6 │ /\[[]/; > 7 │ /\[\[\]a-z[]/; │ ^^ 8 │ /[]]/d; 9 │ /[(]\u{0}*[]/u; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:8:2 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 6 │ /\[[]/; 7 │ /\[\[\]a-z[]/; > 8 │ /[]]/d; │ ^^ 9 │ /[(]\u{0}*[]/u; 10 │ /[]/v; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:9:11 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 7 │ /\[\[\]a-z[]/; 8 │ /[]]/d; > 9 │ /[(]\u{0}*[]/u; │ ^^ 10 │ /[]/v; 11 │ /[[]]/v; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:10:2 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 8 │ /[]]/d; 9 │ /[(]\u{0}*[]/u; > 10 │ /[]/v; │ ^^ 11 │ /[[]]/v; 12 │ /[[a][]]/v; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:11:3 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 9 │ /[(]\u{0}*[]/u; 10 │ /[]/v; > 11 │ /[[]]/v; │ ^^ 12 │ /[[a][]]/v; 13 │ /[a[[b[]c]]d]/v; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:12:6 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 10 │ /[]/v; 11 │ /[[]]/v; > 12 │ /[[a][]]/v; │ ^^ 13 │ /[a[[b[]c]]d]/v; 14 │ /[a--[]]/v; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:13:7 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 11 │ /[[]]/v; 12 │ /[[a][]]/v; > 13 │ /[a[[b[]c]]d]/v; │ ^^ 14 │ /[a--[]]/v; 15 │ /[[]--b]/v; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:14:6 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 12 │ /[[a][]]/v; 13 │ /[a[[b[]c]]d]/v; > 14 │ /[a--[]]/v; │ ^^ 15 │ /[[]--b]/v; 16 │ /[a&&[]]/v; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:15:3 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 13 │ /[a[[b[]c]]d]/v; 14 │ /[a--[]]/v; > 15 │ /[[]--b]/v; │ ^^ 16 │ /[a&&[]]/v; 17 │ /[[]&&b]/v; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:16:6 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 14 │ /[a--[]]/v; 15 │ /[[]--b]/v; > 16 │ /[a&&[]]/v; │ ^^ 17 │ /[[]&&b]/v; 18 │ // negated empty class i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:17:3 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 15 │ /[[]--b]/v; 16 │ /[a&&[]]/v; > 17 │ /[[]&&b]/v; │ ^^ 18 │ // negated empty class 19 │ /[^]/; i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:19:2 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this negated empty character class. 17 │ /[[]&&b]/v; 18 │ // negated empty class > 19 │ /[^]/; │ ^^^ 20 │ /\[][^]/; 21 │ /[\u200E\u2066-\u2069][]/gu; i Negated empty character classes match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:20:5 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this negated empty character class. 18 │ // negated empty class 19 │ /[^]/; > 20 │ /\[][^]/; │ ^^^ 21 │ /[\u200E\u2066-\u2069][]/gu; i Negated empty character classes match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ``` ``` invalid.js:21:23 lint/correctness/noEmptyCharacterClassInRegex ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The regular expression includes this empty character class. 19 │ /[^]/; 20 │ /\[][^]/; > 21 │ /[\u200E\u2066-\u2069][]/gu; │ ^^ i Empty character classes don't match anything. If you want to match against [, escape it \[. Otherwise, remove the character class or fill it. ```