vscode报错,不符和eslint规范,保存时单引号变双引号,代码尾部分号和逗号自动去除

具体参照: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

原文地址:https://www.cnblogs.com/hahahakc/p/13020196.html