1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | module.exports = {
|
13 | meta: {
|
14 | docs: {
|
15 | description: "disallow division operators explicitly at the beginning of regular expressions",
|
16 | category: "Best Practices",
|
17 | recommended: false
|
18 | },
|
19 |
|
20 | schema: []
|
21 | },
|
22 |
|
23 | create(context) {
|
24 | const sourceCode = context.getSourceCode();
|
25 |
|
26 | return {
|
27 |
|
28 | Literal(node) {
|
29 | const token = sourceCode.getFirstToken(node);
|
30 |
|
31 | if (token.type === "RegularExpression" && token.value[1] === "=") {
|
32 | context.report(node, "A regular expression literal can be confused with '/='.");
|
33 | }
|
34 | }
|
35 | };
|
36 |
|
37 | }
|
38 | };
|