I add typescript config for paths (alias):
tsconfig.json
{
"compilerOptions": {
"jsx": "react",
"baseUrl": "src",
"paths": {
"@components/*": ["components/*"]
}
},
"exclude": [
"node_modules",
"public"
]
}
After that I try import somthing like this:
import Header from '@components/header';
And now I get error in eslint: ESLint: Unable to resolve path to module '@components/header'.(import/no-unresolved)
I found a solution in this: eslint-import-resolver-typescript
npm i -D eslint-plugin-import @typescript-eslint/parser eslint-import-resolver-typescript
.eslintrc.js
module.exports = {
'settings': {
'import/resolver': {
'typescript': {},
},
},
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With