我們用Vue-Cli腳手架新建項目時會選擇使用ESLint + Prettier來統一我們的前端代碼風格,但這對新手使用有很大困難,嚴格的格式要求容易出現很多警告和錯誤,這時最好關閉ESLint + Prettier。
1.在src下新建文件.eslintrc.js,並如下配置:
module.exports = { root: true, env: { node: true }, extends: [ 'plugin:vue/essential', //關閉ESlint關鍵代碼 // '@vue/standard' ], parserOptions: { parser: 'babel-eslint' }, rules: { //嚴格的檢查縮進問題,不是報錯,我們可以關閉這個檢查規則,然后在終端輸入npm run dev "indent": ["off", 2], //使用eslint時,嚴格模式下,報錯Missing space before function parentheses的問題,意思是在方法名和刮號之間需要有一格空格。 'space-before-function-paren': 0, 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', //關閉prettier "prettier/prettier": "off" } } ———————————————— 版權聲明:本文為CSDN博主「onpine」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。 原文鏈接:https://blog.csdn.net/weixin_43736435/article/details/105878615
2.配置完重啟生效