-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat: add prefer-object-has-own
rule
#15346
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
Conversation
Co-authored-by: Gautam Arora <gautamarora6248@gmail.com>
prefer-object-has-own
ruleprefer-object-has-own
rule
Hi @snitin315!, thanks for the Pull Request The pull request title isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.
Read more about contributing to ESLint here |
prefer-object-has-own
ruleprefer-object-has-own
rule
No need to prefix with "[WIP]" (which messes up the commit message check). It's fine to just submit the PR as a draft. That tells us it's not ready for review yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good start. The auto fixing is incorrect, I left a comment on one of the invalid tests.
e828a2f
to
a26dd15
Compare
@mdjermanovic thanks for the review, I have applied the latest feedback. |
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
I think the auto-fix will break return{}.hasOwnProperty.call(object, property)
^ no space after `return`. |
Hmm, this should we auto fixed to Thanks, I will fix it in a separate PR. |
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[x] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add auto fixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Fixes #14939
Resolve #15206
Add a new rule
prefer-object-has-own
. This rule requires usingObject.hasOwn
instead ofObject.prototype.hasOwnProperty
.Is there anything you'd like reviewers to focus on?
No