vscode配置vue项目(eslint+standard),保存自动格式化

3,611 阅读1分钟

vue+eslint+standard保存自动格式化

vscode插件

ESLint
standard
Prettier-Standard - JavaScript formatter
StandardJS - JavaScript Standard Style
vue

vscode的setting.json

{
  "editor.formatOnSave": true,
  "standard.autoFixOnSave": true,
  "standard.enable": true,
}

vue项目的.eslintrc

自动生成的文件

module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: [
    'plugin:vue/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'
  },
  overrides: [
    {
      files: [
        '**/__tests__/*.{j,t}s?(x)',
        '**/tests/unit/**/*.spec.{j,t}s?(x)'
      ],
      env: {
        jest: true
      }
    }
  ]
}

自用vscode插件和用户setting配置

{
  "editor.formatOnSave": true,
  "standard.autoFixOnSave": true,
  "standard.enable": true,
  "workbench.colorTheme": "One Dark Pro",
  "workbench.iconTheme": "vscode-great-icons",
  "editor.fontSize": 16,
}