Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-restricted-globals rule crashes with 'hasOwnProperty' as restricted global #10660

Closed
richardejc opened this issue Jul 23, 2018 · 3 comments
Closed
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly good first issue Good for people who haven't worked on ESLint before rule Relates to ESLint's core rules

Comments

@richardejc
Copy link

Tell us about your environment

  • ESLint Version: v5.2.0
  • Node Version: v8.11.1
  • npm Version: v5.6.0

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
{
	"rules": {
		"no-restricted-globals": ["error", "hasOwnProperty"],
	}
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

module.exports = obj => hasOwnProperty(obj, 'name');

What did you expect to happen?
Should get a warning for using the global "hasOwnProperty".

What actually happened? Please include the actual, raw output from ESLint.

restrictedGlobalMessages.hasOwnProperty is not a function
TypeError: restrictedGlobalMessages.hasOwnProperty is not a function
    at isRestricted (/Users/richard/github/website-backend/playosmo-js/node_modules/eslint/lib/rules/no-restricted-globals.js:97:45)
    at Program.scope.variables.forEach.variable (/Users/richard/github/website-backend/playosmo-js/node_modules/eslint/lib/rules/no-restricted-globals.js:106:50)
    at Array.forEach (<anonymous>)
    at Program (/Users/richard/github/website-backend/playosmo-js/node_modules/eslint/lib/rules/no-restricted-globals.js:105:33)
    at listeners.(anonymous function).forEach.listener (/Users/richard/github/website-backend/playosmo-js/node_modules/eslint/lib/util/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/richard/github/website-backend/playosmo-js/node_modules/eslint/lib/util/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/richard/github/website-backend/playosmo-js/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/richard/github/website-backend/playosmo-js/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/Users/richard/github/website-backend/playosmo-js/node_modules/eslint/lib/util/node-event-generator.js:294:14)

The issue is this line in no-restricted-globals.js:

        function isRestricted(name) {
            return restrictedGlobalMessages.hasOwnProperty(name);
        }

which should be:

        function isRestricted(name) {
            return Object.prototype.hasOwnProperty.call(restrictedGlobalMessages, name);
        }
@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jul 23, 2018
@kaicataldo kaicataldo added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 23, 2018
@kaicataldo
Copy link
Member

Thanks for the bug report. Would you like to make a PR?

@platinumazure platinumazure added the good first issue Good for people who haven't worked on ESLint before label Jul 28, 2018
@msaikaushik
Copy link

@kaicataldo can i take this?

@kaicataldo
Copy link
Member

@icedune Please!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 8, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly good first issue Good for people who haven't worked on ESLint before rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

4 participants