UNPKG

1.01 kBJavaScriptView Raw
1/**
2 * @fileoverview Rule to flag usage of __proto__ property
3 * @author Ilya Volodin
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 `__proto__` property",
16 category: "Best Practices",
17 recommended: false
18 },
19
20 schema: []
21 },
22
23 create(context) {
24
25 return {
26
27 MemberExpression(node) {
28
29 if (node.property &&
30 (node.property.type === "Identifier" && node.property.name === "__proto__" && !node.computed) ||
31 (node.property.type === "Literal" && node.property.value === "__proto__")) {
32 context.report({ node, message: "The '__proto__' property is deprecated." });
33 }
34 }
35 };
36
37 }
38};