1
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
        
4

1 回答 1

1

是的,您有几种选择。



选项 #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
于 2021-06-21T07:00:30.513 回答