Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #36620

Re: JSLint Unexpected Warning

Newsgroups comp.lang.javascript
Date 2019-05-16 20:38 -0700
References <3c87329c-6f62-4dc0-a26b-3fb6ed10b04e@googlegroups.com> <qbl6cs$1lb1$1@gioia.aioe.org>
Message-ID <768f9691-003d-4487-85eb-44e4ae4bfbf2@googlegroups.com> (permalink)
Subject Re: JSLint Unexpected Warning
From Julio Di Egidio <julio@diegidio.name>

Show all headers | View raw


On Friday, 17 May 2019 04:31:00 UTC+2, emf  wrote:
> On 2019-04-25 4:28, emfril@gmail.com wrote:
> > JSLint says:
<snip>
> function isValid() {
>      if ((a > b) === (bc > ca)) {
>          return false;
>      } else {
>          return true;
>      }
> }
> 
> it still says:
> 
> Unexpected '==='.
>      if ((a > b) === (bc > ca)) {

Indeed, that's at least ugly.  :)

First, that boils down to:

  function isValid() {
    return !(a > b === bc > ca);
  }

And now note that you are "reifying" the result of the two comparisons
instead of just writing a plain boolean expression, which would be:

  function isValid() {
    return !(a > b && bc > ca || !(a > b) && !(bc > ca));
  }

Now, granted, I personally would not object to your using ===,
certainly not in that case, also considering that in JS there
is no actual reification going on (IIANM).  OTOH, that's certainly
not the only linting rule I would usually relax re the default
set, which is mostly tailored to the rookie and always to the
detriment of actual expert programming, industry-wide...

HTH, anyway my 2c.

Julio

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

JSLint Unexpected Warning emfril@gmail.com - 2019-04-25 01:28 -0700
  Re: JSLint Unexpected Warning "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-04-25 04:33 -0700
    Re: JSLint Unexpected Warning Julio Di Egidio <julio@diegidio.name> - 2019-05-16 20:13 -0700
      Re: JSLint Unexpected Warning "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-05-18 10:59 -0700
  Re: JSLint Unexpected Warning "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-04-25 17:43 +0200
    Re: JSLint Unexpected Warning Gene Wirchenko <genew@telus.net> - 2019-04-25 16:43 -0700
      Re: JSLint Unexpected Warning "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-04-26 13:30 +0200
        Re: JSLint Unexpected Warning Gene Wirchenko <genew@telus.net> - 2019-04-29 11:04 -0700
          Re: JSLint Unexpected Warning "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-04-30 00:06 +0200
            Re: JSLint Unexpected Warning Gene Wirchenko <genew@telus.net> - 2019-04-30 21:15 -0700
  Re: JSLint Unexpected Warning emf <emfril@gmail.com> - 2019-05-16 22:31 -0400
    Re: JSLint Unexpected Warning Julio Di Egidio <julio@diegidio.name> - 2019-05-16 20:08 -0700
    Re: JSLint Unexpected Warning Julio Di Egidio <julio@diegidio.name> - 2019-05-16 20:38 -0700
    Re: JSLint Unexpected Warning Jon Ribbens <jon+usenet@unequivocal.eu> - 2019-05-17 12:17 +0000

csiph-web