简体   繁体   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();

Is there a possibility to exlude a line from linting and formatting in Visual Studio Code?是否有可能从 Visual Studio Code 中的 linting 和格式化中排除一行? Because I need the line, but also need Linting and Formatting for the other part of the Code...因为我需要这条线,但也需要代码的其他部分的 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
        

Yes you have a couple of options available to you.是的,您有几种选择。



Option #1 Disabling Specific Rules:选项 #1 禁用特定规则:


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



Option #2 Disabling Entire Files:选项 #2 禁用整个文件:


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

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




Option #3 Disabling a Single Line:选项 #3 禁用单行:



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

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

  



The official ESLint page that covers the topic, "Disabling ESLint", is located at the link below涵盖主题“禁用 ESLint”的官方 ESLint 页面位于以下链接
https://eslint.org/docs/user-guide/configuring/rules#disabling-rules https://eslint.org/docs/user-guide/configuring/rules#disabling-rules

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM