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

feat(linter): Implement eslint/no-object-constructor #7345

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

azihsoyn
Copy link
Contributor

@azihsoyn azihsoyn commented Nov 18, 2024

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

Copy link

graphite-app bot commented Nov 18, 2024

Your org has enabled the Graphite merge queue for merging into main

Add 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.

@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Nov 18, 2024
Copy link

codspeed-hq bot commented Nov 18, 2024

CodSpeed Performance Report

Merging #7345 will not alter performance

Comparing azihsoyn:feat/eslint-no-object-constructor (69ba5d4) with main (bf839c1)

Summary

✅ 30 untouched benchmarks

Copy link
Contributor

@no-yan no-yan left a 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.

Comment on lines +74 to +76
ctx.diagnostic(
crate::rules::eslint::no_object_constructor::no_object_constructor_diagnostic(span),
);
Copy link
Contributor

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?

Suggested change
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);",
];
Copy link
Contributor

@no-yan no-yan Nov 19, 2024

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Boshen Boshen requested a review from camc314 November 21, 2024 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants