我最近将我的 React Native 升级到了
0.73.9
。我没有注意到,但我的文件不再根据 Eslint 配置进行格式化。我也没有从回调 [] 中得到建议。我目前使用以下格式https://github.com/Rocketseat/eslint-config-rocketseat。
这是我的文件,
.eslintrc.json
{
"extends": "@rocketseat/eslint-config/react",
"plugins": [
"unused-imports"
],
"rules": {
"no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
]
}
}
tsconfig.js
{
"compilerOptions": {
"experimentalDecorators": true,
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"preserveConstEnums": true,
"isolatedModules": true,
"jsx": "react-native",
"lib": ["ES2015", "ES2016", "ES2017", "ES2018", "ES2019", "ES2020"],
"moduleResolution": "Bundler",
"noEmit": true,
"strict": true,
"target": "esnext",
"types": ["react-native", "jest", "styled-components-react-native"],
"resolveJsonModule": true,
"baseUrl": "./src",
"paths": {
"@/*": ["*"]
}
},
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"],
"extends": "@react-native/typescript-config/tsconfig.json"
}
我有以下 vscode 配置:
{
"editor.formatOnSave": false,
}
例如,根据 Eslint 配置,
;
不应该存在,但保存时它不会被删除:
...code
function resetForm() {
form.resetField('nome')
form.resetField('cpf')
form.resetField('observacoes')
form.setValue('foto', undefined);
}
package.json
:
{
"dependencies": {
"@bam.tech/react-native-image-resizer": "^3.0.10",
"@gorhom/bottom-sheet": "^4",
"@hookform/resolvers": "^3.9.0",
"@intercom/intercom-react-native": "^4.0.1",
"@nozbe/watermelondb": "^0.25.5",
"@react-native-async-storage/async-storage": "^1.17.11",
"@react-native-community/datetimepicker": "^7.6.2",
"@react-native-community/netinfo": "^9.3.7",
"@react-navigation/bottom-tabs": "^6.5.3",
"@react-navigation/drawer": "^6.6.6",
"@react-navigation/native": "^6.1.2",
"@react-navigation/native-stack": "^6.9.8",
"@react-navigation/stack": "^6.3.11",
"@tanstack/react-query": "^4.24.4",
"@uidotdev/usehooks": "^2.4.1",
"axios": "^1.2.3",
"babel-plugin-module-resolver": "^5.0.2",
"buffer": "^6.0.3",
"chroma-js": "^2.4.2",
"dayjs": "^1.11.9",
"deprecated-react-native-prop-types": "^4.0.0",
"i18next": "^22.4.9",
"lodash": "^4.17.21",
"mime": "^4.0.1",
"patch-package": "^8.0.0",
"path": "^0.12.7",
"postinstall-postinstall": "^2.1.0",
"react": "18.2.0",
"react-hook-form": "^7.45.2",
"react-i18next": "^12.1.4",
"react-native": "0.73.9",
"react-native-blob-util": "^0.17.1",
"react-native-camera": "^4.2.1",
"react-native-config": "^1.5.1",
"react-native-device-info": "^10.3.0",
"react-native-document-picker": "^8.1.3",
"react-native-drawer-layout": "^4.0.0-alpha.1",
"react-native-element-dropdown": "^2.5.3",
"react-native-fast-image": "^8.6.3",
"react-native-file-viewer": "^2.1.5",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.9.0",
"react-native-image-crop-picker": "^0.41.2",
"react-native-image-picker": "^7.1.0",
"react-native-images-to-pdf": "^0.2.1",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-mask-input": "^1.2.3",
"react-native-mmkv": "^2.12.2",
"react-native-pager-view": "^6.2.2",
"react-native-permissions": "^3.6.1",
"react-native-qrcode-scanner": "^1.5.5",
"react-native-reanimated": "^3.6.0",
"react-native-safe-area-context": "^4.5.0",
"react-native-screens": "^3.34.0",
"react-native-status-bar-height": "^2.6.0",
"react-native-svg": "^13.8.0",
"react-native-tab-view": "^3.5.2",
"react-native-tcp-socket": "^6.0.6",
"react-native-toast-message": "^2.1.5",
"react-native-uuid": "^2.0.2",
"react-native-vector-icons": "^9.2.0",
"styled-components": "^5.1.6",
"yup": "^0.32.11",
"zustand": "^4.5.4"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/plugin-proposal-decorators": "^7.21.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "0.73.21",
"@react-native/eslint-config": "0.73.2",
"@react-native/metro-config": "0.73.5",
"@react-native/typescript-config": "0.73.1",
"@rocketseat/eslint-config": "^2.2.2",
"@tsconfig/react-native": "^3.0.0",
"@types/chroma-js": "^2.4.2",
"@types/node": "^20.5.9",
"@types/react": "^18.2.6",
"@types/react-native-doc-viewer": "^2.7.2",
"@types/react-native-vector-icons": "^6.4.13",
"@types/react-test-renderer": "^18.0.0",
"@types/styled-components": "^5.1.26",
"@types/styled-components-react-native": "^5.1.6",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^8.9.0",
"babel-jest": "^29.6.3",
"babel-plugin-root-import": "^6.6.0",
"customize-cra": "^1.0.0",
"eslint": "^8.47.0",
"eslint-plugin-unused-imports": "^3.0.0",
"jest": "^29.6.3",
"metro-react-native-babel-transformer": "^0.77.0",
"prettier": "2.8.8",
"react-native-svg-transformer": "^1.5.0",
"react-test-renderer": "18.2.0",
"typescript": "5.0.4"
},
"engines": {
"node": ">=18"
},
"resolutions": {
"react-native-vector-icons@^9.2.0": "patch:react-native-vector-icons@npm%3A9.2.0#./.yarn/patches/react-native-vector-icons-npm-9.2.0-7e7f70fd28.patch"
}
}
我必须添加这个,这是我以前不需要的。
.vscode/settings.json
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
}
}