vue-cli3關閉eslint語法檢測


  1. 在項目根目錄創建vue.config.js文件。
module.exports = {
  lintOnSave: false,
  devServer: {
      overlay: {
          warning: false,
          errors: false
      }
  }
}


eslint常見報錯:

 
         
  1. 文件末尾存在空行(eol-last):Too many blank lines at the end of file.Max of 0 allowed

  2. 缺少分號(‘semi’: [‘error’,’always’]) :Missing semicolon

  3. 函數關鍵字后面缺少空格 :Missing space before function parentheses

  4. 字符串沒有使用單引號(’quotes’: [1, ’single’]) :String must use singlequote

  5. 縮進錯誤 : Expected indentation of 2 spaces but found 4

  6. 沒有使用全等(eqeqeq) : Expected ’ === ’ and instaed saw ‘==’

  7. 導入組件卻沒有使用 : ‘seller’ is defined but never used

  8. new了一個對象卻沒有賦值給某個常量(可以在該實例前添加此代碼/eslint-disable

  9. no-new/忽略ESLint的檢查): Do not user’new’ for side effects

  10. 超過一行空白行(no-multiple-empty-lines):More than 1 blank line not allowed

  11. 注釋符 // 后面縮進錯誤(lines-around-comment): Expected space or tab after
    ‘//’ in comment

  12. 模塊導入沒有放在頂部:Import in body of module; reorder to top

  13. 前面缺少空格:Missing space before

  14. 已定義但是沒有使用:‘scope’ is defined but never used

 
         

**************************************************************************************************************************************




規則的含義:

 
         
“off” or 0 - 關閉(禁用)規則 
“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

轉:https://blog.csdn.net/weixin_33831196/article/details/86030209?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.control


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM