json ESLint配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json ESLint配置相关的知识,希望对你有一定的参考价值。

{
  "parser": "babel-eslint",
  "plugins": ["react", "prettier"],
  "extends": ["airbnb", "plugin:prettier/recommended", "prettier/react"],
  "globals": {
    "React": true,
    "document": true,
    "window": true,
    "jQuery": true,
    "$": true,
    "localStorage": true,
    "fetch": true,
    "SERVER_URL":  true
  },
  "root": true,
  "rules": {
    "indent": ["error", 2, {"SwitchCase": 1}],
    "react/prefer-stateless-function": "warn",
    "react/self-closing-comp": [
      "warn",
      {
        "component": true,
        "html": false
      }
    ],
    "react/sort-comp": [
      1,
      {
        "order": [
          "static-methods",
          "lifecycle",
          "everything-else",
          "rendering"
        ],
        "groups": {
          "rendering": ["/^render.+$/", "render"]
        }
      }
    ],
    "react/require-default-props": 0,
    "jsx-a11y/href-no-hash": "off",
    "jsx-a11y/anchor-is-valid": ["warn", { "aspects": ["invalidHref"] }],
    "react/jsx-boolean-value": ["warn", "never"],
    "react/jsx-curly-spacing": ["warn", "never"],
    "react/jsx-filename-extension": ["warn", { "extensions": [".jsx", ".tsx"] }],
    "react/jsx-first-prop-new-line": ["warn", "multiline"],
    "react/forbid-prop-types": "off",
    "react/destructuring-assignment": "off",
    "react/jsx-indent": ["warn", 2],
    "react/jsx-key": "error",
    "react/jsx-wrap-multilines": ["warn"],
    "no-trailing-spaces": [2, { "skipBlankLines": true }],
    "import/prefer-default-export": 0,
    "import/no-unresolved": 0,
    "import/no-extraneous-dependencies": 0,
    "import/extensions": 0,
    "no-underscore-dangle": 0,
    "no-shadow": 0,
    "no-console": 0,
    "no-param-reassign": 0,
    "import/no-named-as-default": 0
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true
  }
}
{
  "dependencies": {
    "babel-eslint": "^10.0.1"
  },
  "devDependencies": {
    "eslint": "^5.15.1",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^4.1.0",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-jsx-a11y": "^6.2.1",
    "eslint-plugin-prettier": "^3.0.1",
    "eslint-plugin-react": "^7.12.4"
  }
}

以上是关于json ESLint配置的主要内容,如果未能解决你的问题,请参考以下文章

如何配置 package.json 来运行 eslint 脚本

json ESLint配置

json ESLint配置

json React项目的ESLint配置

json eslint配置

json ESLint配置(与Prettier一起使用)