eslint报错文档大量红色报错符号 不自动修正

确保eslint在工作

控制台大量报错信息

确保setting.json

开了保存的时候自动格式化代码 这个时候保存的时候代码可以自动被格式化 但是 文档中和控制台中仍然有大量的报错 信息 此时此刻说明 格式化文档的文件不是按照eslint 格式化的

可以网上找找现成可用的setting.json抄一下 这是我的 配的乱七八糟的(网上东拼西凑的)

javascript 复制代码
{
  // #让函数(名)和后面的括号之间加个空格
  "javascript.format.insertSpaceBeforeFunctionParenthesis": false,
  "explorer.confirmDragAndDrop": false,
  "javascript.preferences.quoteStyle": "single",
  "typescript.preferences.quoteStyle": "single",
  // tab 大小为2个空格
  "editor.tabSize": 2,
  // 100 列后换行
  "editor.wordWrapColumn": 100,
  // 保存时格式化
  // "editor.formatOnSave": true,
  // 开启 vscode 文件路径导航
  "breadcrumbs.enabled": true,
  // prettier 设置语句末尾不加分号
  "prettier.semi": false,
  // prettier 设置强制单引号
  "prettier.singleQuote": true,
  // 注释后面加空格
  "prettier.eslintIntegration": true,
  // 选择 vue 文件中 template 的格式化工具
  "vetur.format.defaultFormatter.html": "js-beautify-html",
  "vetur.format.defaultFormatter.js": "vscode-typescript",
  // 显示 markdown 中英文切换时产生的特殊字符
  "editor.renderControlCharacters": true,
  // vetur 的自定义设置
  "vetur.format.defaultFormatterOptions": {
    "prettier": {
      "singleQuote": true, // true 为使用单引号
      "semi": true,// 去掉分号
      "singleAttributePerLine": true,
    },
    "js-beautify-html": {
      "wrap_attributes": "force",
      "wrap_attributes_mode": "auto",
      "wrap-line-length": 100,
      "wrapped_attributes_per_line": "multiple",
      "wrapped_attributes_indent": "auto",
      "wrapped_attributes_end": "auto"
    }
  },
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[vue]": {
    "editor.defaultFormatter": "dbaeumer.vscode-eslint" // 使用 vetur 格式化规则
  },
  "workbench.iconTheme": "vscode-icons-mac",
  "editor.bracketPairColorization.enabled": true,
  "editor.guides.bracketPairs": "active",
  "[javascript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "eslint.enable": true,
  "eslint.autoFixOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "true"
  },
"files.autoSave": "afterDelay",
"eslint.format.enable": true,
"editor.formatOnType": true,
  // eslint 检测文件类型
  "eslint.validate": [
    "html",
    "vue",
    "javascript",
    { "language": "html", "autoFix": true }
  ],
  "bracketPairColorizer.depreciation-notice": false,
  "diffEditor.ignoreTrimWhitespace": false,
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "terminal.integrated.profiles.windows": {
    "PowerShell": {
      "source": "PowerShell",
      "icon": "terminal-powershell"
    },
    "Command Prompt": {
      "path": [
        "${env:windir}\\Sysnative\\cmd.exe",
        "${env:windir}\\System32\\cmd.exe"
      ],
      "args": [],
      "icon": "terminal-cmd"
    },
    "Git Bash": {
      "source": "Git Bash"
    },
    "Windows PowerShell": {
      "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
    }
  },
  "terminal.integrated.defaultProfile.windows": "Windows PowerShell",
  "workbench.colorCustomizations": {},
  "workbench.colorTheme": "One Dark Pro Darker",
  "Codegeex.Privacy": false,
  "fileheader.configObj": {
    "Author": "Guomy",
    "createFileTime": true, // 设置为true则为文件新建时候作为date,否则注释生成时间为date

    "autoAdd": true, // 自动生成注释,老是忘记的同学可以设置

    "annotationStr": {
      "head": "/*",

      "middle": " * @",

      "end": " */",

      "use": true // 设置自定义注释可用
    },

    "headInsertLine": {
      "php": 2
    }
  },
  "fileheader.cursorMode": {
    "Description": "", // 文件内容描述

    "Author": "Guomy", // 编辑人

    "Date": "Do not edit", //时间

    "LastEditTime": "Do not edit",

    "LastEditors": " "
  },
  "editor.formatOnSave": true,
  "prettier.documentSelectors": ["\"singleAttributePerLine\": true,"],
  "prettier.requireConfig": true,
  "json.schemas": [
  ],
  "html.format.contentUnformatted": "",
  "eslint.format.enable": true,
  "eslint.notebooks.rules.customizations": [

  ],
}

配置格式化文档为eslint

注意这里点进去有vscode vetur prettier选项(如果安装过这种插件的话)

必须确保默认值为eslint 点进去配置默认格式化程序配置为eslint 我就是没有点进去配置默认格式化文档 点了很多次eslint 发现保存还是爆红 其实是当前一次配置为 eslint 但是每次保存的时候自动格式化又返回到设置的默认值了(如果默认值没有成功配置为eslint)

点完之后就没啥了

相关推荐
CAE虚拟与现实15 小时前
VSCode中的下载VSIX是指什么?
ide·vscode·编辑器
路边闲人217 小时前
vscode启用GEMINI CODE ASSIST插件
ide·vscode·gemini
CAE虚拟与现实17 小时前
VSCode官方汉化包
ide·vscode·编辑器·vscode汉化
CAE虚拟与现实18 小时前
VSCode创建Python项目和运行py文件
ide·vscode·编辑器
Stardep20 小时前
ssh远程连接服务器到vscode上“连接失败”
服务器·vscode·ssh
superior tigre1 天前
1.linux环境配置+ssh远程连接vscode调试(问题:无法联网,无法共享粘贴板,不满足运行vscode服务器的先决条件)
linux·服务器·vscode
老黄编程2 天前
VSCode 的百度 AI编程插件
ide·vscode·ai编程
老黄编程2 天前
VSCode AI编程插件
ide·vscode·ai编程
Naiva2 天前
ESP32-C3 入门09:基于 ESP-IDF + LVGL + ST7789 的 1.54寸 WiFi 时钟(SquareLine Studio 移植)
ide·笔记·vscode
return(b,a%b);2 天前
VSCode 远程开发连接(glibc<2.28)
ide·vscode·编辑器