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

Re: JSLint for not-quite-JS dialects?

Expand Messages
  • John Hawkinson
    Thanks for all the suggestions. I thought I should write back with an update, perhaps useful to others in the same boat. I did indeed end up with
    Message 1 of 3 , Feb 10, 2011
      Thanks for all the suggestions. I thought I should write
      back with an update, perhaps useful to others in the same boat.

      I did indeed end up with quick-and-dirty preprocessor that runs
      JSLint. It's just a quick modification of fulljslint_ui.js. While
      ignoring the #-processor was easiest, I did extend it to process the
      #include directive that we tend to use, for a single include file (and
      fulljslint.html is modified to add that field). Of course, doing it
      this way means JSLint's line number reporting is wrong if you choose
      to use the #include feature. If there was support in jslint for line
      number hinting via comments, that'd be great, but I certainly don't
      expect it.

      Also, there's no great way to shoehorn in preprocessor error messages
      this way. So it is done hackishly.

      Patch follows.

      --jhawk@...
      John Hawkinson
      +1 617 797 0250

      --- fullinit_ui.js 2011/02/05 21:20:14 1.1
      +++ fullinit_ui.js 2011/02/11 05:23:00
      @@ -93,7 +93,41 @@
      show_jslint_control();
      }

      -
      + function extendScript(instr) {
      + var
      + common,
      + input, output, j, m;
      +
      + common = dom.q('#JSLINT_INPUTCOMMON');
      + input = instr.split('\n');
      + output = [];
      + extendScript.prelog = [];
      + for (j=0; j<input.length; j++) {
      + m=input[j].match(/^[\t ]*#include[\t ](.*)/);
      + if (m) {
      + if (m[1] === '"common.jsxinc"') {
      + output.push("// autoinclude: "+m[1]);
      + output.push(common.getValue());
      + output.push("// end autoinclude");
      + extendScript.prelog.push(
      + "#included common.jsxinc");
      + } else {
      + extendScript.prelog.push(
      + "ignoring #include of " + m[1]);
      + }
      + } else {
      + m=input[j].match(/^[\t ]*#/);
      + if (m) {
      + output.push("// autocomment:" + input[j]);
      + extendScript.prelog.push("ignoring "+input[j]);
      + } else {
      + output.push(input[j]);
      + }
      + }
      + }
      + return output.join('\n');
      + }
      +
      // Restore the options from a JSON cookie.

      if (!option || typeof option !== 'object') {
      @@ -123,7 +157,13 @@

      // Call JSLint and display the report.

      - lib.jslint(input.getValue(), option, output);
      + lib.jslint(extendScript(input.getValue()), option, output);
      + if (extendScript.prelog.length) {
      + output.___nodes___[0].innerHTML =
      + extendScript.prelog.join('<br>\n')+
      + output.___nodes___[0].innerHTML;
      + }
      +
      input.select();
      return false;
      });
      --- fulljslint.html 2011/01/30 22:16:00 1.1
      +++ fulljslint.html 2011/02/06 22:24:02
      @@ -139,6 +139,17 @@
      padding: 0.5em;
      width: 100%;"></textarea>
      </p>
      +<p style="background-color: transparent;">
      +<textarea id="JSLINT_INPUTCOMMON" style="
      + border: 2px solid black;
      + color: black;
      + background: goldenrod;
      + font-family: monospace;
      + height: 10lines;
      + overflow: auto;
      + padding: 0.5em;
      + width: 100%;"></textarea>
      +</p>
      <p>
      <input type="button" name="jslint" value="JSLint">
         

      John Hawkinson <jhawk@...> wrote on Fri, 4 Feb 2011
      at 01:13:04 -0500 in <201102040613.p146D4rv023023@...>:

      > Date: Fri, 4 Feb 2011 01:13:04 -0500 (EST)
      > Message-Id: <201102040613.p146D4rv023023@...>
      > To: jslint_com@yahoogroups.com
      > Subject: JSLint for not-quite-JS dialects?
      > From: John Hawkinson <jhawk@...>
      >
      > Hi, all.
      >
      > I'd like to use JSLint on Adobe's ExtendScript, a JavaScript
      > variant that's used to script Adobe Creative Suite products,
      > like InDesign, PhotoShop, etc. It uses the .jsx file extension.
      >
      > One of its quirks is that it has several "preprocesor"-style
      > directives that can be incldued in script files, some of which
      > are necessary for some scripts (e.g. "#targetengine session").
    Your message has been successfully submitted and would be delivered to recipients shortly.