1、安装依赖
yarn add -D prettier eslint-config-prettier eslint-plugin-prettier @vue/eslint-config-prettier
2、文件配置
(1)配置.eslintrc
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
'standard',
'plugin:vue/essential',
'plugin:prettier/recommended'
],
plugins: [
'vue'
],
rules: {
'prettier/prettier': [
'error',
{
'singleQuote': true, // 单引号
'trailingComma': 'none', // 尾逗号
'semi': false, // 尾分号
},
],
'generator-star-spacing': 'off',
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
globals: {
$CONFIG: false,
$API: false,
}
}
(2)配置.prettierrc
{
"endOfLine": "auto" ,
"printWidth": 100,
"tabWidth": 2
}