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

1287Re: [jslint] Vendor extensions in pseudoclasses

Expand Messages
  • Mike West
    Apr 27, 2010
    • 0 Attachment
      On Tue, Apr 27, 2010 at 5:40 PM, Rob Richardson <erobrich@...> wrote:

      > Alas, I think the going consensus is (with small exception) JSLint is best as
      > a JavaScript lint tool, and not intended to be an all-in-wonder web verifier.

      I understand that, and also see value in concentrating effort on the
      areas in which JSLint most clearly shows value. I wasn't expecting to
      get into an argument about the appropriateness of CSS I'm writing,
      this obviously isn't the correct forum for that discussion. This will
      be my last message on the topic.

      My point is simple. JSLint does, at the moment, parse CSS. It
      attempts to validate CSS in a very practical way (that is, it accepts
      CSS with the conventional hacks that are necessary to do work on
      today's web) in a way that the CSS Validator doesn't. That's valuable
      to me, and I think it's generally valuable.

      The inconsistency I've run into, which is solved via the vendor
      extension, falls into the same category of practical resolutions to
      problems with cross-browser web development. Further, it's consistent
      with JSLint's current acceptance of vendor extensions for properties
      (the IE resize mode I noted yesterday, for example, passes linting).
      I'd recommend that support be added into JSLint for these types of
      pseudoclasses as well.

      In the hopes of helping someone else work around the issue, I'll note
      the 7-line change that I'm using locally below. I don't think it's
      the _right_ way to add the functionality, but it works for me.

      Thanks!

      -Mike

      --- Diff follows, though line numbers won't line up with the current
      version... ---

      diff --git a/scripts/lib/jslint.js b/scripts/lib/jslint.js
      index 05a2283..f270620 100644
      --- a/scripts/lib/jslint.js
      +++ b/scripts/lib/jslint.js
      @@ -884,7 +884,7 @@ var JSLINT = (function () {
      // url badness
      ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto/i,
      // style
      - sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
      + sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_\-][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
      ssx = /^\s*([@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|\d+(?:\.\d+)?|<\/)/,
      // attributes characters
      qx = /[^a-zA-Z0-9-_\/ ]/,
      @@ -3367,8 +3367,12 @@ loop: for (;;) {
      advance(')');
      break;
      default:
      - warning("Expected a pseudo, and instead saw :{a}.",
      - nexttoken, nexttoken.value);
      + if ( option.css && nexttoken.value[ 0 ] === '-' ) {
      + advance();
      + } else {
      + warning("Expected a pseudo, and instead saw :{a}.",
      + nexttoken, nexttoken.value);
      + }
      }
      break;
      case '#':
    • Show all 19 messages in this topic