I have installed eslint
for a next.js
project which uses typescript and absolute paths.
When I try to import a component which has a .tsx
extension using the absolute path I get the following eslint error.
Unable to resolve path to module 'componentsFolder/MyComponentFile'.eslintimport/no-unresolved
The code works fine and only eslint gives a red warning
I have followed the solutions described in this answer, how ever nothing seems to work.
The current state of my eslint.json is as follows.
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"airbnb"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint"
],
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".jsx",
".ts",
".tsx"
]
}
}
},
"rules": {
"react/react-in-jsx-scope": "off",
"react/jsx-filename-extension": [
1,
{
"extensions": [
".jsx",
".tsx"
]
}
],
"react/prop-types": 0,
"no-underscore-dangle": 0
}
}
The tsconfig.json file is as follows.
{
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
}