Skip to content

Commit a432931

Browse files
brad4dcopybara-github
authored andcommitted
Add instructions for suppressing debugger error message.
It's reasonable to suppress the error for use of `debugger;` statements when you're actively debugging. Add instructions for doing this to the error message. PiperOrigin-RevId: 503551199
1 parent 2606751 commit a432931

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/com/google/javascript/jscomp/CheckDebuggerStatement.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,23 @@
1919
import com.google.javascript.rhino.Node;
2020

2121
/**
22-
* {@link CheckDebuggerStatement} checks for the presence of the "debugger"
23-
* statement in JavaScript code. It is appropriate to use this statement while
24-
* developing JavaScript; however, it is generally undesirable to include it in
25-
* production code.
22+
* {@link CheckDebuggerStatement} checks for the presence of the "debugger" statement in JavaScript
23+
* code. It is appropriate to use this statement while developing JavaScript; however, it is
24+
* generally undesirable to include it in production code.
2625
*/
27-
class CheckDebuggerStatement extends AbstractPostOrderCallback
28-
implements CompilerPass {
26+
class CheckDebuggerStatement extends AbstractPostOrderCallback implements CompilerPass {
2927

3028
static final DiagnosticType DEBUGGER_STATEMENT_PRESENT =
31-
DiagnosticType.disabled("JSC_DEBUGGER_STATEMENT_PRESENT",
32-
"Using the debugger statement can halt your application if the user " +
33-
"has a JavaScript debugger running.");
29+
DiagnosticType.disabled(
30+
"JSC_DEBUGGER_STATEMENT_PRESENT",
31+
"Using the debugger statement can halt your application if the user has a JavaScript"
32+
+ " debugger running.\n"
33+
+ "To disable this check when you want to do debugging, you can suppress this message"
34+
+ " like this:\n"
35+
// NOTE: Single quotes around curly braces are necessary to prevent them being
36+
// interpreted as a placeholder for replacement. See MessageFormat javadoc.
37+
+ " /** @suppress '{'checkDebuggerStatement'}' */\n"
38+
+ " debugger;");
3439

3540
private final AbstractCompiler compiler;
3641

0 commit comments

Comments
 (0)