]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/no-prototype-builtins.js
2 * @fileoverview Tests for no-prototype-built-ins
3 * @author Andrew Levine
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/no-prototype-builtins"),
13 { RuleTester
} = require("../../../lib/rule-tester");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
18 const ruleTester
= new RuleTester();
21 { code
: "Object.prototype.hasOwnProperty.call(foo, 'bar')" },
22 { code
: "Object.prototype.isPrototypeOf.call(foo, 'bar')" },
23 { code
: "Object.prototype.propertyIsEnumerable.call(foo, 'bar')" },
24 { code
: "Object.prototype.hasOwnProperty.apply(foo, ['bar'])" },
25 { code
: "Object.prototype.isPrototypeOf.apply(foo, ['bar'])" },
26 { code
: "Object.prototype.propertyIsEnumerable.apply(foo, ['bar'])" },
27 { code
: "hasOwnProperty(foo, 'bar')" },
28 { code
: "isPrototypeOf(foo, 'bar')" },
29 { code
: "propertyIsEnumerable(foo, 'bar')" },
30 { code
: "({}.hasOwnProperty.call(foo, 'bar'))" },
31 { code
: "({}.isPrototypeOf.call(foo, 'bar'))" },
32 { code
: "({}.propertyIsEnumerable.call(foo, 'bar'))" },
33 { code
: "({}.hasOwnProperty.apply(foo, ['bar']))" },
34 { code
: "({}.isPrototypeOf.apply(foo, ['bar']))" },
35 { code
: "({}.propertyIsEnumerable.apply(foo, ['bar']))" }
40 code
: "foo.hasOwnProperty('bar')",
46 messageId
: "prototypeBuildIn",
47 data
: { prop
: "hasOwnProperty" },
48 type
: "CallExpression"
52 code
: "foo.isPrototypeOf('bar')",
58 messageId
: "prototypeBuildIn",
59 data
: { prop
: "isPrototypeOf" },
60 type
: "CallExpression"
64 code
: "foo.propertyIsEnumerable('bar')",
70 messageId
: "prototypeBuildIn",
71 data
: { prop
: "propertyIsEnumerable" }
75 code
: "foo.bar.hasOwnProperty('bar')",
81 messageId
: "prototypeBuildIn",
82 data
: { prop
: "hasOwnProperty" },
83 type
: "CallExpression"
87 code
: "foo.bar.baz.isPrototypeOf('bar')",
93 messageId
: "prototypeBuildIn",
94 data
: { prop
: "isPrototypeOf" },
95 type
: "CallExpression"
100 ruleTester
.run("no-prototype-builtins", rule
, {