将eslint-plugin-json与create-react-app结合使用(弹出)

时间:2019-08-20 17:39:39

标签: create-react-app eslint webpack-dev-server

我的应用程序是使用create-react-app创建的,也被弹出以进行进一步的自定义。

我已经安装了eslint-plugin-json并将其包含在我的.eslintrc中:

{
  "parser": "babel-eslint",
  "extends": [
    "standard",
    "standard-react"
  ],
  "plugins": [
    "babel",
    "json"
  ],
  "env": {
    "browser": true
  },
  "globals": {
    "describe": false,
    "it": false,
    "expect": false
  },
  "rules": {
    "curly": "error",
    "space-before-function-paren": "off",
    "jsx-quotes": ["error", "prefer-single"],
    "semi": ["warn", "always"],
    "no-unused-vars": "warn",
    "spaced-comment": "off",
    "no-debugger": "warn",
    "no-multiple-empty-lines": "warn",
    "no-useless-escape": "off",
    "max-len": ["error", { "code": 120, "tabWidth": 2, "ignoreStrings": true, "ignoreTemplateLiterals": true, "ignoreComments": true }],
    "padded-blocks": "off",
    "react/no-did-update-set-state": "off",
    "key-spacing": "warn"
  }
}

我知道您应该提供其他“扩展名”参数,以便在命令行上运行eslint时(例如eslint . --ext .json --ext .js)可以正常工作

但是,我无法弄清楚如何将这些额外的扩展传递给WebpackDevServer运行的eslint。我特别希望“键间距”规则对JSON文件生效。 WebpackDevServer的eslint可以正确拾取JS文件中的“键间距”冲突,因此我知道它可以正常读取我的eslintrc,但是有什么方法可以为此用例指定其他eslint文件扩展名吗?

0 个答案:

没有答案
相关问题