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
[import/extensions] 2.20.0 still shows errors for importing TS files from JS files without an extension #1615
Comments
We're seeing |
I had the same problem with This fixed it for me: settings: {
'import/resolver': {
node: {
extensions: ['.mjs', '.js', '.json', '.vue'],
},
},
}, Try to replace |
@denisinvader No luck unfortunately (plugin:import/typescript should still be working anyway). |
I'm also getting this error when importing Even explicitly changing the settings in my "settings": {
"import/extensions": [".js", ".mjs", ".jsx", ".js", ".jsx", ".ts", ".tsx"]
}, or setting the rule directly to: "import/extensions": [
"error",
"always",
{
"ts": "never",
"tsx": "never",
"js": "never",
"jsx": "never"
}
], |
@maclockard It seems like Do you use typescript resolver? I had to update config after the package upgrade and add the resolver for webpack but now my linter works much better and can understand aliased imports like Unfortunately, I have zero experience in typescript so my suggestions are more assumptions |
Nevermind, this is working correctly for when I set this in the
and set this in the
I believe in 2.18.3 it wasn't reporting errors that it should have been reporting based on my config (I was not overriding the default |
To clarify, when using |
@thewilkybarkid I think you still need to override |
The airbnb config doesn't include typescript extensions, so yes, you need to override both. |
|
Tested locally and that works, so opened #1637. |
Hello @thewilkybarkid ! Is your change already in the codebase? I see it was committed however I still get this error. I use "eslint-plugin-import": "^2.20.1" |
@javierguzman It was closed rather than committed (see #1637 (review)). For my case I'm switching to using eslint-config-airbnb-typescript rather than eslint-config-airbnb-base directly. |
@thewilkybarkid Thanks! I will keep that package in mind, I think for now I will stick with specifying the never rule thing mentioned above... |
I got the same problem with .vue file and it took me a whole day, read every single thread about these 2 rules (import/extensions and import/no-unresolved), and still got errors. after trying your setting, it works like a charm, and I still have no idea why :-| here are my .eslintrc.js file rules: {
//...
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
mjs: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
vue: 'never',
},
],
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.vue'],
},
},
}, |
* adding eslint and lint scripts * adding pre-commit hook * whitespace fixup * specifying .ts files in lint npm scripts * fixing issue related to TypeScript + AirBnB defaults: import-js/eslint-plugin-import#1615 (comment) * adding mocah env * adding rule exception for chai 'expect' statements
@Methuselah96 - are you still having this issue for 2.22.0? I am still seeing issue. |
@lvdang No, I posted the solution above: #1615 (comment). |
@Methuselah96: No, i doesn't work for me:
still got the error:
|
For those using rules:
# js/ts file extensions
import/extensions: ["error", "ignorePackages", {js: "never", mjs: "never", jsx: "never", ts: "never", tsx: "never"}] |
This is the same error I was getting on 2.19.1 (as seen in #1558). The error does not appear in 2.18.3.
The text was updated successfully, but these errors were encountered: