Skip to content

Rule Suggestion: require-import-type-modifiers #2390

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

Open
Nokel81 opened this issue Feb 25, 2022 · 4 comments
Open

Rule Suggestion: require-import-type-modifiers #2390

Nokel81 opened this issue Feb 25, 2022 · 4 comments

Comments

@Nokel81
Copy link
Contributor

Nokel81 commented Feb 25, 2022

With the release of typescript 4.5, it is possible to have type Modifiers on Import Names.

It would be great if there was a (fixable) rule that could be used to require these.

I am willing to implement this.

@ljharb
Copy link
Member

ljharb commented Feb 25, 2022

It seems better to require them be separate import type statements.

@Nokel81
Copy link
Contributor Author

Nokel81 commented Feb 25, 2022

Not if there are only one or two of either kind. But that could be a different option I guess.

@ljharb
Copy link
Member

ljharb commented Feb 25, 2022

It seems unfortunate to have a rule that is only useful for typescript, but perhaps a rule that detects your TS (or flow) version, and can be configured for an order of preferences - ie, between "types as separate import statements", "types mixed with values, but marked with a type modifier", you could prefer one over the other, and it would fall back to the next one if the preferred one wasn't supported, and if neither are supported, the rule would noop.

@yume-chan
Copy link

yume-chan commented Dec 21, 2022

@typescript-eslint/consistent-type-imports can enforce type-only imports to have a type specifier.

import/consistent-type-specifier-style can choose to ban either import type or import { type }

So bad I need two rules! And the second one hasn't been released yet!

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

No branches or pull requests

3 participants