-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Change Request: Update guard-for-in docs to use Object.hasOwn #16981
Copy link
Copy link
Closed
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussiondocumentationRelates to ESLint's documentationRelates to ESLint's documentationruleRelates to ESLint's core rulesRelates to ESLint's core rules
Metadata
Metadata
Assignees
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussiondocumentationRelates to ESLint's documentationRelates to ESLint's documentationruleRelates to ESLint's core rulesRelates to ESLint's core rules
Type
Projects
Status
Complete
ESLint version
v8.36.0
What problem do you want to solve?
The docs for guard-for-in currently only show how to guard a for-in loop using
Object.prototype.hasOwnPropertyor{}.hasOwnProperty. However, as of ES2022, it is best practice to useObject.hasOwninstead (see prefer-object-has-own).What do you think is the correct solution?
To show best practices, I propose adding the following as the first example in the examples of correct code:
Participation
Additional comments
I'm happy to make a PR for this small change if it's desired 🙂