Thanks to visit codestin.com
Credit goes to github.com

Skip to content

New rule: consistent-type-import #1985

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

Closed
rfermann opened this issue May 7, 2020 · 4 comments
Closed

New rule: consistent-type-import #1985

rfermann opened this issue May 7, 2020 · 4 comments
Labels
enhancement: new plugin rule New rule request for eslint-plugin package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@rfermann
Copy link

rfermann commented May 7, 2020

Repro

import type { FooType } from './foo-type';
import { FooType } from './foo-type';

const fooType: import("foo-type").FooType = {}

All 3 lines above are valid ways of importing types.

Expected Result
A rule informing about the mix of different ways of type importing can be helpful to keep a consistent way of importing types over the project.

Actual Result
As for my knowledge there is no rule available for this purpose.

@rfermann rfermann added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels May 7, 2020
@bradzacher bradzacher added enhancement: new plugin rule New rule request for eslint-plugin and removed triage Waiting for team members to take a look labels May 7, 2020
@David-Else
Copy link

Is there any reason to not always use the new import type syntax? It seems to be the most succinct.

@bradzacher
Copy link
Member

It means you have to separate your type imports from your value imports:

import type { MyInterface } from 'foo';
import { MyValue } from 'foo';

Also for people that don't use babel, in 99.9% of imports, it won't provide any tangible benefits.

@David-Else
Copy link

I like the fact you have to separate your type imports from your value imports, makes it cleaner.

@bradzacher
Copy link
Member

Merging into #2200

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: new plugin rule New rule request for eslint-plugin package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants