1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | module.exports = {
|
13 | meta: {
|
14 | type: "suggestion",
|
15 |
|
16 | docs: {
|
17 | description: "disallow the use of the `__iterator__` property",
|
18 | category: "Best Practices",
|
19 | recommended: false,
|
20 | url: "https://eslint.org/docs/rules/no-iterator"
|
21 | },
|
22 |
|
23 | schema: []
|
24 | },
|
25 |
|
26 | create(context) {
|
27 |
|
28 | return {
|
29 |
|
30 | MemberExpression(node) {
|
31 |
|
32 | if (node.property &&
|
33 | (node.property.type === "Identifier" && node.property.name === "__iterator__" && !node.computed) ||
|
34 | (node.property.type === "Literal" && node.property.value === "__iterator__")) {
|
35 | context.report({ node, message: "Reserved name '__iterator__'." });
|
36 | }
|
37 | }
|
38 | };
|
39 |
|
40 | }
|
41 | };
|