【VUE】 如何關閉ESlint的自動修復功能

  • 問題描述
    • 例如:
      • 原書寫代碼
      • ESLint自動修復
      • 報錯如下
  • 方案一、在文件中添加屏蔽警告的代碼
    • html代碼中
    • JavaScript代碼中
  • 方案二、關閉ESLint的自動修復功能
    • 1、`VSCode` 擴展找到 ESLint 插件
    • 2、在設置中找到`在 settings,json 中編輯`
    • 3、將`"autoFix": true`改為`"autoFix": false`
    • 4、重啟`VSCode`

問題描述

當使用ESLint插件時,報一堆ESLint語法/格式問題,手動按提示修復一保存又自動恢復ESLint報錯的樣子,此時想到的是還不如不自動修復,因此需要手動關閉ESLint自動修復功能。

  216 |                 :value="item.value" />217 |             </el-select>218 |           </el-form-item>error: Binding "key" should be on a new line (vue/max-attributes-per-line) at src\views\setting\clientmanage\index.vue:215:71:213 |             <el-select v-model="role2.machine_position" placeholder="請選擇或輸入" filterable style="width: 60%"214 |               @change.native="selectBlur">
> 215 |               <el-option v-for="item in elSelectModelMachinePosition" :key="item.value" :label="item.value"|                                                                       ^216 |                 :value="item.value" />217 |             </el-select>218 |           </el-form-item>error: Binding "label" should be on a new line (vue/max-attributes-per-line) at src\views\setting\clientmanage\index.vue:215:89:213 |             <el-select v-model="role2.machine_position" placeholder="請選擇或輸入" filterable style="width: 60%"214 |               @change.native="selectBlur">
> 215 |               <el-option v-for="item in elSelectModelMachinePosition" :key="item.value" :label="item.value"|                                                                                         ^216 |                 :value="item.value" />217 |             </el-select>218 |           </el-form-item>warning: Expected indentation of 25 spaces but found 16 spaces (vue/html-indent) at src\views\setting\clientmanage\index.vue:216:1:214 |               @change.native="selectBlur">215 |               <el-option v-for="item in elSelectModelMachinePosition" :key="item.value" :label="item.value"
> 216 |                 :value="item.value" />| ^217 |             </el-select>218 |           </el-form-item>219 |           <el-form-item label="服 務 器" prop="server_id">warning: Expected 1 line break before closing bracket, but no line breaks found (vue/html-closing-bracket-newline) at src\views\setting\clientmanage\index.vue:216:36:214 |               @change.native="selectBlur">215 |               <el-option v-for="item in elSelectModelMachinePosition" :key="item.value" :label="item.value"
> 216 |                 :value="item.value" />|                                    ^217 |             </el-select>218 |           </el-form-item>219 |           <el-form-item label="服 務 器" prop="server_id">error: Directive "model" should be on a new line (vue/max-attributes-per-line) at src\views\setting\clientmanage\index.vue:225:24:223 |           </el-form-item>224 |           <el-form-item label="維護人員" prop="machine_charger_id">
> 225 |             <el-select v-model="role2.machine_charger_id" placeholder="請選擇" filterable style="width: 60%"|                        ^226 |               @blur="selectUser2">227 |               <el-option v-for="item in tbuserList" :key="item.key" :label="item.value" :value="item.key" />228 |             </el-select>error: Attribute "placeholder" should be on a new line (vue/max-attributes-per-line) at src\views\setting\clientmanage\index.vue:225:59:223 |           </el-form-item>224 |           <el-form-item label="維護人員" prop="machine_charger_id">
> 225 |             <el-select v-model="role2.machine_charger_id" placeholder="請選擇" filterable style="width: 60%"|                                                           ^226 |               @blur="selectUser2">227 |               <el-option v-for="item in tbuserList" :key="item.key" :label="item.value" :value="item.key" />228 |             </el-select>error: Attribute "filterable" should be on a new line (vue/max-attributes-per-line) at src\views\setting\clientmanage\index.vue:225:77:223 |           </el-form-item>224 |           <el-form-item label="維護人員" prop="machine_charger_id">
> 225 |             <el-select v-model="role2.machine_charger_id" placeholder="請選擇" filterable style="width: 60%"|                                                                             ^226 |               @blur="selectUser2">227 |               <el-option v-for="item in tbuserList" :key="item.key" :label="item.value" :value="item.key" />228 |             </el-select>error: Attribute "style" should be on a new line (vue/max-attributes-per-line) at src\views\setting\clientmanage\index.vue:225:88:223 |           </el-form-item>224 |           <el-form-item label="維護人員" prop="machine_charger_id">
> 225 |             <el-select v-model="role2.machine_charger_id" placeholder="請選擇" filterable style="width: 60%"|                                                                                        ^226 |               @blur="selectUser2">227 |               <el-option v-for="item in tbuserList" :key="item.key" :label="item.value" :value="item.key" />228 |             </el-select>warning: Expected indentation of 23 spaces but found 14 spaces (vue/html-indent) at src\views\setting\clientmanage\index.vue:226:1:224 |           <el-form-item label="維護人員" prop="machine_charger_id">225 |             <el-select v-model="role2.machine_charger_id" placeholder="請選擇" filterable style="width: 60%"
> 226 |               @blur="selectUser2">| ^227 |               <el-option v-for="item in tbuserList" :key="item.key" :label="item.value" :value="item.key" />228 |             </el-select>229 |           </el-form-item>warning: Expected 1 line break before closing bracket, but no line breaks found (vue/html-closing-bracket-newline) at src\views\setting\clientmanage\index.vue:226:34:224 |           <el-form-item label="維護人員" prop="machine_charger_id">225 |             <el-select v-model="role2.machine_charger_id" placeholder="請選擇" filterable style="width: 60%"
> 226 |               @blur="selectUser2">|                                  ^227 |               <el-option v-for="item in tbuserList" :key="item.key" :label="item.value" :value="item.key" />228 |             </el-select>229 |           </el-form-item>
44 errors and 27 warnings found.
26 errors and 27 warnings potentially fixable with the `--fix` option.You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.

在這里插入圖片描述

例如:

原書寫代碼

            <el-select v-model="role2.machine_charger_id" placeholder="請選擇" filterable style="width: 60%" @blur="selectUser2">

ESLint自動修復

            <el-select v-model="role2.machine_charger_id" placeholder="請選擇" filterable style="width: 60%"@blur="selectUser2">

報錯如下

warning: Expected 1 line break before closing bracket, but no line breaks found (vue/html-closing-bracket-newline) at src\views\setting\clientmanage\index.vue:226:34:224 |           <el-form-item label="維護人員" prop="machine_charger_id">225 |             <el-select v-model="role2.machine_charger_id" placeholder="請選擇" filterable style="width: 60%"
> 226 |               @blur="selectUser2">|                                  ^227 |               <el-option v-for="item in tbuserList" :key="item.key" :label="item.value" :value="item.key" />228 |             </el-select>229 |           </el-form-item>

方案一、在文件中添加屏蔽警告的代碼

html代碼中

<!-- eslint-disable -->:屏蔽此文件后續所有代碼ESLint警告
<!-- eslint-disable-next-line -->:屏蔽下一行的代碼ESLint警告

<template><!-- eslint-disable --><div class="app-container"></div>
</template>

JavaScript代碼中

/* eslint-disable */:屏蔽此文件后續所有代碼ESLint警告
// eslint-disable-next-line:屏蔽下一行的代碼ESLint警告

<script>
/* eslint-disable */
import PanelGroup from './PanelGroup'
</script>

方案二、關閉ESLint的自動修復功能

1、VSCode 擴展找到 ESLint 插件

打開ESLint擴展設置
在這里插入圖片描述

2、在設置中找到在 settings,json 中編輯

在這里插入圖片描述

3、將"autoFix": true改為"autoFix": false

{// vscode默認啟用了根據文件類型自動設置tabsize的選項"editor.detectIndentation": false,// 重新設定tabsize"editor.tabSize": 2,//Ctrl+滾輪實現代碼的縮放"editor.mouseWheelZoom": true,// #每次保存的時候自動格式化"editor.formatOnSave": true,// 添加 vue 支持"eslint.validate": ["javascript","javascriptreact",{"language": "vue","autoFix": false}],//  #讓prettier使用eslint的代碼格式進行校驗// "prettier.eslintIntegration": true,//  #去掉代碼結尾的分號"prettier.semi": false,//  #使用帶引號替代雙引號"prettier.singleQuote": true,//  #讓函數(名)和后面的括號之間加個空格"javascript.format.insertSpaceBeforeFunctionParenthesis": true,// #這個按用戶自身習慣選擇"vetur.format.defaultFormatter.html": "js-beautify-html",// #讓vue中的js按編輯器自帶的ts格式進行格式化"vetur.format.defaultFormatter.js": "vscode-typescript","vetur.format.defaultFormatterOptions": {"js-beautify-html": {"wrap_attributes": "auto",},"prettyhtml": {"printWidth": 100,"singleQuote": false,"wrapAttributes": false,"sortAttributes": false}},"editor.codeActionsOnSave": {"source.fixAll.eslint": true},"[html]": {"editor.defaultFormatter": "mohd-akram.vscode-html-format"},"editor.fontFamily": "Consolas, 'Courier New', monospace,iconfont","[python]": {"editor.formatOnType": true},"security.workspace.trust.untrustedFiles": "open","workbench.iconTheme": "vscode-icons","tabnine.experimentalAutoImports": true,"markdown-preview-enhanced.automaticallyShowPreviewOfMarkdownBeingEdited": true,"[scss]": {"editor.defaultFormatter": "sibiraj-s.vscode-scss-formatter"},"vetur.validation.template": false,"git.enableSmartCommit": true,"git.autofetch": true,"editor.unicodeHighlight.nonBasicASCII": false,"eslint.options": {},"eslint.timeBudget.onFixes": {"warn": 3000,"error": 6000},"eslint.execArgv": null// 格式化stylus, 需安裝Manta's Stylus Supremacy插件//  "stylusSupremacy.insertColons": false, // 是否插入冒號//  "stylusSupremacy.insertSemicolons": false, // 是否插入分好//  "stylusSupremacy.insertBraces": false, // 是否插入大括號//  "stylusSupremacy.insertNewLineAroundImports": false, // import之后是否換行//  "stylusSupremacy.insertNewLineAroundBlocks": false // 兩個選擇器中是否換行
}

4、重啟VSCode

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/14474.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/14474.shtml
英文地址,請注明出處:http://en.pswp.cn/web/14474.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

3.2 運維、運營和經營

第3章 信息技術服務知識 3.2 運維、運營和經營 3.2.1 運維 1、運維是運行維護的簡稱&#xff0c;是一種IT服務形態。2、在《信息技術服務分類與代碼》&#xff08;GB/T29264-20l2&#xff09;中&#xff0c;對運行維護服務&#xff08;operation maintenance service&#x…

4.雙指針+遞歸

一、雙指針編程技巧 方法參數傳遞數組 將數組通過方法參數傳遞&#xff0c;方法操作的數組和main方法中的數組指向同一塊內存區域&#xff0c;意味著方法操作數組&#xff0c;同時會引起main方法中數組的改變以引用的方式作為方法參數進行傳遞的 元素交換 定義臨時變量temp&a…

第十二節 SpringBoot Starter 系列結束語

感謝閱讀&#xff0c;到這里&#xff0c;本系列課程就結束了。 一、為什么選擇 SpringBoot Starter SpringBoot 近年來已經成為 Java 應用的必備框架&#xff1b; 而 SpringBoot starter 模式已經成為各大中間件集成到 SpringBoot 應用的首選方式&#xff0c;通過引入 xxx-st…

C++ | Leetcode C++題解之第101題對稱二叉樹

題目&#xff1a; 題解&#xff1a; class Solution { public:bool check(TreeNode *u, TreeNode *v) {queue <TreeNode*> q;q.push(u); q.push(v);while (!q.empty()) {u q.front(); q.pop();v q.front(); q.pop();if (!u && !v) continue;if ((!u || !v) ||…

爬蟲基礎1

一、爬蟲的基本概念 1.什么是爬蟲&#xff1f; 請求網站并提取數據的自動化程序 2.爬蟲的分類 2.1 通用爬蟲&#xff08;大而全&#xff09; 功能強大&#xff0c;采集面廣&#xff0c;通常用于搜索引擎&#xff1a;百度&#xff0c;360&#xff0c;谷歌 2.2 聚焦爬蟲&#x…

Android App啟動流程和源碼詳解

前言 之前看了些App啟動流程的文章&#xff0c;但是看得很淺顯&#xff0c;隔了沒多久就忘了&#xff0c;自己抓耳撓腮的終于看完了&#xff0c;看得頭疼哦。因為很多是個人理解&#xff0c;大哥們主打一個7分信&#xff0c;2分思考&#xff0c;1分懷疑哈。 主要看的源碼是An…

pytorch-20_1 LSTM在股價數據集上的預測實戰

LSTM在股價數據集上的預測實戰 使用完整的JPX賽題數據&#xff0c;并向大家提供完整的lstm流程。 導包 import numpy as np #數據處理 import pandas as pd #數據處理 import matplotlib as mlp import matplotlib.pyplot as plt #繪圖 from sklearn.preprocessing import M…

人類交互4 感覺輸入和運動輸出

人類感覺系統概述 人類感覺系統是由多個感覺器官和神經系統組成&#xff0c;負責感知外部世界的各種刺激和信息。人類感覺系統包括以下幾個主要部分&#xff1a; 視覺系統&#xff1a;視覺系統由眼睛、視神經和大腦視覺皮層組成&#xff0c;負責感知光線、顏色和形狀&#xff…

datasheet芯片數據手冊—新手入門學習(二)【8-18】

參考芯片手冊已經上傳&#xff0c;可自行下載 因為芯片參考手冊內容比較多&#xff0c;故再一次介紹本文內容主要講解章節。 目錄 8、內容介紹 命令真值表 9、Command Definitions 10、READ Operations &#xff08;1&#xff09;頁面讀取操作 &#xff08;2&#xff…

YTM32的flash應用答疑-詳解寫保護功能

YTM32的flash應用答疑-詳解寫保護功能 文章目錄 YTM32的flash應用答疑-詳解寫保護功能IntroductionPrincipleOperation & DemonstrationDemo #1 驗證基本的寫保護功能Demo #2 編程CUS_NVR設定EFM_ADDR_PROT初值Demo #3 啟用寫保護后試試塊擦除操作 Conclusion Introduction…

報名倒計時兩周|2024 OpenTiny 開源之夏項目直播解讀回顧

5月16日&#xff0c;OpenTiny 開源社區成功舉辦了以《OpenTiny 開源之夏項目解讀直播》為主題的直播活動。此次直播中&#xff0c;華為云的高級前端工程師曾令卡、華為云的高級前端工程師伍其和與10位開源之夏技術專家攜手組成項目導師團&#xff0c;面向廣大開發者一同深入探討…

Java類和對象(五)—— 抽象類、接口、Object類和內部類

抽象類 在繼承體系下&#xff0c;父類有些方法可能是要被重寫的&#xff0c;如果我們事先就知道某些方法需要重寫的話&#xff0c;我們可以不用在父類里面具體實現這個方法&#xff0c;這時候我們會用到抽象方法&#xff0c;這時候我們會用到關鍵字abstract關鍵字來修飾 publ…

BatBot智慧能源管理平臺,更加有效地管理能源

隨著能源消耗的不斷增加&#xff0c;能源管理已成為全球面臨的重要問題。BatBot智慧能源管理作為一種的能源管理技術&#xff0c;促進企業在用能效率及管理有著巨大的提升。 BatBot智慧能源管理是一種基于人工智能技術的能源管理系統&#xff0c;通過智能分析和優化能源使用&…

【JAVA |再談接口、Object、內部類】Object類中子類重寫,Cloneable 接口、比較器、內部類

??謝謝大家捧場&#xff0c;祝屏幕前的小伙伴們每天都有好運相伴左右&#xff0c;一定要天天開心哦&#xff01;?? &#x1f388;&#x1f388;作者主頁&#xff1a; &#x1f388;丠丠64-CSDN博客&#x1f388; ?? 帥哥美女們&#xff0c;我們共同加油&#xff01;一起…

Internet動態路由選擇—RIP與OSPF

剛做完網絡層動態路由選擇的實驗&#xff0c;寫下此篇記錄實驗過程&#xff0c;鞏固學習成果。 參考書目&#xff1a;《計算機網絡》北京理工大學出版社-劉陽老師編 路由選擇可分為兩種策略&#xff1a; - 靜態路由選擇策略 - 動態路由選擇策略 靜態路由即管理員手動配置路由…

Java 商品入庫系統 案例

測試類 package 練習.商品入庫系統;import java.util.ArrayList; import java.util.Scanner; public class Test {public static final int Enrool 1;public static final int Search 2;public static final int Delect 3;public static final int Exit 4;public static…

在docker上部署postgresSQL主從

文章目錄 一、主從規劃二、創建PostgresSQL的Docker鏡像三、主庫部署1、建立pgsql主庫的data地址2、啟動docker鏡像3、docker內操作4、修改配置文件 四、部署從數據庫1、建立psql備庫的data地址2、啟動docker鏡像3、備庫從主庫同步4、檢查是否同步 五、測試主從數據庫 一、主從…

#2495. 滑動窗口 /【模板】單調隊列

題目描述 有一個長為 ( n ) 的序列 ( a )&#xff0c;以及一個大小為 ( k ) 的窗口。現在這個窗口從左邊開始向右滑動&#xff0c;每次滑動一個單位&#xff0c;求出每次滑動后窗口中的最大值和最小值。例如&#xff1a; 數組是 ([1, 3, -1, -3, 5, 3, 6, 7])&#xff0c; ( …

【深度強化學習】關于同一設備上cuda和gpu計算結果不一致問題

文章目錄 問題描述關于seed: 跟原文一致補充:萬能seed 問題結論cpu和gpu差異來源分析浮點數精度的差異補充報錯&#xff1a;Expected all tensors to be on the same device&#xff01;常見運算上的差異累加運算的差異exp運算的差異matmul運算的差異 forward上的差異&#xff…