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

 这是我的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
  "[javascript]": {
    "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
}

评论

发表回复

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

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