I have just created a new project and I am trying to setup an absolute path by following this post:
eslint-config.json
{
"eslintConfig": {
"extends": ["react-app", "airbnb"],
"settings": {
"import/resolver": {
"node": {
"paths": ["src"],
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
}
}
}
tsconfig.json
{
"extends": "@tsconfig/react-native/tsconfig.json", /* Recommended React Native TSConfig base */
"compilerOptions": {
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
"baseUrl": "src",
},
}
In this image you can see my file structure, the error on my simulator. And how I am importing it.
I have two exported functions in my Text.tsx export function Title & export function P
Any help is appreciated... Thank you!
CodePudding user response:
I will not suggest you to go with this flow because it's very confusing.
Suppose you had imported this react/client
thing.
- Is it the npm package that contains subpath
- Is it my folder structure pathname
So I suggest you to go with the flow that most of the developers are using currently.
import Text from "@/views/Text";
I made one demo for you also, please check https://codesandbox.io/s/sleepy-dew-wn2rsu
Note
- Use
eslint-plugin-import
for removing import errors.