关于eslint:编程规范ESLint-Prettier

代码检测工具: 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
      }
    }

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理