【发布时间】:2017-02-04 11:45:47
【问题描述】:
我的 .eslintrc 中有以下内容:
'key-spacing': [ 'error', {
'singleLine': {
'beforeColon' : false,
'afterColon' : true
},
'multiLine': {
'beforeColon' : false,
'afterColon' : true,
'align' : 'colon'
}
}]
目标是确保在对象分配中满足以下条件:
- 在单行赋值中,每个冒号前没有空格, 但后面还有一个。
- 在多行赋值中,冒号水平排列,并且 每个冒号前后都有一个空格。
奇怪的是下面三个代码sn-ps:
1 [来自我的 app.vue 文件]。
export default {
name : 'app',
components : {
todos
}
}
2 [来自我的 main.js 文件]。
new Vue({
el : '#app',
render : h => h( App )
})
3 [来自我的 Hello.spec.js 文件]。
const vm = new Vue({
el : document.createElement( 'div' ),
render : h => h( Hello )
})
在 key-spacing eslint 规则中每个都抛出错误:
/Users/autoboxer/development/learning-vue/src/app.vue
12:3 error Missing space after key 'name' key-spacing
/Users/autoboxer/development/learning-vue/src/main.js
6:2 error Missing space after key 'el' key-spacing
/Users/autoboxer/development/learning-vue/test/unit/specs/Hello.spec.js
7:4 error Missing space after key 'el' key-spacing
我无法从我的设置中弄清楚为什么它们会导致列出的错误,因为每个指定的单词后面都有必要的空格,但我们将不胜感激。
【问题讨论】:
-
使用标签,也许?
-
我正在使用标签。奇怪的是,它只抱怨每种情况下的顶线。所有三个文件都应该抛出两个错误,但第一个对象成员是它抱怨的唯一一个。
-
这就是问题所在,我需要使用空格而不是制表符来对齐它们。