![](/img/trans.png)
[英]How can es-lint be configured to warn/error if useState is used
[英]How to run es-lint rules on Vue component's external script files
我在 Vue 組件上添加了 es-lint 檢查,但該組件的腳本不在同一個文件中,我將它作為項目中所有組件的單獨文件保存。 例如,我在.eslintrc.js
中添加了vue/order-in-components
規則,如果組件腳本的鈎子順序錯誤,則會引發錯誤。
export default {
name: 'Address',
props: {
isNewRegistration: {
type: Boolean,
required: true
}
},
data() {
return {
test: ''
}
}
}
export default {
name: 'Address',
// data should come after props
data() {
return {
test: ''
}
}
props: {
isNewRegistration: {
type: Boolean,
required: true
}
}
}
在組件文檔中訂購: https://eslint.vuejs.org/rules/order-in-components.html
因為我已經通過外部文件添加了組件的腳本。 當我們運行eslint --fix
時,這些檢查不會發生
對此的任何解決方案將不勝感激,在此先感謝
我對 vue 不熟悉,但是您是否嘗試過在運行 eslint 時使用--ext
,例如,
eslint --ext .vue --ext .js src/
如果您使用的是 webpack 模板,請添加
preLoaders: { js: 'eslint-loader' }
到你的 vue-loader.conf.js 文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.