UNPKG

841 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to check for ambiguous div operator in regexes
3 * @author Matt DuVall <http://www.mattduvall.com>
4 */
5
6//------------------------------------------------------------------------------
7// Rule Definition
8//------------------------------------------------------------------------------
9
10module.exports = function(context) {
11
12 "use strict";
13
14 return {
15
16 "Literal": function(node) {
17 var token = context.getTokens(node)[0],
18 nodeType = token.type,
19 source;
20
21 if (nodeType === "RegularExpression") {
22 source = context.getTokens(node)[0].value;
23
24 if (source[1] === "=") {
25 context.report(node, "A regular expression literal can be confused with '/='.");
26 }
27 }
28 }
29 };
30
31};