Skip to main content

Is JS lint available for offline use?



I'd like to use JSLint but am wary of tools that have access to my unfiltered source-code. Is there an offline version or is there another similar tool that does " lint error checking" for JavaScript offline?





Edit: One with a GUI / shows you a styled list of errors, instead of command line?



Source: Tips4all

Comments

  1. If you like the JSLint web interface, you can do File > Save Page As... and Save as type: Web Page, complete (in Firefox, doing it in Internet Explorer may be slightly different) to a local folder.

    I change the name to jslint.htm to get it under 8.3 with no spaces.

    It seems to work when saved locally.

    Three things:


    This may violate his license, although I leave the Copyright intact and don't modify any of his code, and technically my web browser already created a copy of his site on my local HD, so I'm not sure whether I'm in violation or not and I'm not a lawyer so I'll keep doing this until I get a letter telling me to stop.
    The page may somehow still be able to send your code to the Internet, although the chance of it being possible is very remote. That said, the WSH or Rhino versions could probably send the code you submit to the Internet easier than a version in a locally saved web page could (if you're paranoid).
    You'll get behind on any bug fixes or updates Douglas does. But the same thing applies to the WSH or Rhino versions if you don't update them regularly.

    ReplyDelete
  2. Yes:


    On windows use jslint.js + WSH
    On systems that can run Rhino, use jslint.js + Rhino


    Basically, you just need an embedded JavaScript compiler to run jslint.js.

    ReplyDelete
  3. JSLint can be run offline with either WSH or Rhino:

    http://www.jslint.com/lint.html#try

    Edit: In the two years since this question was asked, JSLint has dropped support for Rhino and WSH. I encourage anyone interested in linting their code to also check out JSHint. It's a fork of JSLint which aims to be more flexible than the original, but also happens to support Node, Rhino, and WSH (in addition to browsers, of course).

    ReplyDelete
  4. If you're in a Java environment, you may find my jslint4java tool useful. It comes in a command line variant, and can also be integrated into an ant script. No GUI, because I suck badly at those. :-)

    ReplyDelete
  5. YSlow for Firebug has this feature built in

    ReplyDelete
  6. There's another JS Linter, called JavaScript Lint, that has both online and downloadable command line versions. I use the downloadable version all time. I've been thinking about integrating it into SVN as part of a hook. I like it better than JSLint because it has more options and seems to detect more things. It can be configured to treat certain identifiers as predefined, for toolkits and the like, which allows it to check for usage of undefined variables, which I'm pretty sure JSLint can't do.

    ReplyDelete
  7. I have a tool for running jslint from the command line with either the Spidermonkey shell or Rhino. It also includes a plugin for VIM that allows you to press a button to automatically highlight any problem lines while editing a file:

    http://github.com/hallettj/jslint.vim/

    ReplyDelete
  8. If you use TextMate, I've made a bundle that runs JSLint and displays the output in a graphical window. It's all self-contained; nothing else needs to be installed to use it:

    View JSLint.tmbundle at GitHub

    ReplyDelete
  9. Since JSLint itself is written in JavaScript, you can run it offline by copying the HTML and referenced JavaScript files locally. IE7's "Save As..." "webpage, complete" feature does this just fine.

    ReplyDelete
  10. Cory Bennet has a good post on command-line JSLint. Much of your setup will be getting SpiderMonkey working. Not so bad if you're running Linux; a wee harder if you're using windows and CygWin. And here are some more discussion and comparison with Rhino run-times.

    ReplyDelete
  11. There is a great Yahoo Widget:

    http://ajaxian.com/archives/jslint-multi

    It is open source, if you are paranoid you can audit the code.

    ReplyDelete
  12. I have JSLint with Node.js validating code in my deploy scripts to ensure I don't accidentally push code that could break my site. It can save a lot of time handling customer support issues later.

    ReplyDelete
  13. If you're using TextMate, the JSLintMate bundle has a simple interface, supports both JSLint and JSHint, and lets you set custom options in various ways (e.g., a config file per project, global options across all projects).

    ReplyDelete
  14. If you already use ruby gems then you may install jslint gem in one command :
    http://rubygems.org/gems/jslint

    ReplyDelete
  15. Try the Google Closure Linter. It has more features than JSLint, too.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.