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

fix(analyze/js): fix bindings in bogus imports not being detected as imports #4578

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

dyc3
Copy link
Contributor

@dyc3 dyc3 commented Nov 18, 2024

Summary

This fix attempts to fix #4568 such that the same issue won't pop up in other lint rules.

I suppose a better fix could be to not evaluate linter rules if the file has parsing errors. Would it be better to add a JS_BOGUS_IMPORT instead?

fixes #4568

Test Plan

Tested it manually against the sample in the issue.

@github-actions github-actions bot added the L-JavaScript Language: JavaScript and super languages label Nov 18, 2024
@dyc3 dyc3 changed the title fix(analyze/js): fix some imports not being detected fix(analyze/js): fix bindings in bogus imports not being detected as imports Nov 18, 2024
Copy link
Contributor

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 48595 48595 0
Passed 47403 47403 0
Failed 1192 1192 0
Panics 0 0 0
Coverage 97.55% 97.55% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6586 6586 0
Passed 2208 2208 0
Failed 4378 4378 0
Panics 0 0 0
Coverage 33.53% 33.53% 0.00%

ts/babel

Test result main count This PR count Difference
Total 680 680 0
Passed 608 608 0
Failed 72 72 0
Panics 0 0 0
Coverage 89.41% 89.41% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18618 18618 0
Passed 14273 14273 0
Failed 4345 4345 0
Panics 0 0 0
Coverage 76.66% 76.66% 0.00%

@arendjr
Copy link
Contributor

arendjr commented Nov 18, 2024

I suppose a better fix could be to not evaluate linter rules if the file has parsing errors.

I think we do want to run rules on files that have bogus nodes, because bogus states are to be expected while the user is typing and we don't want diagnostics to temporarily disappear just because they are temporarily in an invalid syntax state.

Would it be better to add a JS_BOGUS_IMPORT instead?

Sometimes having a more specific bogus node can indeed help the error recovery become more resilient. But if the change you made now already resolves the issue, my guess is that's it's not needed here? This is something @denbezrukov is usually quite knowledgeable about, if I'm not mistaken.

@dyc3 dyc3 closed this Nov 19, 2024
@dyc3 dyc3 reopened this Nov 19, 2024
@dyc3
Copy link
Contributor Author

dyc3 commented Nov 19, 2024

my guess is that's it's not needed here?

Technically, sure, to resolve the issue. But I want to make sure we resolve this with a more preventative measure to make sure this doesn't pop up again.

Ultimately, this issue was caused by an assumption (as shown by usage of unreachable!()) that was proven to be false (via fuzzing). So I'm thinking it would make more sense to add a JS_BOGUS_IMPORT node, whether that's in this PR or a different one.

I don't think I have the bandwidth right now to add the node, but I could write up a task detailed enough for someone else to pick up.

@ematipico
Copy link
Member

Out of curiosity, can't we remove the unreachable from the rule's code?

@dyc3
Copy link
Contributor Author

dyc3 commented Nov 19, 2024

Yup, could do that too. I'll go ahead and add that to this PR.

@dyc3 dyc3 force-pushed the 11-18-fix_analyze_js_fix_some_imports_not_being_detected branch from db1a4e4 to a723d56 Compare November 19, 2024 12:57
@dyc3 dyc3 marked this pull request as ready for review November 19, 2024 12:58
@github-actions github-actions bot added the A-Linter Area: linter label Nov 19, 2024
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Looks good! We should update the changelog and - if possible - add a test with the code coming from the issue

@dyc3 dyc3 force-pushed the 11-18-fix_analyze_js_fix_some_imports_not_being_detected branch from a723d56 to 883cca5 Compare November 19, 2024 13:23
@github-actions github-actions bot added the A-Changelog Area: changelog label Nov 19, 2024
@dyc3 dyc3 force-pushed the 11-18-fix_analyze_js_fix_some_imports_not_being_detected branch from 883cca5 to 389c0bc Compare November 19, 2024 13:25
Copy link

codspeed-hq bot commented Nov 19, 2024

CodSpeed Performance Report

Merging #4578 will not alter performance

Comparing 11-18-fix_analyze_js_fix_some_imports_not_being_detected (389c0bc) with main (b8ca13e)

Summary

✅ 99 untouched benchmarks

@dyc3 dyc3 merged commit 2648fa4 into main Nov 19, 2024
13 checks passed
@dyc3 dyc3 deleted the 11-18-fix_analyze_js_fix_some_imports_not_being_detected branch November 19, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Panic internal error: entered unreachable code in lint/correctness/use_exhaustive_dependencies.rs
3 participants