vscode报错,不符和eslint规范,保存时单引号变双引号,代码
尾部分号和逗号⾃动去除
在项⽬根⽬录下新建.prettierrc(prettier插件的配置⽂件)⽂件,在⽂件中写⼊:
{
"semi": true,//在代码尾部添加分号
"singleQuote": true,//把双引号换成单引号
"trailingComma": "es5"//在代码尾部添加逗号
}
在.eslintrc.js(eslint插件的配置⽂件)⽂件中的rules属性中添加:
'no-unused-vars': 'warn',//把该条提⽰信息转换成警告信息
我的.eslintrc.js配置:
root: true,
env: {
vscode代码规范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': v.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': v.NODE_ENV === 'production' ? 'warn' : 'off',
},
};
Prettier 代码格式化插件 -- 配置翻译: