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

Use TypeScript imports resolver #1505

Open
mrhyde opened this issue Apr 8, 2024 · 6 comments
Open

Use TypeScript imports resolver #1505

mrhyde opened this issue Apr 8, 2024 · 6 comments

Comments

@mrhyde
Copy link

mrhyde commented Apr 8, 2024

Hi! Are there any plans to use TypeScript imports resolver in eslint-plugin-import? It seems a bit off that this package is designed for TypeScript but doesn't include this by default.

P.S. Thank you for all your hard work over the years! Your efforts deserve more recognition!

@mightyiam
Copy link
Owner

Thank you. This seems to introduce a good amount of details. Would you be interested in contributing it?

@mrhyde
Copy link
Author

mrhyde commented Apr 8, 2024

Sure! Just wanted to be sure that it's something you are interested in

@mrhyde
Copy link
Author

mrhyde commented Apr 8, 2024

@mightyiam I have created #1509 let me know what you think

@psychobolt
Copy link

psychobolt commented Jul 10, 2024

Seems like the original PR was rejected. In my case, I'm not looking for a code mod feature, but somehow VSCode doesn't really provide great visibility for unused imports e.g.

Screenshot 2024-07-09 at 9 05 40 PM

As you can see, lower opacity is something not ideal. However, if I however over the the problem, I can see it clearly.

Screenshot 2024-07-09 at 9 05 51 PM

TS Language Server also doesn't seem to populate the Problems tab and my TypeScript compilier doesn't even complain about it! So my project will probably be filled with unused code that requires code modding. Not what I expected if we are able to do a lint checker. I also expected TS to not give out false positives...

Anyway for alternatives, I suggest:
https://github.com/un-ts/eslint-plugin-import-x
https://www.npmjs.com/package/eslint-import-resolver-typescript
https://www.npmjs.com/package/eslint-plugin-unused-imports

@mightyiam
Copy link
Owner

@psychobolt doesn't that seem like an IDE issue to you? Does tsc complain about it?

@psychobolt
Copy link

psychobolt commented Jul 10, 2024

Seems like you have to explicitly tell TypeScript to warn about unused variables e.g

    "noUnusedLocals": true

Screenshot 2024-07-10 at 7 55 34 AM

If I turn on this compilerOption, tsc will complain. Anyways there is already a rule no-unused-vars for ts-eslint: https://typescript-eslint.io/rules/no-unused-vars/ which seem enabled by default. I'm not sure if import resolver is suppose to handle that, but eslint is not warning about unused imports. Until I enabled that option I mentioned, those TS errors will be shown also in linter.

Some more info on how the IDE works: microsoft/vscode#219335

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

3 participants