0

我的缩进设置是 4 个空格,但正如您在我的屏幕截图中看到的那样,此代码段自动修复为 2 个空格,然后 eslint 抛出错误。

2个空格eslint错误

这是错误背后的代码

import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import mutations from './mutations'
import actions from './actions'

Vue.use(Vuex)

export default new Vuex.Store({
  state,
  mutations,
  actions
})

我假设object-curly-spacing是罪魁祸首,但我真的不太了解 eslint。

我的 eslint 配置

"eslintConfig": {
  "root": true,
  "env": {
    "node": true
  },
  "extends": [
    "plugin:vue/essential",
    "eslint:recommended"
  ],
  "parserOptions": {
    "parser": "babel-eslint",
    "ecmaFeatures": {
      "legacyDecorators": true
    }
  },
  "rules": {
    "no-undef": "warn",
    "no-unused-vars": "warn",
    "comma-spacing": [
      "error",
      {
        "after": true
      }
    ],
    "id-length": [
      "warn",
      {
        "min": 2,
        "exceptions": [
          "i",
          "x",
          "y"
        ]
      }
    ],
    "indent": [
      "error",
      4,
      {
        "SwitchCase": 1
      }
    ],
    "semi": [
      "error",
      "never"
    ],
    "keyword-spacing": [
      "error",
      {
        "after": true,
        "before": true
      }
    ],
    "no-multiple-empty-lines": [
      "error",
      {
        "max": 1
      }
    ],
    "no-prototype-builtins": "off",
    "no-trailing-spaces": [
      "error"
    ],
    "object-curly-spacing": [
      "error",
      "always"
    ],
    "space-in-parens": [
      "error",
      "never"
    ],
    "quotes": [
      "error",
      "single"
    ],
    "space-before-function-paren": [
      "error",
      "never"
    ],
    "vue/attribute-hyphenation": "off",
    "vue/attributes-order": "off",
    "vue/html-indent": [
      "error",
      4
    ],
    "vue/max-attributes-per-line": "off",
    "vue/multiline-html-element-content-newline": [
      "error",
      {
        "allowEmptyLines": true
      }
    ],
    "vue/name-property-casing": [
      "error",
      "kebab-case"
    ],
    "vue/no-unused-vars": "error",
    "vue/no-v-html": "off",
    "vue/singleline-html-element-content-newline": "off",
    "vue/valid-v-slot": "error"
  }
}

- - 编辑 - - -

事实证明,同样的错误发生在一个更简单的例子中

var thing = {
 test: 'a'
}
4

1 回答 1

0

将此添加到我的配置中删除了错误,但仍然不确定自动修复来自何处

"indent": [
  "error",
  4,
  {
    "SwitchCase": 1,
    "ObjectExpression": "off"
  }
]
于 2020-04-30T03:52:50.203 回答