Skip to content

eslint/no-div-regex Restriction

🛠️ An auto-fix is available for this rule.

What it does

Disallow equal signs explicitly at the beginning of regular expressions.

Why is this bad?

Characters /= at the beginning of a regular expression literal can be confused with a division assignment operator.

Example

javascript
function bar() {
  return /=foo/;
}

How to use

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

bash
oxlint --deny no-div-regex
json
{
  "rules": {
    "no-div-regex": "error"
  }
}

References

Released under the MIT License.