Allow debugger; statements in certain files, using ESLint

69.3k Views Asked by At

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?

6

There are 6 best solutions below

0
On

OR, add:

"no-debugger": false

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

2
On

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

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

You can also disable ESLint in the same line:

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

You can do that like this:

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

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:

enter image description here

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.

0
On

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 */