Re: Bug in recent JSLint update
- --- In firstname.lastname@example.org, "sandyhead25" <austin.cheney@...> wrote:
> There appears to be a new rule that looks for unnecessary parenthesis, but this rule gets confused when wrapping regex: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)/);
> 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.
var mhtml = true,
disqualify = mhtml ? (/^(\s?<((pre)|(script)))/) : (/^(\s <script)/);