expected indentation of 0 spaces but found 2 . vue eslint规则和idea冲突

版权声明:工作和生活的点点滴滴都应该记录下来! https://blog.csdn.net/u011350541/article/details/81049761

使用vue创建工程时,在vue页面里,用到script时,idea默认会缩进两个空格,而eslint校验时期望,script下的首行不要缩进。
因此会提示如下报错:

expected indentation of 0 spaces but found 2 . 

解决办法:
1、不校验缩进,在rule里增加如下规则:

'rules': {
    'indent': 'off'
  }

2、修改IDEA或webstorm配置,File => Setting => Editor => Code Style => HTML,找到 add Do not indent children of 的选项,添加 script 标签就完美解决缩进问题。
这里写图片描述

参考链接:https://github.com/vuejs/eslint-plugin-vue/issues/352

猜你喜欢

转载自blog.csdn.net/u011350541/article/details/81049761