# no-empty-character-class

> Disallow empty character classes `[]` in regular expressions

`[]` in a regular expression is a character class with no characters in it. It matches nothing, so `/^#[]{6}$/` never matches any string. Most often someone forgot to fill in the class, or meant the text `[]`, which is written `\[]`.

`[^]`, which matches any character, is allowed. Only regular expression literals are checked, not strings passed to `new RegExp()`.

This rule is on by default.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

On by default as a warning. To turn it off:

```toml bunfig.toml
[lint.rules]
"no-empty-character-class" = "off" # or "error"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
const isHexColor = /^#[]{6}$/.test(color);
```

Not reported:

{/* good */}
```js
const isHexColor = /^#[0-9a-f]{6}$/i.test(color);
```

{/* good */}
```js
const anyCharacter = /[^]/;
const emptyArrayText = /\[]/;
const notChecked = new RegExp("[]");
```
