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

Re: Bug in recent JSLint update

Expand Messages
  • douglascrockford
    ... I completely agree. It is wise to wrap regexp literals in parens to avoid syntactic weirdness. But that is not what JSLint is complaining about. Try this:
    Message 1 of 3 , Dec 27, 2012
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "sandyhead25" <austin.cheney@...> wrote:

      > There appears to be a new rule that looks for unnecessary parenthesis, but this rule gets confused when wrapping regex:
      >
      > var mhtml = true,
      > disqualify = (mhtml) ? (/^(\s?<((pre)|(script)))/) : (/^(\s?<script)/);
      >
      > For safety regular expressions not used in or with a method I typically wrap in parenthesis because some software can get confused as to where the regular expression syntax ends. Everywhere else in my code the excess parenthesis rule is happy to allow me to wrap regex, except when the regex also contains parenthesis.


      I completely agree. It is wise to wrap regexp literals in parens to avoid syntactic weirdness. But that is not what JSLint is complaining about. Try this:

      var mhtml = true,
      disqualify = mhtml ? (/^(\s?<((pre)|(script)))/) : (/^(\s <script)/);
    • sandyhead25
      Thank you! Austin
      Message 2 of 3 , Dec 27, 2012
      • 0 Attachment
        Thank you!

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