Skip to content

eslint/no-empty-character-class Correctness

This rule is turned on by default.

What it does

Disallow empty character classes in regular expressions

Why is this bad?

Because empty character classes in regular expressions do not match anything, they might be typing mistakes.

Example

javascript
var foo = /^abc[]/;

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny no-empty-character-class
json
{
  "rules": {
    "no-empty-character-class": "error"
  }
}

References

Released under the MIT License.