UNPKG

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