- 在項目根目錄創建vue.config.js文件。
module.exports = { lintOnSave: false, devServer: { overlay: { warning: false, errors: false } } }
eslint常見報錯:
-
文件末尾存在空行(eol-last):Too many blank lines at the end of file.Max of 0 allowed
-
缺少分號(‘semi’: [‘error’,’always’]) :Missing semicolon
-
函數關鍵字后面缺少空格 :Missing space before function parentheses
-
字符串沒有使用單引號(’quotes’: [1, ’single’]) :String must use singlequote
-
縮進錯誤 : Expected indentation of 2 spaces but found 4
-
沒有使用全等(eqeqeq) : Expected ’ === ’ and instaed saw ‘==’
-
導入組件卻沒有使用 : ‘seller’ is defined but never used
-
new了一個對象卻沒有賦值給某個常量(可以在該實例前添加此代碼/eslint-disable
-
no-new/忽略ESLint的檢查): Do not user’new’ for side effects
-
超過一行空白行(no-multiple-empty-lines):More than 1 blank line not allowed
-
注釋符 // 后面縮進錯誤(lines-around-comment): Expected space or tab after
‘//’ in comment -
模塊導入沒有放在頂部:Import in body of module; reorder to top
-
前面缺少空格:Missing space before
-
已定義但是沒有使用:‘scope’ is defined but never used
**************************************************************************************************************************************
規則的含義:
“warn” or 1 - 將規則視為一個警告(並不會導致檢查不通過)
“error” or 2 - 將規則視為一個錯誤 (退出碼為1,檢查不通過)
Possible Errors 可能的錯誤或邏輯錯誤
no-cond-assign 禁止條件表達式中出現模棱兩可的賦值操作符
no-console 禁用console
no-constant-condition 禁止在條件中使用常量表達式
no-debugger 禁用 debugger
no-dupe-args 禁止 function 定義中出現重名參數
no-dupe-keys 禁止對象字面量中出現重復的 key
no-duplicate-case 禁止出現重復的 case 標簽
no-empty 禁止出現空語句塊
no-ex-assign 禁止對 catch 子句的參數重新賦值
no-extra-boolean-cast 禁止不必要的布爾轉換
no-extra-parens 禁止不必要的括號
no-extra-semi 禁止不必要的分號
no-func-assign 禁止對 function 聲明重新賦值
no-inner-declarations 禁止在嵌套的塊中出現變量聲明或 function 聲明
no-irregular-whitespace 禁止在字符串和注釋之外不規則的空白
no-obj-calls 禁止把全局對象作為函數調用
no-sparse-arrays 禁用稀疏數組
no-prototype-builtins 禁止直接使用Object.prototypes 的內置屬性
no-unexpected-multiline 禁止出現令人困惑的多行表達式
no-unreachable 禁止在return、throw、continue 和 break語句之后出現不可達代碼
use-isnan 要求使用 isNaN() 檢查 NaN
valid-typeof 強制 typeof 表達式與有效的字符串進行比較
轉:https://blog.csdn.net/wron_path/article/details/104655844