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

New rule request: Restrict assignments to certain properties of certain objects #6920

Closed
platinumazure opened this issue Aug 16, 2016 · 2 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion

Comments

@platinumazure
Copy link
Member

When the rules will warn. Include a description as well as sample code.

This is a supplemental rule to no-restricted-globals. Instead of checking for the reassignment of a global, this would check for reassignment of properties for a global. For example, if a library has been exported to a particular global such as _, this rule flags reassignments to any property of _.

Example of violation:

/* eslint no-restricted-global-property-assignment: "error", "_" */

_.template = function () {};

Whether the rule prevents an error or is stylistic.

This can prevent errors that can arise from assignments to globals that will affect other parts of the code.

Why the rule should be in the core instead of creating a custom rule.

No strong reason, except that it seems unfortunate to be able to lint against global reassignments (e.g., _ = something) but not to lint against reassignments of properties.

Are you willing to create the rule yourself?

Yes! (Unless someone volunteers to do it faster than I will.)

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 16, 2016
@platinumazure platinumazure added rule Relates to ESLint's core rules feature This change adds a new feature to ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Aug 16, 2016
@nzakas
Copy link
Member

nzakas commented Aug 16, 2016

Duplicate of #3218?

@platinumazure
Copy link
Member Author

Aw crap. And I even commented on that issue. Sorry!

@platinumazure platinumazure added duplicate and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion feature This change adds a new feature to ESLint rule Relates to ESLint's core rules labels Aug 16, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@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 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

No branches or pull requests

3 participants