Re: [jslint] Re: Missing Warning
> JSLint could complain when an operand of a relational operator is a ! expression. And it could complain when a relational expression is anIn my opinion, the first line is correct, and the second one is suspicious.
> operand of a ! expression.
> comparison operator.
> If I were to do this,
> !(x === y) // bad
> !x === y // bad
> I don't know that that should increase your confidence about Spry.
About Spry, I had to build a quick prototype with tabs, and I got a
It took me a couple of minutes to locate and fix the problem, so I
don't really trust Spry anymore.
What is interesting for JsLint is that this kind of error could be
discovered with source analysis.
I *love* source code analysis since I discovered PCLint (in 1996).
Imagine my delight when I discovered JsLint !
On Mon, Sep 28, 2009 at 6:54 PM, James Clark <sbj@...> wrote:
> I think it would be sufficient to warn only about using ! in an operand
> of <, >, <=, and >=, where (generally speaking) it is clearly unintended.
> !x < y // bad
> Warning about the same for ==, ===, !=, and !==, and warning about !(x
> == y) would be OK if you want, but hypothetically those construct might
> be used for good.
In my common usage, I only use ! as a boolean operator.
Some valid examples:
!(expression1) | expression2
!(expression1) || expression2
!(expression1) & expression2
!(expression1) && expression2
are fine for me
Mixing types should be prohibited:
!(expression) + expression2
!(expression) > expression2
And I express doubts about:
!(expression) == expression2
since it's clearer as:
expression != expression2
Any expression involving a ! should at least display an optional warning.
- --- In email@example.com, Jean-Charles Meyrignac <jcmeyrignac@...> wrote:
> And I express doubts about:I think you meant
> !(expression) == expression2
> since it's clearer as:
> expression != expression2
!(expression === expression2)
Clearly there are hazards here.