]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/no-debugger.md
07da9b8a376d6974441d078c707a5f8877264d6b
[pve-eslint.git] / eslint / docs / src / rules / no-debugger.md
1 ---
2 title: no-debugger
3 layout: doc
4 rule_type: problem
5 related_rules:
6 - no-alert
7 - no-console
8 further_reading:
9 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger
10 ---
11
12
13
14 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.
15
16 ## Rule Details
17
18 This rule disallows `debugger` statements.
19
20 Example of **incorrect** code for this rule:
21
22 ::: incorrect
23
24 ```js
25 /*eslint no-debugger: "error"*/
26
27 function isTruthy(x) {
28 debugger;
29 return Boolean(x);
30 }
31 ```
32
33 :::
34
35 Example of **correct** code for this rule:
36
37 ::: correct
38
39 ```js
40 /*eslint no-debugger: "error"*/
41
42 function isTruthy(x) {
43 return Boolean(x); // set a breakpoint at this line
44 }
45 ```
46
47 :::
48
49 ## When Not To Use It
50
51 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.