Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #36409 > unrolled thread
| Started by | emfril@gmail.com |
|---|---|
| First post | 2019-04-25 01:28 -0700 |
| Last post | 2019-05-17 12:17 +0000 |
| Articles | 14 — 7 participants |
Back to article view | Back to comp.lang.javascript
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
| From | emfril@gmail.com |
|---|---|
| Date | 2019-04-25 01:28 -0700 |
| Subject | JSLint Unexpected Warning |
| Message-ID | <3c87329c-6f62-4dc0-a26b-3fb6ed10b04e@googlegroups.com> |
JSLint says:
Unexpected '==='.
if (((a > b) === (bc > ca)) && ((b > c) === (ca > ab))
0.48
Unexpected '==='.
in this (and others):
if (((a > b) === (bc > ca)) && ((b > c) === (ca > ab))
&& ((c > a) === (ab > bc)) && ((a === b) === (bc === ca))
&& ((b === c) === (ca === ab)) && ((c === a) !== (ab === bc))) {
return false;
} else {
return true;
}
Why?
[toc] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2019-04-25 04:33 -0700 |
| Message-ID | <15153690-7779-4df6-bd01-092376ded1f0@googlegroups.com> |
| In reply to | #36409 |
On Thursday, April 25, 2019 at 3:28:22 AM UTC-5, emf...@gmail.com wrote:
> JSLint says:
>
> Unexpected '==='.
> if (((a > b) === (bc > ca)) && ((b > c) === (ca > ab))
> 0.48
> Unexpected '==='.
> in this (and others):
>
> if (((a > b) === (bc > ca)) && ((b > c) === (ca > ab))
> && ((c > a) === (ab > bc)) && ((a === b) === (bc === ca))
> && ((b === c) === (ca === ab)) && ((c === a) !== (ab === bc))) {
> return false;
> } else {
> return true;
> }
>
> Why?
Try a different linter:
https://eslint.org/demo/#eyJ0ZXh0IjoiZnVuY3Rpb24gZm9vKGEsIGIsIGMsIGFiLCBiYywgY2EpIHtcclxuICAgIGlmICgoKGEgPiBiKSA9PT0gKGJjID4gY2EpKSAmJiAoKGIgPiBjKSA9PT0gKGNhID4gYWIpKSAmJlxyXG4gICAgICAgICgoYyA+IGEpID09PSAoYWIgPiBiYykpICYmICgoYSA9PT0gYikgPT09IChiYyA9PT0gY2EpKSAmJlxyXG4gICAgICAgICgoYiA9PT0gYykgPT09IChjYSA9PT0gYWIpKSAmJiAoKGMgPT09IGEpICE9PSAoYWIgPT09IGJjKSlcclxuXHQpIHtcclxuICAgICAgICByZXR1cm4gZmFsc2U7XHJcblx0fSBlbHNlIHtcclxuICAgICAgICByZXR1cm4gdHJ1ZTtcclxuXHR9XHJcbn1cclxuXHJcbmZvbyh0cnVlLCBmY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Im5vLXJlZGVjbGFyZSI6Miwibm8tcmVnZXgtc3BhY2VzIjoyLCJuby1zZWxmLWFzc2lnbiI6Miwibm8tc3BhcnNlLWFycmF5cyI6Miwibm8tdGhpcy1iZWZvcmUtc3VwZXIiOjIsIm5vLXVuZGVmIjoyLCJuby11bmV4cGVjdGVkLW11bHRpbGluZSI6Miwibm8tdW5yZWFjaGFibGUiOjIsIm5vLXVuc2FmZS1maW5hbGx5IjoyLCJuby11bnNhZmUtbmVnYXRpb24iOjIsIm5vLXVudXNlZC1sYWJlbHMiOjIsIm5vLXVudXNlZC12YXJzIjoyLCJuby11c2VsZXNzLWVzY2FwZSI6MiwicmVxdWlyZS15aWVsZCI6MiwidXNlLWlzbmFuIjoyLCJ2YWxpZC10eXBlb2YiOjJ9LCJlbnYiOnt9fX0=
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2019-05-16 20:13 -0700 |
| Message-ID | <b0a057bd-541c-4eaa-b159-1dd079a70689@googlegroups.com> |
| In reply to | #36412 |
On Thursday, 25 April 2019 13:34:02 UTC+2, Michael Haufe (TNO) wrote: > Try a different linter: Bad advice. Rather, find a decent linter then stick to it and rather customise your configuration. Following industry-wide practices is important,so do not configure your linting as a dick: OTOH, it's a mistake to think that here there is, or even that there should be, a fit for all. Conventions are team-wise... Julio
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2019-05-18 10:59 -0700 |
| Message-ID | <e26c064d-37a1-4acd-a29c-fe9451ef5790@googlegroups.com> |
| In reply to | #36619 |
Julio Di Egidio wrote: > [nothing significant]
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2019-04-25 17:43 +0200 |
| Message-ID | <XnsAA3CB44E3667Deejj99@194.109.6.166> |
| In reply to | #36409 |
emfril@gmail.com wrote on 25 Apr 2019 in comp.lang.javascript:
> JSLint says:
>
> Unexpected '==='.
> if (((a > b) === (bc > ca)) && ((b > c) === (ca > ab))
> 0.48
> Unexpected '==='.
> in this (and others):
That is to be expected when you make an error.
Hint: count your ('s and )'s.
> if (((a > b) === (bc > ca)) && ((b > c) === (ca > ab))
> && ((c > a) === (ab > bc)) && ((a === b) === (bc === ca))
> && ((b === c) === (ca === ab)) && ((c === a) !== (ab === bc))) {
> return false;
>} else {
> return true;
>}
>
> Why?
Same thing
================================
btw:
if (myBoolean)
return false
else
return true;
is a unnecesarily difficult way of writing:
return ! myBoolean;
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@telus.net> |
|---|---|
| Date | 2019-04-25 16:43 -0700 |
| Message-ID | <5ch4ce5kt6uq7telfompcjoe79c4ng4etl@4ax.com> |
| In reply to | #36414 |
On Thu, 25 Apr 2019 17:43:29 +0200, "Evertjan."
<exxjxw.hannivoort@inter.nl.net> wrote:
>emfril@gmail.com wrote on 25 Apr 2019 in comp.lang.javascript:
>
>> JSLint says:
>>
>> Unexpected '==='.
>> if (((a > b) === (bc > ca)) && ((b > c) === (ca > ab))
>> 0.48
>> Unexpected '==='.
>> in this (and others):
>
>That is to be expected when you make an error.
>
>Hint: count your ('s and )'s.
>
>> if (((a > b) === (bc > ca)) && ((b > c) === (ca > ab))
>> && ((c > a) === (ab > bc)) && ((a === b) === (bc === ca))
>> && ((b === c) === (ca === ab)) && ((c === a) !== (ab === bc))) {
>> return false;
>>} else {
>> return true;
>>}
>>
>> Why?
>
>Same thing
The parens look balanced with this second one, but it is bad
code, because it is too complicated.
>================================
>
>btw:
>
>if (myBoolean)
> return false
>else
> return true;
>
>is a unnecesarily difficult way of writing:
>
>return ! myBoolean;
Quite. You might need parens around the boolean if it is an
expression.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2019-04-26 13:30 +0200 |
| Message-ID | <XnsAA3D8978E82F8eejj99@194.109.6.166> |
| In reply to | #36421 |
Gene Wirchenko <genew@telus.net> wrote on 26 Apr 2019 in comp.lang.javascript: >>btw: >> >>if (myBoolean) >> return false >>else >> return true; >> >>is a unnecesarily difficult way of writing: >> >>return ! myBoolean; > > Quite. You might need parens around the boolean if it is an > expression. Why? -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@telus.net> |
|---|---|
| Date | 2019-04-29 11:04 -0700 |
| Message-ID | <j0fece17bqm0ppk72sik45grh8ea8tdb89@4ax.com> |
| In reply to | #36430 |
On Fri, 26 Apr 2019 13:30:50 +0200, "Evertjan."
<exxjxw.hannivoort@inter.nl.net> wrote:
>Gene Wirchenko <genew@telus.net> wrote on 26 Apr 2019 in
>comp.lang.javascript:
>
>>>btw:
>>>
>>>if (myBoolean)
>>> return false
>>>else
>>> return true;
>>>
>>>is a unnecesarily difficult way of writing:
>>>
>>>return ! myBoolean;
>>
>> Quite. You might need parens around the boolean if it is an
>> expression.
>
>Why?
If the expression has more than one part, the negation will not
give the right result. Suppose the boolean is
IsCust && HasCredit
The negation is not
!IsCust && HasCredit
but
!(IsCust && HasCredit)
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2019-04-30 00:06 +0200 |
| Message-ID | <XnsAA4110677F3eejj99@194.109.6.166> |
| In reply to | #36486 |
Gene Wirchenko <genew@telus.net> wrote on 29 Apr 2019 in comp.lang.javascript: >>>>return ! myBoolean; >>> >>> Quite. You might need parens around the boolean if it is an >>> expression. >> >>Why? > > If the expression has more than one part, the negation will not > give the right result. Suppose the boolean is > IsCust && HasCredit > The negation is not > !IsCust && HasCredit > but > !(IsCust && HasCredit) True! I was under the impression that you meant this expression: return (! myBoolean); because THAT was my expression, because myBoolean is imho not an expression, but just a value. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@telus.net> |
|---|---|
| Date | 2019-04-30 21:15 -0700 |
| Message-ID | <g87ice1j72pj326b0d1ptmm22s5vt4lah8@4ax.com> |
| In reply to | #36490 |
On Tue, 30 Apr 2019 00:06:02 +0200, "Evertjan."
<exxjxw.hannivoort@inter.nl.net> wrote:
>Gene Wirchenko <genew@telus.net> wrote on 29 Apr 2019 in
>comp.lang.javascript:
>
>>>>>return ! myBoolean;
>>>>
>>>> Quite. You might need parens around the boolean if it is an
>>>> expression.
>>>
>>>Why?
>>
>> If the expression has more than one part, the negation will not
>> give the right result. Suppose the boolean is
>> IsCust && HasCredit
>> The negation is not
>> !IsCust && HasCredit
>> but
>> !(IsCust && HasCredit)
>
>True!
>
>I was under the impression that you meant this expression:
>
>return (! myBoolean);
>
>because THAT was my expression,
>because myBoolean is imho not an expression,
>but just a value.
I thought that might be the case. I just wanted to warn about
the more general issue. Some people are not so familiar with complex
boolean expressions. I get hung up on some messy ones on occasion
myself.
Keep pushing out good advice.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | emf <emfril@gmail.com> |
|---|---|
| Date | 2019-05-16 22:31 -0400 |
| Message-ID | <qbl6cs$1lb1$1@gioia.aioe.org> |
| In reply to | #36409 |
On 2019-04-25 4:28, emfril@gmail.com wrote:
> JSLint says:
>
> Unexpected '==='.
> if (((a > b) === (bc > ca)) && ((b > c) === (ca > ab))
> 0.48
> Unexpected '==='.
> in this (and others):
>
> if (((a > b) === (bc > ca)) && ((b > c) === (ca > ab))
> && ((c > a) === (ab > bc)) && ((a === b) === (bc === ca))
> && ((b === c) === (ca === ab)) && ((c === a) !== (ab === bc))) {
> return false;
> } else {
> return true;
> }
>
> Why?
Thanks for all the replies. When, however, I submit to JSLint just this
function isValid() {
if ((a > b) === (bc > ca)) {
return false;
} else {
return true;
}
}
it still says:
Unexpected '==='.
if ((a > b) === (bc > ca)) {
It accepts, however, as correct this:
function isValid() {
var agb = (a > b);
var bcgca = (bc > ca);
if (agb === bcgca) {
return false;
} else {
return true;
}
}
It seems JSLint does not like to perform (boolean) operations within the
condition except for the main one.
I feel like JSLint is a moving target. Every time I consult it, there is
always something new it doesn't like. So far I've been following its
directions, but I do wish I were sure it's heading in the right direction...
Eustace
--
Spherical Triangle Calculator
http://emf.neocities.org/tr/spherical.html
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2019-05-16 20:08 -0700 |
| Message-ID | <931667c1-04c2-4594-9ada-451b15ad5794@googlegroups.com> |
| In reply to | #36616 |
On Friday, 17 May 2019 04:31:00 UTC+2, emf wrote: > I feel like JSLint is a moving target. Linters are tools to help enforcing conventions and catching some kinds of bugs, period. In particular: Linting is supportive [can I say this in English?], not normative. Linting is configurable, i.e. not meant to be a "fixed target". Linting won't teach you how to code properly, less of all how to structure your code. Use linters, just use them cum grano salis. HTH, Julio
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2019-05-16 20:38 -0700 |
| Message-ID | <768f9691-003d-4487-85eb-44e4ae4bfbf2@googlegroups.com> |
| In reply to | #36616 |
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
[toc] | [prev] | [next] | [standalone]
| From | Jon Ribbens <jon+usenet@unequivocal.eu> |
|---|---|
| Date | 2019-05-17 12:17 +0000 |
| Message-ID | <slrnqdt9j7.6qb.jon+usenet@sable.unequivocal.eu> |
| In reply to | #36616 |
On 2019-05-17, emf <emfril@gmail.com> wrote: > It seems JSLint does not like to perform (boolean) operations within the > condition except for the main one. > > I feel like JSLint is a moving target. Every time I consult it, there is > always something new it doesn't like. So far I've been following its > directions, but I do wish I were sure it's heading in the right direction... Ditch JSLint, install Standard, job done :-) https://standardjs.com/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web