Allow debugger; statements in certain files, using ESLint

可紊 提交于 2020-12-29 03:56:14

问题


Say I want to use this rule:

https://eslint.org/docs/rules/no-debugger

however, I have about 15 files where I want to keep debugger; statements.

Is there something I can add at the top of the .ts/.js files, that can tell ESLint to ignore the no-debugger rule for this particular file?


回答1:


You can do that like this:

/* eslint-disable no-debugger */
... code that violates rule ...
/* eslint-enable no-debugger */



回答2:


You can also disable ESLint in the same line:

debugger; // eslint-disable-line no-debugger



回答3:


Probably your IDE can help. If you are using VS Code, you can mouse over debugger, click Quick Fix..., and select Disable no-debugger for the entire file, as shown as below:

Then the IDE will add the following comment at the top of the file to disable the rule for you:

/* eslint-disable no-debugger */

See more on the eslint no-debugger rule.




回答4:


OR, add:

"no-debugger": false

to the bottom of tslint.json, to disable this warning for all files.




回答5:


Update your eslint configuration file (.eslintrc etc) with such rule:

"rules": {
    "no-debugger":"off"
}


来源:https://stackoverflow.com/questions/47423266/allow-debugger-statements-in-certain-files-using-eslint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!