The Artima Developer Community
Sponsored Link

Python Buzz Forum
JSLint from the Command Line

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ian Bicking

Posts: 900
Nickname: ianb
Registered: Apr, 2003

Ian Bicking is a freelance programmer
JSLint from the Command Line Posted: Oct 7, 2005 3:13 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ian Bicking.
Original Post: JSLint from the Command Line
Feed Title: Ian Bicking
Feed URL: http://www.ianbicking.org/feeds/atom.xml
Feed Description: Thoughts on Python and Programming.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ian Bicking
Latest Posts From Ian Bicking

Advertisement

Javascript can be a finicky language, all the worse that it's often permissive, because different browsers are more permissive than others. Annoyingly for me, Mozilla is more permissive than IE, so my Mozilla testing often misses things.

There aren't many programs out there to check Javascript. The only one I've really found is JSLint. The hard part is that it is written in Javascript. I guess it makes sense, but I want to do automated checking, and a browser context doesn't work for me.

However, you can run Javascript from the command-line with Spidermonkey (Mozilla's Javascript interpreter split out). The command-line interface is hard to decypher.

I eventually figured out I could run jslint like this:

load('fulljslint.js');

var body = arguments[0];

var result = jslint(body);
if (result) {
  print('All good.');
} else {
  print('Problems:');
}  
print(jslint.report());

I can't figure out any way to access stdin, so I have to stuff the entire Javascript into the first argument, and I run it like:

$ js jslintrun.js "`cat jsfile.js`"

Eh... at least it works. I should also use js -s jsfile.js, as this prints out another set of useful warnings (-s is for strict mode).

I want to turn this into another piece of Paste middleware, checking all the JS as it goes past, and probably putting the report in the session so it can be displayed the next time the user/developer views an HTML page.

Then I just have to interface with the CSS validator (or this one?).

Read: JSLint from the Command Line

Topic: Book: Producing Open Source Software Previous Topic   Next Topic Topic: Is TurboGears to Python what Ubuntu is to Linux?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use