Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_js_analyze): noPrototypeBuiltins #4101

Merged
merged 6 commits into from
Jan 9, 2023
Merged

feat(rome_js_analyze): noPrototypeBuiltins #4101

merged 6 commits into from
Jan 9, 2023

Conversation

unvalley
Copy link
Contributor

Closes #3979

Summary

Implement a rule noPrototypeBuiltins.

  • I reffered to ESLint docs no-prototype-builtins.
  • I noted about using hasOwn() instead of hasOwnProperty()

Test Plan

cargo test -p rome_js_analyze -- no_prototype_builtins

Documentation

  • The PR requires documentation
  • [ ] I will create a new PR to update the documentation
    • added docs by just codegen

@netlify
Copy link

netlify bot commented Dec 23, 2022

Deploy Preview for docs-rometools ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 120d959
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/63bc09abbfa4730008ec0ba9
😎 Deploy Preview https://deploy-preview-4101--docs-rometools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

foo?.hasOwnProperty(bar);
(foo?.hasOwnProperty)("bar");
foo?.["hasOwnProperty"]("bar");
(foo?.[`hasOwnProperty`])("bar");
Copy link
Contributor Author

@unvalley unvalley Dec 23, 2022

Choose a reason for hiding this comment

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

I created test cases based on ESLint test cases.

I didn't add a test for:

String.raw`foo.bar["propertyIsEnumerable"]('baz')`

Honestly, I couldn't find out how to recreate JsCallExpression from the token foo.bar["propertyIsEnumerable"]('baz'). If I should handle the case, please tell me the way...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can skip it for now, if you think it requires another PR to add this case.

@unvalley unvalley marked this pull request as ready for review December 23, 2022 14:33
foo?.hasOwnProperty(bar);
(foo?.hasOwnProperty)("bar");
foo?.["hasOwnProperty"]("bar");
(foo?.[`hasOwnProperty`])("bar");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can skip it for now, if you think it requires another PR to add this case.

@unvalley
Copy link
Contributor Author

@ematipico Thanks for reviewing, I updated the PR.

unvalley and others added 6 commits January 9, 2023 21:09
chore: just codegen

test: update snapshot and docs

chore: cargo fmt

chore: just codegen

chore: fix indent

test: update note for hasOwn

chore: just codegen

docs: update for note about hasOwn

Update crates/rome_js_analyze/src/analyzers/nursery/no_prototype_builtins.rs

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>

Update crates/rome_js_analyze/src/analyzers/nursery/no_prototype_builtins.rs

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>

Update crates/rome_js_analyze/src/analyzers/nursery/no_prototype_builtins.rs

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>

Update crates/rome_js_analyze/src/analyzers/nursery/no_prototype_builtins.rs

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>

Update crates/rome_js_analyze/src/analyzers/nursery/no_prototype_builtins.rs

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
test: update snapshot

chore: just codegen
chore: cargo fmt
@ematipico ematipico merged commit e0325d3 into rome:main Jan 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

noPrototypeBuiltins, no-prototype-builtins
2 participants