代码检测工具: Eslint

代码格式化工具: Prettier

prettier能够在保留代码时,让代码合乎ESLint规范

  1. 在VSCode中装置prettier插件
  2. 在我的项目根目录创立.prettierrc.js文件
  3. 配置prettier

    module.exports = {semi: true,singleQuote: true,trailingComma: 'none'}
  4. 在VSCode设置中勾选Format On Save,formatter中Default Formatter抉择Prettier-Code formatter
  5. 在VSCode设置中批改Tab Size为2,将一个tab改为两个空格
  6. 在.eslintrc.js中解决ESLint和Prettier之间的抵触

    module.exports = {  root: true,  env: { node: true  },  extends: [ 'plugin:vue/vue3-essential', '@vue/standard'  ],  parserOptions: { parser: 'babel-eslint'  },  rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'space-before-function-paren': 0  }}