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

Re: [jslint] Re: Missing Warning

Expand Messages
  • Jean-Charles Meyrignac
    ... In my opinion, the first line is correct, and the second one is suspicious. About Spry, I had to build a quick prototype with tabs, and I got a Javascript
    Message 1 of 5 , Sep 29, 2009
    • 0 Attachment
      > JSLint could complain when an operand of a relational operator is a ! expression. And it could complain when a relational expression is an
      > 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.
      >

      In my opinion, the first line is correct, and the second one is suspicious.
      About Spry, I had to build a quick prototype with tabs, and I got a
      Javascript error within a few minutes.
      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.
      >
      > So:
      > !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
      are bad.

      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.

      JC
    • Douglas Crockford
      ... I think you meant !(expression === expression2) Clearly there are hazards here.
      Message 2 of 5 , Sep 29, 2009
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, Jean-Charles Meyrignac <jcmeyrignac@...> wrote:
        > And I express doubts about:
        > !(expression) == expression2
        > since it's clearer as:
        > expression != expression2

        I think you meant

        !(expression === expression2)

        Clearly there are hazards here.
      Your message has been successfully submitted and would be delivered to recipients shortly.