15

I'm running JSLint's Rhino version from the Ubuntu command line like so:

$ rhino jslint.js myScript.js

While the web interface offers various options, I couldn't figure out how to invoke those via the command line. Am I overlooking anything in the documentation?

5 Answers 5

7

Yes! You did miss it. You can specify the options for jslint at the top of your .js file. See the doc page and read the options section for an example.

3
  • 2
    Thanks! I hadn't even considered to put the options into the .js files themselves... The documentation there says "JSLint accepts an option object" - any way to pass that via the command line?
    – AnC
    Commented Mar 1, 2009 at 14:50
  • Not that I know of, unfortunately. You could write a wrapper script to take command-line options and put them at the top of the js file, or create a temporary js file which is just the options + the original. Just an idea, though, never tried it. You could write it an open source it!
    – jonstjohn
    Commented Mar 1, 2009 at 14:59
  • I've had the same thought - shouldn't be hard, but not sure when I'll get around to it. (I'd have to make sure though not to add any line breaks, otherwise the line numbers being reported would be off.)
    – AnC
    Commented Mar 1, 2009 at 15:16
3

My jslint4java project includes a command line tool that allows you to add in flags like --undef. This may be more useful than running it by hand.

2

I was inspired by the discussion above, and extended my JSLint wrapper script accordingly. It's fairly primitive, but seems to do the job.

0
1

There is a perl+js wrapper for jslint that Cory Bennet put together (based on Ian Bicking's prior art). It's got command-line options, etc. He even details some Emacs integration via a compile-mode hook.

I had some trouble, and put some notes up on getting it to work in Cygwin and Emacs32.

There are some other options in a similar question: Is there an offline version of jslint for windows?

3
  • That sounds very interesting, thanks! So it's a Perl wrapper that uses Spidermonkey? Sorry FND, but I guess I'll have to abandon your Rhino-based Python script... (I just saw there's a Spidermonkey version as well, but that looks a little unfinished?)
    – AnC
    Commented Aug 24, 2009 at 5:59
  • the Perl-wrapper "just" calls the local javascript interpreter -- I use it with spidermonkey, and there are some instructions for making sure you get the right build of SM, but I don't know if Rhino will work, or not. If you can call it from the command-line, it should work fine (I use it both inside Cygwin, and without). Commented Aug 24, 2009 at 13:15
  • more EmacsW32 suggestions @ stackoverflow.com/questions/2465821/… Commented Mar 18, 2010 at 13:40
0

I came up with a command line jslint solution based on jQuery's jslint-check.js script, which is executed within Rhino via their Makefile.

0