Object-Curly-Spacing, когда свойство находится на своей собственной линии - PullRequest
0 голосов
/ 30 апреля 2020

Мои настройки отступа - 4 пробела, но, как вы можете видеть на моем скриншоте, этот фрагмент автоматически исправляет 2 пробела, а затем eslint выдает ошибку.

2 spaces eslint 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
})

Я предполагаю, что 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"
  }
}

---- edit ------

оказывается, что та же самая ошибка происходит с гораздо более простым примером

var thing = {
 test: 'a'
}

1 Ответ

0 голосов
/ 30 апреля 2020

добавление этого в мою конфигурацию устранило ошибку, все еще не уверенный, откуда происходит авто-исправление

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