Wednesday, February 2, 2011

JSLint and Rhino support...

Official support for JSLint and Rhino has been dropped according to this post by Douglas Crockford:
http://tech.groups.yahoo.com/group/jslint_com/message/1636
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:
https://github.com/douglascrockford/JSLint/commit/ca120a731db548c0014320fa0c196edc613536ae#diff-3

The actual GitHub that removed this file is located here:
https://github.com/douglascrockford/JSLint/commit/523956b6a2a6771ecfdd138934ed0611fb25bc6c

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
https://github.com/mikewest/jslint-utils/commit/6e854f564b517c696a35b72f93a69635bfc66ab3 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
    inline)
var e, i, input, fileToParse, fileToDisplay, defaults;
15c15
<         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 ' +
  47 
+                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)
            flymake-err-line-patterns))

(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