![](/img/trans.png)
[英]There should be no space after '{' (babel/object-curly-spacing)
[英]object-curly-spacing when the property is on it's own line
我的縮進設置是 4 個空格,但正如您在我的屏幕截圖中看到的那樣,此代碼段自動修復為 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'
}
將此添加到我的配置中刪除了錯誤,但仍然不確定自動修復來自何處
"indent": [
"error",
4,
{
"SwitchCase": 1,
"ObjectExpression": "off"
}
]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.