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
add consistent type import eslint rule #2899
Conversation
I'm sorry, I just don't understand the benefit of this rule. Can you please explain? |
fbc3c2b
to
9b806f4
Compare
Hey, sorry it took so long to get back with an answer; this was super low on the 3.0 priority list. I primarily had 2 reasons for wanting to introduce this change:
At the end of the day, types/interfaces are "syntactic sugar" in typescript that won't get emitted in the transpiled javascript code we deliver. This should have no impact on consumers besides being a utility to help developers. I think it'll be worth it and has already proven to be helpful in determining deps of the vcr and client repos. Additional reading on type-only imports/exports if you're interested: |
@aruniverse I have somewhat mixed feelings on this rule... I'm definitely a huge fan of the But two things are concerning to me here:
|
Good points @wgoehrig ! Re 1: Agreed, there are some files that are already larger than they ought to be, and this def doesn't help. A little bit more uglier and effort is needed to determine if a pkg can be a devDep imo (I'm prob very lazy so that doesn't help), but I can see the benefit of saving lines, and it's not that bad. Re 2: From what ive seen vscode won't automatically add the type annotation. Agreed this can be very annoying if the linter fails your pr because of this; its why I added the I think we'll need to wait on this, typescript-eslint/typescript-eslint#4338 I'm not opposed to leaving this PR as a draft until we find a perfect solution. |
@aruniverse I was wondering why you added the lint:fix script... I don't think you need it, vscode should do it automatically when you save a file. The only potential problem is that you had to disable no-duplicate-imports so we might end up with several type imports from the same module. |
You can now achieve this with |
Add @typescript-eslint/consistent-type-imports to recommended eslint plugins
Add
lint:fix
npm scriptsRun new rule across entire monorepo