確保eslint在工作
控制臺大量報錯信息
如果不工作的話可以重啟(如圖如博主所說)
確保setting.json
開了保存的時候自動格式化代碼 這個時候保存的時候代碼可以自動被格式化 但是 文檔中和控制臺中仍然有大量的報錯 信息 此時此刻說明 格式化文檔的文件不是按照eslint 格式化的
可以網(wǎng)上找找現(xiàn)成可用的setting.json抄一下 這是我的 配的亂七八糟的(網(wǎng)上東拼西湊的)
{
// #讓函數(shù)(名)和后面的括號之間加個空格
"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 中英文切換時產(chǎn)生的特殊字符
"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 格式化規(guī)則
},
"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": "", // 文件內(nèi)容描述
"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
文章來源:http://www.zghlxwxcb.cn/news/detail-827401.html
注意這里點進去有vscode vetur prettier選項(如果安裝過這種插件的話)
必須確保默認值為eslint 點進去配置默認格式化程序配置為eslint 我就是沒有點進去配置默認格式化文檔 點了很多次eslint 發(fā)現(xiàn)保存還是爆紅 其實是當前一次配置為 eslint 但是每次保存的時候自動格式化又返回到設置的默認值了(如果默認值沒有成功配置為eslint)
點完之后就沒啥了文章來源地址http://www.zghlxwxcb.cn/news/detail-827401.html
到了這里,關于eslint報錯文檔大量紅色報錯符號 不自動修正的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!