]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-prototype-builtins.js
a00d3707204ffddc4a078e15394a28361ede2c20
2 * @fileoverview Rule to disallow use of Object.prototype builtins on objects
3 * @author Andrew Levine
7 //------------------------------------------------------------------------------
9 //------------------------------------------------------------------------------
16 description
: "disallow calling some `Object.prototype` methods directly on objects",
17 category
: "Possible Errors",
19 url
: "https://eslint.org/docs/rules/no-prototype-builtins"
25 prototypeBuildIn
: "Do not access Object.prototype method '{{prop}}' from target object."
30 const DISALLOWED_PROPS
= [
33 "propertyIsEnumerable"
37 * Reports if a disallowed property is used in a CallExpression
38 * @param {ASTNode} node The CallExpression node.
41 function disallowBuiltIns(node
) {
42 if (node
.callee
.type
!== "MemberExpression" || node
.callee
.computed
) {
45 const propName
= node
.callee
.property
.name
;
47 if (DISALLOWED_PROPS
.indexOf(propName
) > -1) {
49 messageId
: "prototypeBuildIn",
50 loc
: node
.callee
.property
.loc
,
51 data
: { prop
: propName
},
58 CallExpression
: disallowBuiltIns