-
-
Notifications
You must be signed in to change notification settings - Fork 682
vue/script-indent 配置问题 #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
在我的团队中,一部分人使用webstorm,一部分人使用vscode, |
@ldwqh0 你好,我也遇到了这个问题,请问您解决了这个问题没有?怎么解决的? |
没有解决,我现在临时的做发是让大家不用WebStorm的格式化功能。改用webstorm的eslint自动修复功能来格式化代码,但效果不是很好,但最起码不会报错。 |
+1 |
加了这个玩意儿简直是存心让我们前端不好过啊~, script 标签下面不能缩进, 一缩进就跪, 总不能改webstorm的配置吧。都不知道怎么处理了 。 |
我们再这里讨论的的热火朝天,可惜这个issue closed. 还有,我的E文不太好,你们谁翻译一下,让作者看看。 |
我把eslint的缩进给禁了 |
要用这个配置,在当前版本只能禁用,冲突了。 |
看来只能这么干了, 为什么script下面不能缩进呢,瞎折腾 。 |
不是不能缩进,webstorm的缩进规则和eslint的冲突了, webstorm格式化
eslint-vue
这两个的区别 |
我习惯写完代码格式化啊 ,我一格式化,save就警告了。找了一早上的文档试试能不能不这样,没找到。 |
@busyhe |
我怎么觉得是他们的bug呢 。 |
用蹩脚英语问了下,大概这么处理。 #362 |
这就是我最头上的处理方式,但会有问题, new Vue({
el: '#app',
router,
components: {App},
template: '<App/>'
}) router那一行会报错 |
/* eslint-disable no-new */
new Vue({ el: '#app', router, components: { App }, template: '<App/>' }) 我这么写完美的避开了错误。。。 但是。。好像还是坑 诶 这么写没问题, /* eslint-disable no-new */
new Vue({
router: router
}) 这么写就会有问题 /* eslint-disable no-new */
new Vue({
router
}) |
所以这个问题解决了吗?
|
这是我的配置,在最近的项目中,好像没有什么问题了。 parserOptions: {
parser: 'babel-eslint'
},
extends: [
'standard',
'plugin:vue/strongly-recommended'
],
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'vue/max-attributes-per-line': ['error', {
'singleline': 3,
'multiline': {
'max': 1,
'allowFirstLine': true
}
}],
'vue/script-indent': ['error', 2, {'baseIndent': 1}],
'indent': 'off'
} 我的代码长这样 import Vue from 'vue'
import App from './App'
Vue.config.productionTip = false
console.log('Created By [email protected]')
/* eslint-disable no-new */
new Vue({
el: '#app',
components: {
App
},
template: '<App/>'
}) |
@wengpengfeijava 改一下webstorm规则就好了, |
@ldwqh0 因为你设置了: 'indent': 'off' 所以没检测 |
"vetur.format.styleInitialIndent": false, |
Because of you use ESLint to lint your code,The problem is occured. |
@BarryZhan 感谢,完美的解决方案 |
如何在.eslintrc中设置 |
https://www.jianshu.com/p/deea5446e51e 这篇文章解决了这个问题 |
|
|
https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/script-indent.md |
我尝试 增加如下配置到 rules中
在main.js中使用如下代码
在components行会报如下错误
[eslint] Expected indentation of 4 spaces but found 2 spaces. (vue/script-indent)
如果使用如下缩进就不会出错
但这跟standard的配置时相悖的
The text was updated successfully, but these errors were encountered: