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

some.object && some.object.fn() and this.object && this.object.value not handled #51

Open
connorjclark opened this issue Dec 20, 2021 · 2 comments

Comments

@connorjclark
Copy link
Contributor

I used this tool on a large codebase, and came across some cases that were missed. Here's
everything I found:

GoogleChrome/lighthouse#13503 (comment)
(link to code at particular commit)
https://github.com/GoogleChrome/lighthouse/tree/11a6a030f3e29910be6dc1166f17e085c17da6da

I believe the following specific examples show every unique case missed.


Does not transform:

const hasMetricError = lhr.categories.performance && lhr.categories.performance.auditRefs
  .some(audit => Boolean(audit.group === 'metrics' && lhr.audits[audit.id].errorMessage));

But it will transform this:

const hasMetricError = lhr.categories.performance && lhr.categories.performance.auditRefs;

Perhaps function calls are not handled?


Does not transform:

this.json.audits['script-treemap-data'] && this.json.audits['script-treemap-data'].details

or

this.json.audits.blah && this.json.audits.blah.details

Perhaps this. is not handled?

@villesau
Copy link
Owner

villesau commented Dec 20, 2021

ThisExpression needed some special attention but this seemed to work: https://github.com/villesau/optional-chaining-codemod/pull/54/files

@villesau
Copy link
Owner

And yeah, function calls are not currently handled. Doesn't seem to be super straight forward to fix either unfortunately :/ If you want to give it a try, pull requests are very welcome! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants