⚝
One Hat Cyber Team
⚝
Your IP:
172.22.0.1
Server IP:
151.80.20.34
Server:
Linux 794f04d97d5e 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64
Server Software:
Apache/2.4.62 (Debian)
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
nodejs
/
eslint
/
lib
/
rules
/
View File Name :
no-prototype-builtins.js
/** * @fileoverview Rule to disallow use of Object.prototype builtins on objects * @author Andrew Levine */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { meta: { type: "problem", docs: { description: "disallow calling some `Object.prototype` methods directly on objects", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/no-prototype-builtins" }, schema: [] }, create(context) { const DISALLOWED_PROPS = [ "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable" ]; /** * Reports if a disallowed property is used in a CallExpression * @param {ASTNode} node The CallExpression node. * @returns {void} */ function disallowBuiltIns(node) { if (node.callee.type !== "MemberExpression" || node.callee.computed) { return; } const propName = node.callee.property.name; if (DISALLOWED_PROPS.indexOf(propName) > -1) { context.report({ message: "Do not access Object.prototype method '{{prop}}' from target object.", loc: node.callee.property.loc.start, data: { prop: propName }, node }); } } return { CallExpression: disallowBuiltIns }; } };