1

In our current project we are using JSLint for verifying that Javacript is written correctly, and that it satisfies a few style checks. This is included as an Ant task in our build.xml.

However, I have found that the license of JSLint makes it incompatible with free and open-source software:

// The Software shall be used for Good, not Evil.

I also find JSLint a bit too overzealous in its checks, and makes JQuery-based development difficult. I understand that its intent is not to help one develop scripts, but to check that the script will work in most existing language implementations.

Finally, it's just not smart enough with its scoping: what's wrong with defining a variable in the head of a for loop? (i.e. for (var i = 0; ...) rather than var i; for (i = 0; ...)).

(EDIT: This is actually a problem with Javascript itself. JavaScript does not have block scope, unlike most C-like languages.)

What alternatives exist for verifying the syntax and style for Javascript scripts, intended to be executed within modern web browsers? Any implementation language is fine. I've even thought about using the Rhino library to load and execute the script within Java.

Community
  • 1
  • 1
jevon
  • 3,197
  • 3
  • 32
  • 40
  • 1
    Check http://stackoverflow.com/questions/3208604/js-validator-alternatives-to-jslint for some options – Bruno Silva Feb 20 '12 at 01:08
  • Still waiting for a valid answer - so far, only a JSLint fork and a different language have been suggested. (For what it's worth, Rhino JS is also useful for linting syntax but not style.) – jevon Dec 09 '12 at 22:03

3 Answers3

1

Use JSHint: http://www.jshint.com/

David G
  • 94,763
  • 41
  • 167
  • 253
  • 2
    JSHint is based on JSLint and thus has the exact same incompatible software license. – jevon Feb 20 '12 at 03:40
  • @jevon: According to https://github.com/versatica/JsSIP/issues/77, it looks like Crockford gave a pristine MIT license to the Eclipse Foundation, who then shared it with JSHint. – Kevin May 31 '17 at 22:07
0

JSHint does not have the same license as JSLint. In a sense it does have an MIT license without the 'Do no evil' addition of JSLint. See the github link: jsHint license on gitHub

Luca
  • 9,259
  • 5
  • 46
  • 59
Gabriel Kohen
  • 4,166
  • 4
  • 31
  • 46
  • 2
    JSHint itself might be under standard MIT, but unless JSHint has totally removed any dependency or reuse of JSLint, or Crockford has granted JSLint an exemption, AFAIK it's still bound by the "do no evil" clause of JSLint. It's still labelled a "fork of JSLint". – jevon Oct 21 '12 at 01:22
0

Why not try TypeScript? its much better than any "checker" JS can provide and generates great code. Its also type-safe and a leaner-meaner language. Just an opinion.

Aniket Inge
  • 25,375
  • 5
  • 50
  • 78
  • Of course one can use any compile-to-Javascript techniques (e.g. Coffeescript, etc) to improve productivity, but this question is specifically for Javascript linting/testing. (One problem is that they always lack integration with existing tool or debugging frameworks; another is that you assume you are writing code from scratch, rather than modifying existing application Javascript.) – jevon Oct 21 '12 at 01:26