Closed as not planned
Closed as not planned
Description
Hi,
All my exports from .tsx files are reported as not being used when I use absolute paths based on baseUrl set in tsconfig.json
How to reproduce this problem:
- npx create-react-app my-app --template typescript
- cd my-app && npm install eslint-plugin-import
- define a baseUrl of "." in tsconfig.json (in "compilerOptions")
- create a 2 folders in "src/" (name them "a" and "b")
- create a file in each of them ("a/out.tsx" and "b/in.tsx")
- export a function from "a/out.tsx" (fn)
- import fn in "b/in.tsx" using an absolute path ("import {fn} from 'src/a/out';")
- check in "a/out.tsx" if eslint-plugin-import reports "fn" as not being used
- you can add a script in package.json for running the linter ("lint": "eslint . --ext .ts,.tsx")
eslint is configured in package.json like this:
{
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest",
"plugin:import/typescript"
]
"settings": {
"import/resolver": {
"node": {
"extensions": [
".ts",
".tsx"
],
"paths": [
"."
]
}
}
},
"rules": {
"import/no-unused-modules": [
"warn",
{
"missingExports": true,
"unusedExports": true,
"src": [
"."
],
"ignoreExports": [
"src/**/*.d.ts"
]
}
]
}
},
}
Maybe I do something wrong in the way I configure eslint or eslint/eslint-plugin-import has a problem with absolute paths based on baseUrl.
Any help is highly appreciated. Thank you.
Cheers,
Iulian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment