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(eslint-plugin): [triple-slash-reference] fix crash with external module reference #2788

Merged
merged 3 commits into from Nov 25, 2020
Merged

fix(eslint-plugin): [triple-slash-reference] fix crash with external module reference #2788

merged 3 commits into from Nov 25, 2020

Conversation

ddubrava
Copy link
Contributor

@ddubrava ddubrava commented Nov 20, 2020

fixes #2762

https://astexplorer.net/#/gist/cde0bd7d85e03d135e604e7913a999cd/c034332f4ccf256e809629b0552578191e38b3fe

I'm not sure about the solution cuz it's weird that there was used as TSESTree.TSExternalModuleReference and didn't handle any other types considering that moduleReference has already been typed.

…n that module reference is always TSExternalModuleReference
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @ddubrava!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@codecov
Copy link

codecov bot commented Nov 20, 2020

Codecov Report

Merging #2788 (d6d15bf) into master (e82698c) will decrease coverage by 0.00%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master    #2788      +/-   ##
==========================================
- Coverage   92.79%   92.79%   -0.01%     
==========================================
  Files         297      300       +3     
  Lines        9833     9858      +25     
  Branches     2762     2770       +8     
==========================================
+ Hits         9125     9148      +23     
  Misses        332      332              
- Partials      376      378       +2     
Flag Coverage Δ
unittest 92.79% <66.66%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../eslint-plugin/src/rules/triple-slash-reference.ts 93.54% <66.66%> (-3.12%) ⬇️
packages/eslint-plugin/src/rules/array-type.ts 97.33% <0.00%> (-1.30%) ⬇️
packages/scope-manager/src/lib/index.ts 100.00% <0.00%> (ø)
packages/scope-manager/src/lib/es2020.ts 100.00% <0.00%> (ø)
packages/scope-manager/src/lib/esnext.ts 100.00% <0.00%> (ø)
packages/visitor-keys/src/visitor-keys.ts 100.00% <0.00%> (ø)
packages/eslint-plugin/src/rules/ban-types.ts 100.00% <0.00%> (ø)
...ackages/eslint-plugin/src/rules/no-implied-eval.ts 93.75% <0.00%> (ø)
...ckages/eslint-plugin/src/rules/no-throw-literal.ts 95.00% <0.00%> (ø)
...eslint-plugin/src/rules/no-unsafe-member-access.ts 100.00% <0.00%> (ø)
... and 7 more

@bradzacher bradzacher added the bug Something isn't working label Nov 20, 2020
Comment on lines 91 to 97
case AST_NODE_TYPES.Identifier:
value = source.name;
break;

case AST_NODE_TYPES.TSQualifiedName:
value = (source.left as TSESTree.Identifier).name;
break;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should just completely ignore these cases by returning early instead.

There's no import source to compare against here, so doing so will likely lead to some weirdness.

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Nov 20, 2020
…ssumption that module reference is always TSExternalModuleReference"

This reverts commit f1ecd2b.
@ddubrava ddubrava changed the title fix(eslint-plugin): [triple-slash-reference] remove invalid assumption that module reference is always TSExternalModuleReference fix(eslint-plugin): [triple-slash-reference] ignore not TSExternalModuleReference Nov 21, 2020
@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Nov 21, 2020
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

thanks for this!

@bradzacher bradzacher changed the title fix(eslint-plugin): [triple-slash-reference] ignore not TSExternalModuleReference fix(eslint-plugin): [triple-slash-reference] fix crash with external module reference Nov 25, 2020
@bradzacher bradzacher merged commit 32b1b68 into typescript-eslint:master Nov 25, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[triple-slash-reference] TypeError: Cannot read property 'value' of undefined
2 participants