TypeScript import/order regression
joaovieira opened this issue · comments
I've just upgraded to eslint-plugin-import@2.18.2
and eslint-import-resolver-typescript@2.0.0
and started to get import/order
errors:
Any module defined in @types/*
(e.g. @types/express
in this case) is seen as "internal", while modules with their own types (e.g. http-status-codes
) are seen as "external". I've tried with other modules as well.
Changing the default order to:
'import/order': [
'error',
{
groups: ['internal', 'external'],
},
],
Gets rid of the error.
Can't understand the root cause though, but here's some logging from the resolver if it helps:
The import/order
rule history doesn't seem to have anything suspicious. Could the new version of the resolver be causing this?
Yes, that sounds like it's due to the typescript resolver.
So, the package name is express
, path is node_modules/@types/express/index.d.ts
:
- it passes the external regexp
- but it's not external because
path.indexOf('node_modules/express') == -1
We could simply use the import/external-module-folders
setting to include the @types
folder as ['node_modules', 'node_modules/@types']
in the typescript config, or change the isExternalPath
logic to account for these scenarios.
@ljharb what do you think is best? I'm worried that with the setting it doesn't solve the problem for people that are already overriding it.
Answer from eslint-import-resolver-typescript:
import/order generates wrong order with 2.0
I think I've also got this issue in our projects at work when updating things...
@Evalon's linked issue has been closed and locked and now @ljharb has closed this issue without an explanation or mention of it being explicitly fixed? 🤔
So what's actually the suggested solution here? Are we waiting on something to be merged or does something else need doing somewhere?
Edit: realize now this issue might be unrelated due to it's age and rolling back to 2.20.0 resolved my issue - created: #1643
@South-Paw in fact, it was closed by the PR #1526, which has been released - do you not see that in the timeline entry?