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): [consistent-type-imports] crash when using both default and namespace in one import #2778

Merged

Conversation

ota-meshi
Copy link
Contributor

Fixes #2775

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @ota-meshi!

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 18, 2020

Codecov Report

Merging #2778 (b1f2c7a) into master (c2dde58) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2778      +/-   ##
==========================================
+ Coverage   92.80%   92.81%   +0.01%     
==========================================
  Files         300      300              
  Lines        9857     9871      +14     
  Branches     2769     2773       +4     
==========================================
+ Hits         9148     9162      +14     
  Misses        332      332              
  Partials      377      377              
Flag Coverage Δ
unittest 92.81% <100.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
...eslint-plugin/src/rules/consistent-type-imports.ts 97.15% <100.00%> (+0.24%) ⬆️

@bradzacher bradzacher added the bug Something isn't working label Nov 18, 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 hopping in to fix this!

// eslint-disable-next-line @typescript-eslint/internal/plugin-test-formatting
output: noFormat`
import type Default from 'module';
import * as Rest from 'module';
Copy link
Member

Choose a reason for hiding this comment

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

Hard to notice, but this is being fixed with a double space: import\ \ *.
We probably don't want to be doing that if we can avoid it.

Comment on lines 1100 to 1129
// eslint-disable-next-line @typescript-eslint/internal/plugin-test-formatting
output: noFormat`
import type * as Rest from 'module';
import Default from 'module';
const a: Rest.A = '';
`,
Copy link
Member

Choose a reason for hiding this comment

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

I'd consider just dedenting the entire block to 0 (both code and output) so it matches instead of disabling the lint rule

Suggested change
// eslint-disable-next-line @typescript-eslint/internal/plugin-test-formatting
output: noFormat`
import type * as Rest from 'module';
import Default from 'module';
const a: Rest.A = '';
`,
output: noFormat`
import type * as Rest from 'module';
import Default from 'module';
const a: Rest.A = '';
`,

Comment on lines 1120 to 1148
// eslint-disable-next-line @typescript-eslint/internal/plugin-test-formatting
output: noFormat`
import type Default from 'module';
import * as Rest from 'module';
const a: Default = '';
`,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// eslint-disable-next-line @typescript-eslint/internal/plugin-test-formatting
output: noFormat`
import type Default from 'module';
import * as Rest from 'module';
const a: Default = '';
`,
output: noFormat`
import type Default from 'module';
import * as Rest from 'module';
const a: Default = '';
`,

Comment on lines 1141 to 1169
// eslint-disable-next-line @typescript-eslint/internal/plugin-test-formatting
output: noFormat`
import type * as Rest from 'module';
import type Default from 'module';
const a: Default = '';
const b: Rest.A = '';
`,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// eslint-disable-next-line @typescript-eslint/internal/plugin-test-formatting
output: noFormat`
import type * as Rest from 'module';
import type Default from 'module';
const a: Default = '';
const b: Rest.A = '';
`,
output: noFormat`
import type * as Rest from 'module';
import type Default from 'module';
const a: Default = '';
const b: Rest.A = '';
`,

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Nov 21, 2020
@ota-meshi
Copy link
Contributor Author

Thank you for checking! I changed this PR.

I didn't know that 0 indentation would eliminate the format error. Thank you for telling me about this. I also fixed some related pre-existing test cases.

@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Nov 22, 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 working on this!

@bradzacher bradzacher changed the title fix(eslint-plugin): [consistent-type-imports] crash when using default and namespace fix(eslint-plugin): [consistent-type-imports] crash when using both default and namespace in one import Nov 25, 2020
@bradzacher bradzacher merged commit c816b84 into typescript-eslint:master Nov 25, 2020
@ota-meshi ota-meshi deleted the fix-consistent-type-imports branch November 25, 2020 21:42
@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.

[@typescript-eslint/consistent-type-imports] Crash when using default imports
2 participants