1

可以对我在 VScode 中打开的所有项目使用 .eslintrc 并全局安装 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

这里是我的 .eslintrc/user/home/.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
        }
    ]
  }
}
4

0 回答 0