Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 763 Bytes

no-div-regex.md

File metadata and controls

43 lines (27 loc) · 763 Bytes
title rule_type related_rules
no-div-regex
suggestion
no-control-regex
no-regex-spaces

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

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

Rule Details

This rule forbids equal signs (=) after the slash (/) at the beginning of a regular expression literal, because the characters /= can be confused with a division assignment operator.

Examples of incorrect code for this rule:

:::incorrect

/*eslint no-div-regex: "error"*/

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

:::

Examples of correct code for this rule:

:::correct

/*eslint no-div-regex: "error"*/

function bar() { return /[=]foo/; }

:::