eslint prettier配置速记

111 阅读1分钟

ctrl+shift+p 打开

image.png

配置

{
  // 将prettier设置为默认格式化程序(在编辑器中有可能被其他Formatter占用,所以将prettier设置为默认Formatter)
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  // 保存时自动格式化 (根据根目录下‘.prettierrc文件配置项’)
  "editor.formatOnSave": true,
  // Enable per-language
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": true
  },
  // 为ESLint启用“保存时自动修复”,并且仍然具有格式和快速修复功能
  "editor.codeActionsOnSave": {
    "source.fixAll": "explicit",
    "source.fixAll.eslint": "explicit"
  },
  "editor.tabSize": 2,
  "[vue]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "notebook.formatOnSave.enabled": true
}

配置 .eslintrc.js

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

配置 .prettierrc

{
  "tabWidth": 2,
  "singleQuote": true,
  "trailingComma": "none"
}

eslintrc.js文件详解(参考)

blog.csdn.net/qq_39241736…