]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/rules/no-debugger.md
f8220bde8132f56514f97e5933acc499c936a3b6
[pve-eslint.git] / eslint / docs / rules / no-debugger.md
1 # disallow the use of `debugger` (no-debugger)
2
3 The `debugger` statement is used to tell the executing JavaScript environment to stop execution and start up a debugger at the current point in the code. This has fallen out of favor as a good practice with the advent of modern debugging and development tools. Production code should definitely not contain `debugger`, as it will cause the browser to stop executing code and open an appropriate debugger.
4
5 ## Rule Details
6
7 This rule disallows `debugger` statements.
8
9 Example of **incorrect** code for this rule:
10
11 ```js
12 /*eslint no-debugger: "error"*/
13
14 function isTruthy(x) {
15 debugger;
16 return Boolean(x);
17 }
18 ```
19
20 Example of **correct** code for this rule:
21
22 ```js
23 /*eslint no-debugger: "error"*/
24
25 function isTruthy(x) {
26 return Boolean(x); // set a breakpoint at this line
27 }
28 ```
29
30 ## When Not To Use It
31
32 If your code is still very much in development and don't want to worry about stripping `debugger` statements, then turn this rule off. You'll generally want to turn it back on when testing code prior to deployment.
33
34 ## Further Reading
35
36 * [Debugger](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger)
37
38 ## Related Rules
39
40 * [no-alert](no-alert.md)
41 * [no-console](no-console.md)