All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rules.jshint.W087.html Maven / Gradle / Ivy

Go to download

Consume reports generated by jshint for code quality. Also consume reports for code duplication (either simian or cpd). Consumes the unit/integration tests reports (generated by Jasmin) coverage report (lcov generated by Istanbul). The information generated by reports are added in Sonar

There is a newer version: 2.1.0
Show newest version

    

History

This warning has existed in various forms in JSLint, JSHint and ESLint. It was introduced in the original version of JSLint and has remained in all three linters ever since.

  • In JSLint the warning given is "Unexpected 'debugger'"

  • In JSHint prior to version 1.0.0 the message used is "All 'debugger' statements should be removed"

  • In JSHint version 1.0.0 and above the message is "Forgotten 'debugger' statement?"

  • In ESLint the message has always been "Unexpected 'debugger' statement"

The situations that produce the warning have not changed despite changes to the text of the warning itself.

When do I get this error?

The "All 'debugger' statements should be removed" error, and the alternatives "Forgotten 'debugger' statement" and "Unexpected 'debugger'", is thrown when JSLint, JSHint or ESLint encounters a debugger statement. The following example is completely useless but is the minimum program that will generate this error:

x
 
1
debugger;
2
JSLint found 1 errorVersion 2015-09-23
Line 0:Unexpected 'debugger'.

Why do I get this error?

This error is raised to highlight a lack of convention and a possible oversight. Your code will run without error but it will probably not behave the way you want it to in a production environment. The debugger statement is used to tell the JavaScript engine to open a debugger if one is available and treat the statement as a breakpoint (ES5 §12.15):

Evaluating the DebuggerStatement production may allow an implementation to cause a breakpoint when run under a debugger. If a debugger is not present or active this statement has no observable effect.

This can be useful during development to get an insight into how your code behaves, or to inspect the value of variables at runtime. However it's highly unlikely that you want to keep debugger statements in production code. For that reason, JSLint, JSHint and ESLint prefer them to be removed.

In JSHint 1.0.0 and above you have the ability to ignore any warning with a special option syntax. The identifier of this warning is W087. This means you can tell JSHint to not issue this warning with the /*jshint -W087 */ directive.

In ESLint the rule that generates this warning is named no-debugger. You can disable it by setting it to 0, or enable it by setting it to 1.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy