Wednesday, February 2, 2011

JSLint and Rhino support...

Official support for JSLint and Rhino has been dropped according to this post by Douglas Crockford:
I am dropping support for rhino.js and wsh.js because others have improved on
them. If you have such an improvement, please add a record describing it.
Thank you.
Here is what the original rhino.js file looks like:

The actual GitHub that removed this file is located here:

The Rhino'd version on the jslint-utils is basically concatenating the fulljslint.js with a small wrapper program for the Rhino:
cat ./fulljslint.js ./rhino.js > ../rhinoed_jslint.js
The version posted at has the following diff:

Adjust rhino.js

-   accept a 'realfilename' argument for the CSS munging that I'll put
    in later on.

-   change the defaults to what I consider a good baseline (documented
var e, i, input, fileToParse, fileToDisplay, defaults;
<         print("Usage: jslint.js file.js");
>         print("Usage: jslint.js file.js [realfilename.js]");

In addition, it changes the JSLint output to be the following:

print('Lint at line ' + e.line + ' character ' +
+                print('[' + fileToDisplay + '] Lint at line ' + e.line + ' character ' +

If you intend to use Flymake with Emacs, you have to check your flymake-jslint.el to change the regexp accordingly.

(setq flymake-err-line-patterns
;     (cons '("^Lint at line \\([[:digit:]]+\\) character \\([[:digit:]]+\\): \\(.+\\)$"                                                                                                                            
;            nil 1 2 3)                                                                                                                                                                                             
      (cons '("\\[\\(.*\\)\\] Lint at line \\([[:digit:]]+\\) character \\([[:digit:]]+\\): \\(.+\\)$"
              1 2 3 4)

(provide 'flymake-jslint)

Page 362 of Learning GNU Emacs from the O'Reilly series and Stack Overflow article explains the reason for the double backslashes. Apparently Emacs needs one backslash when decoding/parsing the Lisp program, and another when creating the regular expression character. Basically the regular expression extracts the file displayed with the \\[ and \\] groupings, and then we extract the filename within it.

No comments:

Post a Comment