Excluding files

99 views
Skip to first unread message

Jonathan Klein

unread,
Dec 13, 2013, 2:54:20 PM12/13/13
to jsh...@googlegroups.com
Hi All,

I'm trying to exclude a set of files to lint while using JSHint 2.3.0 in a node.js context.  I've been reading lots of documentation, PR's, etc., and I still can't seem to accomplish my goal.  

On the command line this is easy with the --exclude option, or with a .jshintignore.  It also seems like grunt accomplishes this by doing require('jshint/src/cli/cli'), and then calling cli.run directly.  Unfortunately, when jshint is installed as an npm module it doesn't look like the cli object is exported.  So basically I'm doing this:

var JSHINT    = require('jshint').JSHINT;
var jshintOptions = JSON.parse(fs.readFileSync('/path/to/.jshintrc'));
var jsContent = ""+fs.readFileSync('some/path/to/file', 'utf8');

JSHINT(jsContent, jshintOptions);
var jsHintWarnings = JSHINT.errors;

Is there any way to get a list of files/directories to exclude into this workflow?  Or am I doing something crazy and I should alter my approach?  To give a little more context, this is for a fully node.js web app that provides statistics about our CSS/JS.  Thanks!

-Jonathan

Anton Kovalyov

unread,
Dec 13, 2013, 3:25:38 PM12/13/13
to jsh...@googlegroups.com
Hi Jonathan,

When JSHint runs as a library, it doesn’t have a notion of files or directories. All it expects is an input string. In your case you will have to filter out files outside of JSHint and then call JSHINT function on the result.

Hope this helps.

Anton

--
You received this message because you are subscribed to the Google Groups "JSHint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jshint+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jonathan Klein

unread,
Dec 13, 2013, 3:31:17 PM12/13/13
to jsh...@googlegroups.com
Blast, that's what I was afraid of.  Well, at least I wasn't missing something obvious.  Thanks Anton!  

-Jonathan
Reply all
Reply to author
Forward
0 new messages