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

eslint-config: Enforce import types with @typescript-eslint/consistent-type-imports #1623

Merged
merged 3 commits into from
Nov 10, 2023

Conversation

MicroFish91
Copy link
Contributor

@MicroFish91 MicroFish91 commented Nov 9, 2023

How does everyone feel about just adding this as an eslint rule so we don't have to think about whether something should be imported as a type or a value for optimization?

This should make it easier to enforce import types where we can essentially just run eslint --fix

Related: microsoft/vscode-azurecontainerapps#568

@MicroFish91 MicroFish91 marked this pull request as ready for review November 9, 2023 20:30
@MicroFish91 MicroFish91 requested a review from a team as a code owner November 9, 2023 20:30
@bwateratmsft
Copy link
Contributor

Can it be configured so it applies not to internal imports but only to package imports?

@MicroFish91
Copy link
Contributor Author

MicroFish91 commented Nov 10, 2023

Can it be configured so it applies not to internal imports but only to package imports?

I haven't been able to find a way to make this distinction, but if anyone knows of a way please let me know

@bwateratmsft
Copy link
Contributor

bwateratmsft commented Nov 10, 2023

It looks like as long as TS 4.5+ is in use, you can have it fix imports to look like this which IMO is neater:

import { type Foo } from 'bar';

https://typescript-eslint.io/rules/consistent-type-imports/

@MicroFish91 MicroFish91 merged commit 677be89 into main Nov 10, 2023
4 checks passed
@MicroFish91 MicroFish91 deleted the mwf/import-types branch November 10, 2023 19:18
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

Successfully merging this pull request may close these issues.

2 participants