原本在開開心心地寫着代碼,然鵝格式化后居然有一處 eslint 提示報錯,說我的縮進有問題,刪除多余的縮進后,再格式化又變成了之前那樣!其它地方都沒問題,為啥就那一小塊會報錯呢?項目使用了 prettier 進行自動格式化,eslint 來進行檢查報錯,可是這倆貌似有世仇,不能好好相處。。。廢話不多說了,直接上配置代碼吧,找了好久才找到的方法,根據代碼自己調整下就好,有些項不一定用得上,希望對看官管用吧。
// .eslintrc.js
module.exports = {
root: true,
env: {
node: true,
},
'extends': [
'plugin:vue/strongly-recommended'
],
rules: {
'indent': ['error', 2],
'vue/script-indent': [
'error',
2,
{ 'baseIndent': 1 }
],
},
'overrides': [
{
'files': ['*.vue'],
'rules': {
'indent': 'off'
}
}
]
};
項目中我注釋掉了 vue/script-indent
如果開啟這個會報其它錯誤,使用時自個看看。