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(lint/noPrototypeBuiltins): add code fix action and cover scenarios from prefer-object-has-own #3997

Merged
merged 7 commits into from
Oct 21, 2024

Conversation

kaioduarte
Copy link
Contributor

Summary

Closes #3927

Test Plan

Snapshots + CI

@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Sep 19, 2024
Copy link

codspeed-hq bot commented Sep 19, 2024

CodSpeed Performance Report

Merging #3997 will not alter performance

Comparing kaioduarte:use-object-has-own (7c37f2e) with main (a3483e4)

Summary

✅ 97 untouched benchmarks

@kaioduarte kaioduarte changed the title feat(lint): add useObjectHasOwn rule feat(linter): add useObjectHasOwn rule Sep 19, 2024
@kaioduarte kaioduarte force-pushed the use-object-has-own branch 2 times, most recently from c168909 to b08c72c Compare September 23, 2024 09:38
@Conaclos
Copy link
Member

Conaclos commented Sep 23, 2024

Hi @kaioduarte!

I am sorry, I completely missed the fact that we already [noPrototypeBuiltins](have https://biomejs.dev/linter/rules/no-prototype-builtins/) which has some overlap with the rule you are implementing.
ESLint has both no-prototype-builtins and prefer-object-has-own, but in Biome we try to avoid overlapping.

I think we could improve noPrototypeBuiltins to include the cases that are not yet covered such as Object.prototype.hasOwnProperty.call(). We could also add a code fix as the one you implemented here.
More globally I could even report any read of a prototype builtins (regardless whether it is called or not), e.g const x = Object.prototype.hasOwnProperty.
What do you think?

@kaioduarte
Copy link
Contributor Author

Sounds good, I'll take a look at that later. Should I add prefer-object-has-own to the rule's sources array?

@Conaclos
Copy link
Member

Should I add prefer-object-has-own to the rule's sources array?

Yes. This will avoid thinking that the rule was not covered.

@github-actions github-actions bot added A-Parser Area: parser and removed A-Diagnostic Area: diagnostocis labels Sep 24, 2024
@kaioduarte
Copy link
Contributor Author

I haven't done the read-only part yet, I only incorporated the changes from the other rule while adapting the code fix.

@kaioduarte kaioduarte changed the title feat(linter): add useObjectHasOwn rule feat(lint/noPrototypeBuiltins): add code fix action and cover scenarios from prefer-object-has-own Sep 24, 2024
@Conaclos
Copy link
Member

Conaclos commented Sep 24, 2024

LGTM
Blocking the merging until we decide we no longer ship patch version for Biome 1.9.

I haven't done the read-only part yet, I only incorporated the changes from the other rule while adapting the code fix.

This could be left for another PR.

@ematipico ematipico added the S-Merge for next minor Status: the PR should be merged in the next minor label Oct 14, 2024
@ematipico ematipico merged commit 383d3f7 into biomejs:main Oct 21, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Linter Area: linter A-Parser Area: parser A-Project Area: project L-JavaScript Language: JavaScript and super languages S-Merge for next minor Status: the PR should be merged in the next minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📎 Implement useObjectHasOwn - eslint/prefer-object-has-own
3 participants