34

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?

  • 2
    Possible duplicate of [Turning off eslint rule for a specific file](https://stackoverflow.com/questions/34764287/turning-off-eslint-rule-for-a-specific-file) – ztadic91 Nov 21 '17 at 22:00

6 Answers6

82

You can also disable ESLint in the same line:

debugger; // eslint-disable-line no-debugger
Andrzej Gis
  • 13,706
  • 14
  • 86
  • 130
  • I had to do it for ```console.debug``` and ```console.error``` and I used this: ```// eslint-disable-next-line no-console``` on the line above the statements. – MikhailRatner Apr 12 '22 at 15:13
25

You can do that like this:

/* eslint-disable no-debugger */
... code that violates rule ...
/* eslint-enable no-debugger */
husayt
  • 14,553
  • 8
  • 53
  • 81
16

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

"rules": {
    "no-debugger":"off"
}
Arseny
  • 187
  • 1
  • 3
  • Can you explain why this would resolve the question? – llmora Nov 29 '20 at 22:05
  • Tried using this and got ``` Configuration for rule "no-debugger" is invalid: Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed 'false').``` – Ryan Hamblin Sep 10 '21 at 16:09
9

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.

Yuci
  • 27,235
  • 10
  • 114
  • 113
2

OR, add:

"no-debugger": false

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

Beachhouse
  • 4,972
  • 3
  • 25
  • 39
0

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 */
George Wayne
  • 160
  • 1
  • 5