简体   繁体   中英

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.

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.

my eslint config

"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"
  }
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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