[HELP] Can not get plugin to work with path aliases
See original GitHub issueHi there,
Sorry if this is a situation where I am being dense – most likely the case. I have spent the last couple hours trying to get the plugin to work but to no avail.
I have search previous questions here and on Stack Overflow but I just can’t find any solution which makes eslint play ball with my typescript paths.
Basically, it always gives me an error if I import a module via its mapped alias in the tsconfig file. If I change it to a relative path it is fine. Typescript has no issues finding the modules it is just eslint being a pain.
Some code
// tsconfig.json
...
"baseUrl": "src",
"paths": {
"@services/*": ["services/*"],
"@constants/*": ["constants/*"],
"@typeDefs/*": ["typeDefs/*"],
"@config/*": ["config/*"],
"@utils/*": ["utils/*"],
"@assets/*": ["assets/*"]
}
...
// Eslint config
...
"plugins": ["@typescript-eslint", "prettier", "import"],
"extends": [
"airbnb-base",
"airbnb-typescript/base",
"prettier",
"eslint:recommended",
"plugin:import/typescript",
"plugin:import/recommended",
"plugin:node/recommended"
],
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module",
"project": "tsconfig.json"
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": "tsconfig.json"
}
},
"node": {
"tryExtensions": [".ts"]
}
}
...
And I am importing as follows:
import { someFunc } from "@services/index";
Further info: Node version: v14.20.0 NPM version: 8.14.0
All packages have been downloaded today so they are all the latest.
Sorry again if I am being dense I am just at wits end. Thank you in advance
Issue Analytics
- State:
- Created a year ago
- Comments:7
I don’t find any issue related to this resolver.
node/no-missing-import
should just be disabled when using together witheslint-plugin-import
because it is redundant.No probs thank you for responding so quickly I really appreciate it