简体   繁体   English

当属性在它自己的行上时对象卷曲间距

[英]object-curly-spacing when the property is on it's own line

My indent settings is 4 spaces, but as you can see in my screenshot, this snippet is auto-fixing to 2 spaces, then eslint is throwing the error.我的缩进设置是 4 个空格,但正如您在我的屏幕截图中看到的那样,此代码段自动修复为 2 个空格,然后 eslint 抛出错误。

2个空格eslint错误

here is the code behind the error这是错误背后的代码

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
})

I'm assuming object-curly-spacing is the culprit but I really don't know eslint very well.我假设object-curly-spacing是罪魁祸首,但我真的不太了解 eslint。

my eslint config我的 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"
  }
}

----edit------ - - 编辑 - - -

turns out the same error happens with a much simpler example事实证明,同样的错误发生在一个更简单的例子中

var thing = {
 test: 'a'
}

adding this to my config removed the error, still not sure where the auto-fix is coming from将此添加到我的配置中删除了错误,但仍然不确定自动修复来自何处

"indent": [
  "error",
  4,
  {
    "SwitchCase": 1,
    "ObjectExpression": "off"
  }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM