簡體   English   中英

忽略掉毛和格式化中的線條 - VSC EsLint + Prettier

[英]Ignore lines from linting and formating - VSC EsLint + Prettier

some.JS.Code;

//ignore this line from linting etc.
##Software will do some stuff here, but for JS it's an Error##

hereGoesJs();

是否有可能從 Visual Studio Code 中的 linting 和格式化中排除一行? 因為我需要這條線,但也需要代碼的其他部分的 Linting 和 Formatting ......

// I Tried

// eslint-disable-next-line no-use-before-define

// eslint-disable-line no-use-before-define

/*eslint-disable */

//suppress all warnings between comments
alert('foo');

/*eslint-enable */

// @ts-ignore
        

是的,您有幾種選擇。



選項 #1 禁用特定規則:


  /* eslint-disable no-var */
  
  var x = 'apple sauce'; 
  
  /* eslint-enable no-var */



選項 #2 禁用整個文件:


// Anything up here will still be affected by the linter.

/* eslint-disable */  // Disables everything from this point down




選項 #3 禁用單行:



    // eslint-disable-next-line 
    var x = 'apple sauce';
    
    //  or you can do this:

    var y = 'apple sauce'; // eslint-disable-line

  



涵蓋主題“禁用 ESLint”的官方 ESLint 頁面位於以下鏈接
https://eslint.org/docs/user-guide/configuring/rules#disabling-rules

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM