关于前端:解决prettier和eslint冲突详细配置

6次阅读

共计 1962 个字符,预计需要花费 5 分钟才能阅读完成。

这是我的 vscode 设置,次要是设置 vetur 里对 vue 文件各局部的校验工具。解决问题的话就给我点个赞吧!须要装置 prettier-eslint 这个插件

setting.json 文件

{
  // 编辑器格调相干
  "workbench.colorTheme": "One Dark Pro", // 页面格调
  "eslint.alwaysShowStatus": true, // 展现 eslit 栏
  "files.autoSave": "off", // 文件主动保留
  "editor.fontSize": 14,
  "editor.tabSize": 2, // 设置 tab 位 2 个空格.
  "editor.tabCompletion": "on", // 用来在呈现推荐值时,按下 Tab 键是否主动填入最佳推荐值
  "editor.lineNumbers": "on", // 设置代码行号
  "editor.formatOnSave": true, // 保留时格式化
  "explorer.confirmDelete": false, // 删除文件不跳揭示
  "explorer.confirmDragAndDrop": false, // 挪动文件不跳揭示
  "workbench.iconTheme": "vscode-icons", // 文件图标主题
  "vsicons.dontShowNewVersionMessage": true, // 疏忽新版本更新提醒
  "editor.codeActionsOnSave": {
    "source.fixAll": true, // 保留主动修复谬误
    "source.organizeImports": false // 禁止主动调整 import 语句相干程序
  },
  "editor.defaultFormatter": "esbenp.prettier-vscode", // 主动格式化程序为 prettier
  "javascript.updateImportsOnFileMove.enabled": "always", //js 重命名文件自动更新门路
  //js 主动格式化程序为 prettier-eslint
  "": {"editor.defaultFormatter":"rvest.vs-code-prettier-eslint"},"[vue]": {"editor.defaultFormatter":"octref.vetur"},
  // #让 vue 中的 js 按 "prettier" 格局进行格式化
  "vetur.format.defaultFormatter.html": "prettier",
  "vetur.format.defaultFormatter.js": "prettier-eslint",
  "vetur.format.defaultFormatterOptions": {
    // #vue 组件中 html 代码格式化款式
    // "js-beautify-html": {
    //   "wrap_attributes": "force-aligned", // 也能够设置为“auto”,成果会不一样
    //   "wrap_line_length": 200,
    //   "end_with_newline": false,
    //   "semi": false,
    //   "singleQuote": true
    // },
    // "prettier-eslint": {
    //   "semi": false,
    //   "singleQuote": true,
    //   "editor.tabSize": 2
    // },
    // "prettyhtml": {
    //   "printWidth": 160,
    //   "singleQuote": false,
    //   "wrapAttributes": false,
    //   "sortAttributes": false
    // }
  },

  "editor.suggestSelection": "first", //tab 优先选第一个倡议
  "editor.formatOnPaste": true, // 主动格式化粘贴内容
  "editor.formatOnType": true, // 键入一行后主动格式化

  // markdownlint 设置 疏忽 img 标签报错 又拍云图床还是麻烦!"markdownlint.config": {
    "MD033": {"allowed_elements": ["img"]
    }
  },
  "editor.fontFamily": "Jetbrains Mono, Source Code Pro",
  "vscode-edge-devtools.mirrorEdits": true,
  "editor.matchBrackets": false,
  "files.saveConflictResolution": "overwriteFileOnDisk",
  "vscode-edge-devtools.webhint": false
}
正文完
 0