我试图使ESLint和Prettier工作几天,但是无论我做什么,都不会改变。
我什至不知道我在全球范围内安装了什么,但这是我项目的本地package.json
{
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^8.0.4",
"babel-preset-react-native": "4.0.0",
"global": "^4.3.2",
"react": "16.5.0",
"react-native": "0.57.2",
"react-native-linear-gradient": "^2.4.0",
"react-native-navigation": "^1.1.488",
"react-native-snap-carousel": "^3.7.5",
"react-native-vector-icons": "^6.0.2",
"react-navigation": "^2.17.0"
},
"devDependencies": {
"babel-eslint": "^10.0.1",
"babel-jest": "23.6.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-prettier": "^3.0.0",
"jest": "23.6.0",
"prettier": "^1.14.3",
"react-test-renderer": "16.5.0"
},
"jest": {
"preset": "react-native"
}
}
我的.eslintrc
包含
{
"extends": ["react-app", "plugin:prettier/recommended"]
}
ESLint部分的输出说
[Error - 1:15:10 PM] Cannot find module 'eslint-plugin-prettier' Referenced from: /Users/me/project/.eslintrc
我已经调整了VSCode设置,这样很好,但是这种简单的方法不起作用。
答案 0 :(得分:6)
我相信您缺少主要的eslint软件包。 您可以尝试将其添加到package.json
吗? "eslint": "^5.8.0",