是否可以将.eslintrc用于我在VScode中打开且全局安装eslint的所有项目?
我想在家中使用.eslintrc, 当我打开一个项目时,在VScode控制台中出现eslint错误。
Failed to load plugin prettier: Cannot find module 'eslint-plugin-prettier'
Happened while validating /home/**/**/**/constants.js
This can happen for a couple of reasons:
1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
2. If ESLint is installed globally, then make sure 'eslint-plugin-prettier' is installed globally as well.
3. If ESLint is installed locally, then 'eslint-plugin-prettier' isn't installed correctly.
但是在运行此命令之前:
npm install -g eslint@^3.19.0 eslint-config-airbnb@^15.0.1 eslint-config-prettier@^2.9.0 eslint-loader@^1.8.0 eslint-plugin-import@^2.7.0 eslint-plugin-jsx-a11y@^5.0.1 eslint-plugin-prettier@^2.6.1 eslint-plugin-react@^7.1.0
这是我在/user/home/.eslintrc
中的.eslintrc
{
"parser": "babel-eslint",
"plugins": ["react", "jsx-a11y", "import", "prettier"],
"extends": ["react-app", "airbnb", "prettier", "prettier/react"],
"env": {
"browser": true
},
"rules": {
"import/prefer-default-export": 0,
"jsx-a11y/no-static-element-interactions": 0,
"react/jsx-filename-extension": 0,
"import/no-extraneous-dependencies": 0,
"import/extensions": 0,
"import/no-unresolved": 0,
"no-console": 0,
"react/jsx-closing-bracket-location": 2,
"no-confusing-arrow": 0,
"import/no-webpack-loader-syntax": 0,
"no-return-assign": 0,
"jsx-a11y/label-has-for": 0,
"react/no-array-index-key": 0,
"no-mixed-operators": 0,
"react/no-did-mount-set-state": 0,
"react/require-default-props": 0,
"prettier/prettier": [
"error",
{
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 120
}
]
}
}