A friend and I are developing a small react-native app. He recently included Es-lint and prettier to the project and I have an import error I have not been able to resolve since.
Any imports from react-native show the following error
module "C:/Users/Brendan/projects/garden-manager-native/node_modules/@types/react-native/index" Parse errors in imported module 'react-native': ';' expected. (14:32)eslintimport/namespace.
I have the following dependencies in package.json:
"dependencies": {
"@expo/vector-icons": "^13.0.0",
"@react-native-async-storage/async-storage": "~1.15.0",
"@react-navigation/bottom-tabs": "^6.0.5",
"@react-navigation/native": "^6.0.2",
"@react-navigation/native-stack": "^6.1.0",
"@reduxjs/toolkit": "^1.8.0",
"date-fns": "^2.28.0",
"expo": "~44.0.0",
"expo-asset": "~8.4.6",
"expo-camera": "~12.1.2",
"expo-cli": "^5.3.0",
"expo-constants": "~13.0.1",
"expo-file-system": "~13.1.4",
"expo-font": "~10.0.4",
"expo-linking": "~3.0.0",
"expo-splash-screen": "~0.14.1",
"expo-status-bar": "~1.2.0",
"expo-updates": "~0.11.7",
"expo-web-browser": "~10.1.0",
"normalizr": "^3.6.2",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-hook-form": "^7.28.1",
"react-native": "0.64.3",
"react-native-calendars": "^1.1283.0",
"react-native-elements": "^3.4.2",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "~3.10.1",
"react-native-timeline-flatlist": "^0.8.0",
"react-native-vector-icons": "^9.1.0",
"react-native-web": "0.17.1",
"react-redux": "^7.2.6",
"redux-persist": "^6.0.0"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@testing-library/jest-native": "4.0.4",
"@testing-library/react-native": "^9.1.0",
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
"@types/jest": "^27.4.1",
"@types/react": "~17.0.21",
"@types/react-native": "~0.64.12",
"eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-universe": "^11.1.0",
"jest": "^26.6.3",
"jest-expo": "~44.0.0",
"prettier": "^2.7.1",
"react-test-renderer": "17.0.1",
"typescript": "~4.3.5"
},
"private": true,
"resolutions": {
"@types/react": "17.0.2",
"@types/react-dom": "17.0.2",
"react-devtools-core": "4.14.0"
}
My friend is not receiving this error on his end.
I cant seem to find much information on this particular problem but I have tried reinstalling the node_modules folder without any effect.
I know I can disable this rule to remove the error but would prefer to find a better solution.
Per the convo at https://github.com/facebook/react-native/issues/28549#issuecomment-657249702
You should use this pattern as it will not match things like react-native-navigation
.
settings: {
'import/ignore': ['node_modules/react-native/index\\.js$']
}