[import/no-unresolved] when using with typescript and "paths" option
See original GitHub issueI get [import/no-unresolved] error with eslint while using typescript tsconfig.json paths option.
nextjs + typescript + eslint
My eslint file
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: { jsx: true },
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
// Prettier plugin and recommended rules
'plugin:prettier/recommended',
],
rules: {
// Include .prettierrc.js rules
'prettier/prettier': ['error', {}, { usePrettierrc: true }],
'no-empty': 'off',
'react/prop-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/interactive-supports-focus': 'off',
'jsx-a11y/no-noninteractive-element-interactions': 'off',
'jsx-a11y/no-onchange': 'off',
},
settings: {
'import/extensions': ['.js', '.jsx', '.tsx', '.ts'],
'import/resolver': {
typescript: {},
},
},
};
In tsconfig.json i use paths
"paths": {
"@/core/*": ["src/core/*"],
}
and get errors from eslint like
18:23 error Unable to resolve path to module '@/core/useRouter' import/no-unresolved
Compilation build all works great, just linting fails eslint
Issue Analytics
- State:
- Created 2 years ago
- Reactions:13
- Comments:17 (2 by maintainers)
Top Results From Across the Web
[import/no-unresolved] when using with typescript "baseUrl ...
[import/no-unresolved] when using with typescript "baseUrl" and "paths" ... It should respect baseUrl and paths option on tsconfig.json.
Read more >Using eslint with typescript - Unable to resolve path ...
In my eslintrc.js config file, the "import/resolver" object needed to sit within the "rules" node, not the " ...
Read more >eslint-import-resolver-typescript
Start using eslint-import-resolver-typescript in your project by running `npm i eslint-import-resolver-typescript`.
Read more >Typescript — How to solve the problem with unresolved ...
Since the outDir is the “build” subfolder, we have to check one by one all the .js files under it, to find if...
Read more >Typescript – How to solve the problem with unresolved path ...
js file containing the line with the path alias. The actual cause of the issue is that the tsc compiler does not transpiles...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
On the plugin docs (https://github.com/alexgorbatchev/eslint-import-resolver-typescript):
Adding
has worked for me - the
import/parsersbit seemed to fix it.this is with
"eslint-import-resolver-typescript": "^2.7.1",I’ve tried all the suggestions above and still get this error. Can anyone help
my root tsconfig.json
My referenced typescript project tsconfig.json