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

Bug: import type fails with no-missing-import if node fails to resolve the import #286

Closed
1 task
perrin4869 opened this issue Jun 2, 2024 · 4 comments · Fixed by #344
Closed
1 task
Labels

Comments

@perrin4869
Copy link

Environment

ESLint version: 8.57.0
eslint-plugin-n version: 17.7.0

What rule do you want to report?

n/no-missing-import

Link to Minimal Reproducible Example

https://eslint-online-playground.netlify.app/#eNp1kk1uwyAQha+C2KSVYpxFV+mmi96gy5BKrhlbTvFAAUepIt+9A/6JkzQbjJmP94YHZ+5dmcOpaK0GETzf8qa1xgUWfi2wD3BHcBq8Z5UzLZPczyuSS5RYGvSGtmpTP13oZ77m4HWDQRBQNbU4LKQPs9rbAOUHUnuVOFmP9VXswZeusSEbwNUFQqNgxIZaZnVXN5hhhCTCKWEKqqLTge0kMjIe2/HCQWnaFlCBWseSEHT6h9VoNhV3kle6CPmCyYYmJd8n+hwHxlxHUWynP8Z+OhPiAgmAc8ZJvqYIlOm+NExbGevTN457OgflaIvyu6iBEjRIGSY5yWM0km9p1hpFRiQ2FBQc38HGtrBsgHKdOyDbFNSwjY4Anuaj7fVd/AvcxPyAWj6QCHy+iI3YLH3Srea33J3Q3eVfcykliT3v/wAjz/CN

What did you expect to happen?

An import that only imports a type should be excluded from n/no-missing-import. In the example above, serverless@4 stopped providing their main file, and this causes the linting to fail

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

@perrin4869 perrin4869 added the bug label Jun 2, 2024
@scagood
Copy link

scagood commented Jun 2, 2024

🤔 It sounds like this should be listed in the allowModules option, as serverless is actually missing.


I wonder if there is a better way to route to the @types in enhanced resolve.

@perrin4869
Copy link
Author

yeah this does seem like a really tricky one, I think ideally this would be handled by this plugin, even if it's just a warning, but I can live with ignoring the rule or adding it to allowModules

@aladdin-add
Copy link

aladdin-add commented Jun 3, 2024

I think we can just ignore these cases (they should have been caught by ts).

the rule no-unpublished-import has an option ignoreTypeImport : https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-unpublished-import.md#ignoretypeimport. we could add it to no-missing-import, too.

and considering enabling it by default in the next major version. 🤔

@scagood
Copy link

scagood commented Jun 5, 2024

Im of two minds about enabling that by default.

On one hand I would rather correctly fix resolving the import type ... or import { type something} ... to the type definitions.

But on the other hand, that is not a "node" problem, and just ignoring type imports seems to make a world of sense, as we can the the typescript linter handle them.


I am currently leaning towards adding ignoreTypeImport to no-missing-import and making it default.

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

Successfully merging a pull request may close this issue.

3 participants