Loading ...
Sorry, an error occurred while loading the content.

Another lint for node.js

Expand Messages
  • nicktulett
    Added the few node.js globals to fulljslint.js, plus a little extra to generate a web page on port 8181 showing the lint results.
    Message 1 of 3 , Oct 5, 2010
    • 0 Attachment
      Added the few node.js globals to fulljslint.js, plus a little extra to
      generate a web page on port 8181 showing the lint results.

      http://github.com/NickTulett/nodelinter/downloads
      <http://github.com/NickTulett/nodelinter/downloads>


      Usage:

      node nodelinter.js your.js


      Reaction:

      Joy, tinged with sadness.




      [Non-text portions of this message have been removed]
    • NickT
      I m just wondering if anyone would consider the irony (and disgrace) of using node.js to fetch the latest fulljslint.js and EVAL!!!ing it to make sure you were
      Message 2 of 3 , Oct 6, 2010
      • 0 Attachment
        I'm just wondering if anyone would consider the irony (and disgrace) of using node.js to fetch the latest fulljslint.js and EVAL!!!ing it to make sure you were always using the latest version. TO wit:

        //EVILnodelinter.js
        require("fs").readFile(process.argv[2], function (err, lintable) {

        var JSlintCSS = "#errors {background-color:mistyrose;border:2px solid black;margin:1em;padding:1em;}#errors p {margin-left:2em;}#errors p.evidence {font-family:monospace;margin-left:0;}#functions {background-color:white;}#members {background-color:peachpuff;}#functions, #members {border:2px solid black;font-family:monospace;margin:1em;padding:1em;}#functions div {margin-left:10em;text-indent:-5em;}#functions div.function {margin-left:0;text-indent:0;}",
        sys = require("sys"),
        http = require('http'),
        jslintfull = http.createClient(80, 'www.jslint.com'),
        request, fulljslint = [], jslint;
        sys.puts(process.argv[2]);
        if (!err) {
        request = jslintfull.request('GET', '/fulljslint.js',
        {'host': 'www.jslint.com'});
        request.end();
        request.on('response', function (response) {
        response.setEncoding('utf8');
        response.on('data', function (chunk) {
        fulljslint.push(chunk);
        });
        response.on('end', function () {
        jslint = eval(fulljslint.join(""));
        if (JSLINT(lintable.toString())) {
        sys.puts("Nothing untoward");
        } else {
        sys.puts("JSlint report available at localhost:8181");
        var httpServer = http.createServer(
        function (request, response) {
        response.writeHead(200, { 'Content-Type': "text/html",
        "Expires": "now" });
        response.end("<html><head><title>JSlint report</title><style>" +
        JSlintCSS + "</style></head><body>" +
        "<H1>JSlint</H1><H2>" + process.argv[2] +
        "</H2><H3>" + (Date().toLocaleString()) + "</H3>" +
        JSLINT.report() + "</body></html>");
        process.exit(0);
        }).listen(8181);
        }
        });
        });
        } else {
        sys.log("File not found!");
        }
        });


        This is just an exercise, makes no allowance for node.js globals but produces the same html report as before.

        As a courtesy, the age should be checked against a locally cached version before requesting a download but I for one have no intention of actually using this...
      • Harry Whitfield
        ... Code removed. ... Douglas provides a minimised version of the current JSLint at http://www.JSLint.com/jslint.js . In my Widget Tester Widget, there is an
        Message 3 of 3 , Oct 8, 2010
        • 0 Attachment
          On 6 Oct 2010, at 21:33:25, NickT wrote:

          > I'm just wondering if anyone would consider the irony (and disgrace) of using node.js to fetch the latest fulljslint.js and EVAL!!!ing it to make sure you were always using the latest version. TO wit:

          Code removed.

          > This is just an exercise, makes no allowance for node.js globals but produces the same html report as before.
          > As a courtesy, the age should be checked against a locally cached version before requesting a download but I for one have no intention of actually using this...

          Douglas provides a minimised version of the current JSLint at http://www.JSLint.com/jslint.js .

          In my Widget Tester Widget, there is an option to download and use the current version instead of the version built into the Widget. I have been using this since April 2009 without any problems. To limit the load on the server, the Widget downloads the code no more than once a day. The Widget uses the include() function call to access the JSLint code, but that is much the same as using eval().

          The latest version of the Widget Tester Widget is at http://tinyurl.com/5unocx and at

          http://widgets.yahoo.com/widgets/widget-tester/with/history .

          The Widget can be unzipped to provide access to the JavaScript code.

          Clearly, if you run downloaded code, you are putting your trust in the web site from which it was fetched.
          If you build JSLint into your own programs, you are also putting your trust in the web site from which it was obtained.

          Harry.
        Your message has been successfully submitted and would be delivered to recipients shortly.