Reputation: 8937
When I've finished debugging an issue, occasionally, one or two console.log()
calls and debugger;
statements go unnoticed, and end up in source control as a result, which I'd like to avoid.
Is there an inspection that would detect this, and maybe even allow setting its severity (e.g. to treat it like an error), similar to other inspections?
Upvotes: 1
Views: 138
Reputation: 8937
To detect console.log
calls, it's possible to create a Structural Search Inspection, found under Editor > Inspections > General > Structural Search Inspection
. After enabling it, you need to click the + icon in the bottom half of the right side, and pick "Add Search template…".
Then, use the following settings:
console.log($log$);
as Search template
Case-sensitive
JavaScript
as the File type
And finally, click OK, and give your new inspection a name that will be shown when it matches, e.g. "Console logging detected".
Upvotes: 2
Reputation: 165088
Settings/Preferences | Editor | Inspections
JavaScript | JavaScript validity issues
'debugger' statement
This inspection reports JavaScript 'debugger' statements, used for interaction with Javascript debuggers. Such statements should probably not be found in production code.
Unfortunately I do not know about similar inspection for console
statements.
P.S. If it would be a PHP code .. it could be done via "Php Inspections (EA Extended)" plugin where in similar by functionality inspection you can provide your own functions/classes.
Upvotes: 1