HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/frenchy/www/french-american.org/current/node_modules/@sinonjs/commons/eslint-local-rules.js
"use strict";

function getPrototypeMethods(prototype) {
    /* eslint-disable local-rules/no-prototype-methods */
    return Object.getOwnPropertyNames(prototype).filter(function(name) {
        return (
            typeof prototype[name] === "function" &&
            prototype.hasOwnProperty(name)
        );
    });
}

var DISALLOWED_ARRAY_PROPS = getPrototypeMethods(Array.prototype);

var DISALLOWED_OBJECT_PROPS = getPrototypeMethods(Object.prototype);

module.exports = {
    // rule to disallow direct use of prototype methods of builtins
    "no-prototype-methods": {
        meta: {
            docs: {
                description: "disallow calling prototype methods directly",
                category: "Possible Errors",
                recommended: false,
                url: "https://eslint.org/docs/rules/no-prototype-builtins"
            },

            schema: []
        },

        create: function(context) {
            /**
             * 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 ||
                    // allow static method calls
                    node.callee.object.name === "Array" ||
                    node.callee.object.name === "Object"
                ) {
                    return;
                }
                var propName = node.callee.property.name;

                if (DISALLOWED_OBJECT_PROPS.indexOf(propName) > -1) {
                    context.report({
                        message:
                            "Do not access {{obj}} prototype method '{{prop}}' from target object.",
                        loc: node.callee.property.loc.start,
                        data: {
                            obj: "Object",
                            prop: propName
                        },
                        node: node
                    });
                } else if (DISALLOWED_ARRAY_PROPS.indexOf(propName) > -1) {
                    context.report({
                        message:
                            "Do not access {{obj}} prototype method '{{prop}}' from target object.",
                        loc: node.callee.property.loc.start,
                        data: {
                            obj: "Array",
                            prop: propName
                        },
                        node: node
                    });
                }
            }

            return {
                CallExpression: disallowBuiltIns
            };
        }
    }
};