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

feat(rome_js_analyze): noSelfCompare rule #4031

Merged
merged 4 commits into from
Dec 16, 2022

Conversation

kaioduarte
Copy link
Contributor

Summary

Closes #3982.

Test Plan

cargo test -p rome_js_analyze -- no_self_compare

@kaioduarte kaioduarte requested review from leops, ematipico, xunilrj and a team as code owners December 10, 2022 16:22
@netlify
Copy link

netlify bot commented Dec 10, 2022

Deploy Preview for docs-rometools ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 8162104
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/639b4a713843ef00086d38db
😎 Deploy Preview https://deploy-preview-4031--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.

@ematipico
Copy link
Contributor

@kaioduarte could you please comment on the issue? Doing so, I can assign the issue to you. This will help showing that the issue is being assigned already

```

```
noSelfCompare.js:26:1 lint/nursery/noSelfCompare ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not a huge fan of these cases where the expression is very complex.

Not only the expression can have side effects, it is also very hard to known what "self" is, to say that we are comparing something with itself.

Makes sense to short circuit the comparison in problematic nodes like function calls?

Comment on lines +79 to +80
/// Verifies that both nodes are equal by checking their descendants (nodes included) kinds
/// and tokens (same kind and inner token text).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we mark these as equal nodes?

a.b.c === a?.b.c

they have the same meaning in the end

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't the first one throw? and the second no?

If we remove this expression, a function can stop throwing.
Maybe this is a good thing, but we are changing behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, in that sense they are different, but not if we only consider the identifiers chain. Anyway, maybe it's fine to keep it as is.

@ematipico ematipico merged commit 8597c39 into rome:main Dec 16, 2022
@kaioduarte kaioduarte deleted the feat/no-self-compare branch December 16, 2022 10:17
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.

noSelfCompare, no-self-compare
5 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载