在package.json中配置命令 eslint檢測代碼風格並自動修復

webpack中配置命令 

"lint": "eslint --ext .js --ext .jsx --ext .vue client/",
"lint-fix": "eslint --fix --ext .js --ext .jsx --ext .vue client/",

安裝babel-eslint 和 eslint-loader,在webpack.config.base.js中配置rules

{
        test: /\.(vue|js|jsx)$/,
        loader: 'eslint-loader',
        exclude: /node_modules/,
        enforce: 'pre' // 預處理
},

在build前自動刪除上次打包文件

"clean": "rimraf dist",

.editconfig 配置

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章