2 * @fileoverview Rule to check for ambiguous div operator in regexes
3 * @author Matt DuVall <http://www.mattduvall.com>
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
17 description: "disallow division operators explicitly at the beginning of regular expressions",
18 category: "Best Practices",
20 url: "https://eslint.org/docs/rules/no-div-regex"
28 unexpected: "A regular expression literal can be confused with '/='."
33 const sourceCode = context.getSourceCode();
38 const token = sourceCode.getFirstToken(node);
40 if (token.type === "RegularExpression" && token.value[1] === "=") {
43 messageId: "unexpected",
45 return fixer.replaceTextRange([token.range[0] + 1, token.range[0] + 2], "[=]");