Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jshint: use node options, but disallow console statements?

Tags:

node.js

jshint

I'm using jshint and I'd like to use the node option, but I'd also like to disallow console statements.

Is this possible? I've been reading the jshint options documentation without luck.

Things I've tried that have failed:

"node": true,
"globals": { 
  "console": false
}

Also:

"node": true,
"devel": false

I guess I could set "node": false and then explicitly add everything to globals, but that seems ugly.

like image 981
Richard Avatar asked May 08 '14 14:05

Richard


1 Answers

First of all the syntax:

"globals": {
    "console": false
}

Is to allow console as a read only variable, so not what you want.

What does appear to work is the following setting:

"predef": ["-console"]

I couldn't find this directly documented, but the docs (http://jshint.com/docs/) mention the predef jshintrc option, and later talk about inline global blacklists (e.g. /* global -BLACKLIST */) and tests show that combining the two does work.

like image 161
Hargo Avatar answered Oct 13 '22 21:10

Hargo