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


Groups > comp.lang.javascript > #40991

Re: JSLint: "Wrap a ternary expression in parens, ..."

Path csiph.com!aioe.org!rEIP5qHyzg2o27z2J/u4LQ.user.46.165.242.91.POSTED!not-for-mail
From emf <emfril@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: JSLint: "Wrap a ternary expression in parens, ..."
Date Fri, 15 Jul 2022 14:24:28 -0400
Organization Aioe.org NNTP Server
Message-ID <tasbct$11ej$1@gioia.aioe.org> (permalink)
References <tapv73$1pkf$1@gioia.aioe.org> <ff42c0ad-120d-4a19-9a04-e4b47f2b0a92n@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Info gioia.aioe.org; logging-data="34259"; posting-host="rEIP5qHyzg2o27z2J/u4LQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0
X-Notice Filtered by postfilter v. 0.9.2
Content-Language en-US
Xref csiph.com comp.lang.javascript:40991

Show key headers only | View raw


On 2022-07-15 11:40, Michael Haufe (TNO) wrote:
> On Thursday, July 14, 2022 at 3:44:28 PM UTC-5, emf wrote:
>> Hi.
>>
>> JSLint now does not like this code (that it used to find OK), saying
>>
>> "Wrap a ternary expression in parens, with a line break after
>> the left paren."
>>
>> =================
>> orb = (orb0Btn.checked)
>> ? 0
>> : (orb5Btn.checked)
>> ? 5
>> : (orb10Btn.checked)
>> ? 10
>> : (orb15Btn.checked)
>> ? 15
>> : 20;
>> =================
>>
>> What is now the correct syntax for the ternary expression?
> 
> It's just a jslint setting. You can turn that off I'm pretty sure.
> 
> I think it wants:
> 
> (
>      p ? truePart : (
>          p ? truePart : falsePart
>      )
> )
> 
> 
> I think this is because nested ternaries can be a little hard to read if you don't format them properly.
> 
> I prefer ESLint

OK, JSLint does not find anything wrong with this

orb = ((orb0Btn.checked)
      ? 0
      : (orb5Btn.checked)
         ? 5
         : (orb10Btn.checked)
             ? 10
              : (orb15Btn.checked)
                 ? 15
                 : 20);

The only now warning is:

1. Bad assignment to 'panel'. 89.5
     panel = document.getElementById("panel");

however the program (see sig below in (nataltransits2.js) still 
does not work...

Eustace
-- 
Natal Transits Calculator
https://emf.neocities.org/nt/nataltransits2.html

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


Thread

JSLint: "Wrap a ternary expression in parens, ..." emf <emfril@gmail.com> - 2022-07-14 16:44 -0400
  Re: JSLint: "Wrap a ternary expression in parens, ..." "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2022-07-15 08:40 -0700
    Re: JSLint: "Wrap a ternary expression in parens, ..." emf <emfril@gmail.com> - 2022-07-15 14:24 -0400
      Re: JSLint: "Wrap a ternary expression in parens, ..." "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2022-07-16 08:37 -0700
        Re: JSLint: "Wrap a ternary expression in parens, ..." emf <emfril@gmail.com> - 2022-07-16 17:46 -0400
      Re: JSLint: "Wrap a ternary expression in parens, ..." emf <emfril@gmail.com> - 2022-07-16 17:27 -0400
  Re: JSLint: "Wrap a ternary expression in parens, ..." emf <emfril@gmail.com> - 2022-07-15 14:19 -0400

csiph-web