-
-
Notifications
You must be signed in to change notification settings - Fork 457
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
feat(linter): Implement eslint/no-object-constructor #7345
base: main
Are you sure you want to change the base?
feat(linter): Implement eslint/no-object-constructor #7345
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
CodSpeed Performance ReportMerging #7345 will not alter performanceComparing Summary
|
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.
Thank you for your contribution!
Since the team seem to be focusing on other tasks, I’ve added comments on smaller points to help keep things moving efficiently.
ctx.diagnostic( | ||
crate::rules::eslint::no_object_constructor::no_object_constructor_diagnostic(span), | ||
); |
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.
I noticed this could be simplified. Can we use this instead?
ctx.diagnostic( | |
crate::rules::eslint::no_object_constructor::no_object_constructor_diagnostic(span), | |
); | |
ctx.diagnostic(no_object_constructor_diagnostic(span)); | |
"Object() instanceof Object;", | ||
"const obj = Object?.();", | ||
"(new Object() instanceof Object);", | ||
]; |
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.
It seems that the fix test cases were not scaffolded properly.
Could you add the test cases in a commented-out form? It makes it easier for implementers to notice and use that cases.
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.
Thanks!
Hello, again!
I added eslint rule eslint/no-object-constructor
https://eslint.org/docs/latest/rules/no-object-constructor
Notes
A test case for
new Object()
has been commented out:This is due to the test configuration specifying
globals: { Object: "off" }
.This approach follows the example set by the no_new_wrappers rule. Reference Code