Closed
Description
I have started a new react app and defined baseUrl as "./" on my tsconfig.json. Added eslint-import-resolver-typescript
and empty settings on .eslintrc.js but still got Unable to resolve path
error, despite imports worked as expected. Tried to specify tsconfig.json location on project property but got title error. All package.json, tsconfig.json and .eslintrc.js are on root folder, code is on /src.
These are my current config files:
.eslintrc.js
:
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
"eslint:recommended",
"plugin:import/recommended",
"plugin:react/recommended",
"airbnb",
"plugin:prettier/recommended",
"plugin:import/typescript",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: "module",
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {},
},
},
plugins: ["import", "react", "@typescript-eslint"],
rules: {
"react/react-in-jsx-scope": "off",
"react/jsx-filename-extension": [
2,
{ extensions: [".js", ".jsx", ".ts", ".tsx"] },
],
},
};
}
{
"name": "react",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"connected-react-router": "^6.9.1",
"feather-icons": "^4.28.0",
"history": "^5.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"redux": "^4.1.0",
"typescript": "^4.3.2",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"eslint": "^7.27.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.23.3",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react-hooks": "^4.2.0",
"prettier": "^2.3.0"
}
}
.tsconfig.json:
{
"compilerOptions": {
"noFallthroughCasesInSwitch": true,
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"noImplicitAny": false,
"strict": true
},
"include": ["src"]
}