Reputation:
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?
Upvotes: 40
Views: 78663
Reputation: 191
I think debugger
need to removed, and briefly used in a development environment.
So you're better off ignoring it where you use.
For example: disable no-debugger for this line
// eslint-disable-next-line no-debugger
debugger
or disable no-debugger for the entire file
/* eslint-disable no-debugger */
Upvotes: 0
Reputation: 197
Update your eslint configuration file (.eslintrc
etc) with such rule:
"rules": {
"no-debugger":"off"
}
Upvotes: 17
Reputation: 5052
OR, add:
"no-debugger": false
to the bottom of tslint.json, to disable this warning for all files.
Upvotes: 2
Reputation: 14316
You can also disable ESLint in the same line:
debugger; // eslint-disable-line no-debugger
Upvotes: 97
Reputation: 30189
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.
Upvotes: 9
Reputation: 15149
You can do that like this:
/* eslint-disable no-debugger */
... code that violates rule ...
/* eslint-enable no-debugger */
Upvotes: 26