具體參照:https://www.jianshu.com/p/3cfd91231cc7
在項目根目錄下新建.prettierrc(prettier插件的配置文件)文件,在文件中寫入:
{ "semi": true,//在代碼尾部添加分號 "singleQuote": true,//把雙引號換成單引號 "trailingComma": "es5"//在代碼尾部添加逗號 }
在.eslintrc.js(eslint插件的配置文件)文件中的rules屬性中添加:
'no-unused-vars': 'warn',//把該條提示信息轉換成警告信息
我的.eslintrc.js配置:
module.exports = { root: true, env: { node: true, }, extends: ['plugin:vue/essential', '@vue/standard'], parserOptions: { parser: 'babel-eslint', }, rules: { indent: ['off', 2], 'no-tabs': 'off', semi: [0], 'no-mixed-spaces-and-tabs': [0], singleQuote: 0, 'space-before-function-paren': 0, 'no-unused-vars': 'warn', //把該條提示信息轉換成警告信息 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', }, };
Prettier 代碼格式化插件 -- 配置翻譯:
參考:https://www.jianshu.com/p/4be58a69b20f