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

betterwsh.js

Expand Messages
  • Sean Kelly
    I ve been working hard to come up to speed on JavaScript (the right way) and I was delighted to find jslint and have been actively working on how I could
    Message 1 of 3 , Sep 20, 2010
    • 0 Attachment
      I've been working hard to come up to speed on JavaScript (the right way) and
      I was delighted to find jslint and have been actively working on how I could
      incorporate this into our automated build process as a quality gate for all
      our javascript code. To that end I have discovered that the wsh.js module is
      significantly less feature rich than the web version. specifically limiting
      to one error before stopping and using stdin instead of reading source file
      directly. To that end I hammered out the follow over the weekend and was
      wondering if there was any reason why this might not be a betterwsh.js?

      (function () {
      var i, j, e, filename, file, source, fso = new
      ActiveXObject("Scripting.FileSystemObject");
      if (WScript.Arguments.length > 0) {
      for (i = 0; i < WScript.Arguments.length; i += 1) {
      filename = WScript.Arguments(i);
      if (fso.FileExists(filename)) {
      file = fso.OpenTextFile(filename, 1, false, -2);
      source = file.ReadAll();
      if (!JSLINT(source, {})) {
      for(j = 0; j < JSLINT.errors.length; j += 1) {
      e = JSLINT.errors[j];
      if (e && e.line) {
      WScript.StdErr.WriteLine(filename + '(' + e.line
      + ') : ' + e.reason);
      }
      }
      WScript.Quit(1);
      } else {
      WScript.StdOut.WriteLine(filename);
      WScript.Quit(0);
      }
      } else {
      WScript.StdErr.WriteLine(filename + ' : File Not Found');
      }
      }
      } else {
      WScript.StdOut.WriteLine('jslint - Windows Scripting front end for
      JSLint');
      WScript.StdOut.WriteLine('Usage: jslint filename [filename] ...');
      }
      }());


      [Non-text portions of this message have been removed]
    • dino chiesa
      A while ago, I noticed the same problems, and wrote something similar. Called it jslint-for-wsh. Posted it on this mailing list a few months ago. Because I
      Message 2 of 3 , Sep 24, 2010
      • 0 Attachment
        A while ago, I noticed the same problems, and wrote something similar. Called it jslint-for-wsh. Posted it on this mailing list a few months ago.
        Because I use emacs, I also wrote a jslint-for-wsh integration with emacs (including flymake).

        All available at http://code.google.com/p/jslint-for-wsh/downloads/list

        My version is different than Sean's, in that it will work either with a filename specified on the command line, or if no arguments are present, with STDIN.

        Not sure why, but I didn't get much feedback on it.

        -Dino

        ps: I also published info on jslint-for-wsh on the EmacsWiki, http://www.emacswiki.org/cgi-bin/wiki/FlymakeJavaScript#toc5 .





        To: jslint_com@yahoogroups.com
        From: home@...
        Date: Mon, 20 Sep 2010 14:24:58 -0700
        Subject: [jslint] betterwsh.js






        I've been working hard to come up to speed on JavaScript (the right way) and
        I was delighted to find jslint and have been actively working on how I could
        incorporate this into our automated build process as a quality gate for all
        our javascript code. To that end I have discovered that the wsh.js module is
        significantly less feature rich than the web version. specifically limiting
        to one error before stopping and using stdin instead of reading source file
        directly. To that end I hammered out the follow over the weekend and was
        wondering if there was any reason why this might not be a betterwsh.js?

        (function () {
        var i, j, e, filename, file, source, fso = new
        ActiveXObject("Scripting.FileSystemObject");
        if (WScript.Arguments.length > 0) {
        for (i = 0; i < WScript.Arguments.length; i += 1) {
        filename = WScript.Arguments(i);
        if (fso.FileExists(filename)) {
        file = fso.OpenTextFile(filename, 1, false, -2);
        source = file.ReadAll();
        if (!JSLINT(source, {})) {
        for(j = 0; j < JSLINT.errors.length; j += 1) {
        e = JSLINT.errors[j];
        if (e && e.line) {
        WScript.StdErr.WriteLine(filename + '(' + e.line
        + ') : ' + e.reason);
        }
        }
        WScript.Quit(1);
        } else {
        WScript.StdOut.WriteLine(filename);
        WScript.Quit(0);
        }
        } else {
        WScript.StdErr.WriteLine(filename + ' : File Not Found');
        }
        }
        } else {
        WScript.StdOut.WriteLine('jslint - Windows Scripting front end for
        JSLint');
        WScript.StdOut.WriteLine('Usage: jslint filename [filename] ...');
        }
        }());

        [Non-text portions of this message have been removed]





        [Non-text portions of this message have been removed]
      • seank_com
        Cool! So there appears to be a need. I was only interested in knowing if there was a technical reason the wsh.js module didn t do this in the first place as
        Message 3 of 3 , Sep 24, 2010
        • 0 Attachment
          Cool! So there appears to be a need. I was only interested in knowing if there was a technical reason the wsh.js module didn't do this in the first place as putting jslint in the build pipeline is the only way a large team can guarantee it gets used regularly

          SeanK.


          --- In jslint_com@yahoogroups.com, dino chiesa <dpchiesa@...> wrote:
          >
          >
          > A while ago, I noticed the same problems, and wrote something similar. Called it jslint-for-wsh. Posted it on this mailing list a few months ago.
          > Because I use emacs, I also wrote a jslint-for-wsh integration with emacs (including flymake).
          >
          > All available at http://code.google.com/p/jslint-for-wsh/downloads/list
          >
          > My version is different than Sean's, in that it will work either with a filename specified on the command line, or if no arguments are present, with STDIN.
          >
          > Not sure why, but I didn't get much feedback on it.
          >
          > -Dino
          >
          > ps: I also published info on jslint-for-wsh on the EmacsWiki, http://www.emacswiki.org/cgi-bin/wiki/FlymakeJavaScript#toc5 .
          >
          >
          >
          >
          >
          > To: jslint_com@yahoogroups.com
          > From: home@...
          > Date: Mon, 20 Sep 2010 14:24:58 -0700
          > Subject: [jslint] betterwsh.js
          >
          >
          >
          >
          >
          >
          > I've been working hard to come up to speed on JavaScript (the right way) and
          > I was delighted to find jslint and have been actively working on how I could
          > incorporate this into our automated build process as a quality gate for all
          > our javascript code. To that end I have discovered that the wsh.js module is
          > significantly less feature rich than the web version. specifically limiting
          > to one error before stopping and using stdin instead of reading source file
          > directly. To that end I hammered out the follow over the weekend and was
          > wondering if there was any reason why this might not be a betterwsh.js?
          >
          > (function () {
          > var i, j, e, filename, file, source, fso = new
          > ActiveXObject("Scripting.FileSystemObject");
          > if (WScript.Arguments.length > 0) {
          > for (i = 0; i < WScript.Arguments.length; i += 1) {
          > filename = WScript.Arguments(i);
          > if (fso.FileExists(filename)) {
          > file = fso.OpenTextFile(filename, 1, false, -2);
          > source = file.ReadAll();
          > if (!JSLINT(source, {})) {
          > for(j = 0; j < JSLINT.errors.length; j += 1) {
          > e = JSLINT.errors[j];
          > if (e && e.line) {
          > WScript.StdErr.WriteLine(filename + '(' + e.line
          > + ') : ' + e.reason);
          > }
          > }
          > WScript.Quit(1);
          > } else {
          > WScript.StdOut.WriteLine(filename);
          > WScript.Quit(0);
          > }
          > } else {
          > WScript.StdErr.WriteLine(filename + ' : File Not Found');
          > }
          > }
          > } else {
          > WScript.StdOut.WriteLine('jslint - Windows Scripting front end for
          > JSLint');
          > WScript.StdOut.WriteLine('Usage: jslint filename [filename] ...');
          > }
          > }());
          >
          > [Non-text portions of this message have been removed]
          >
          >
          >
          >
          >
          > [Non-text portions of this message have been removed]
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.