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


Groups > comp.lang.javascript > #38030 > unrolled thread

Re: Airbnb JavaScript Style Guidelines, chapter 1

Started byArno Welzel <usenet@arnowelzel.de>
First post2020-01-11 18:56 +0100
Last post2020-01-13 12:49 -0800
Articles 6 — 4 participants

Back to article view | Back to comp.lang.javascript

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Airbnb JavaScript Style Guidelines, chapter 1 Arno Welzel <usenet@arnowelzel.de> - 2020-01-11 18:56 +0100
    Re: Airbnb JavaScript Style Guidelines, chapter 1 "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-11 11:43 -0800
      Re: Airbnb JavaScript Style Guidelines, chapter 1 Julio Di Egidio <julio@diegidio.name> - 2020-01-11 23:11 -0800
      Re: Airbnb JavaScript Style Guidelines, chapter 1 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-01-13 21:03 +0100
        Re: Airbnb JavaScript Style Guidelines, chapter 1 Arno Welzel <usenet@arnowelzel.de> - 2020-01-13 21:42 +0100
        Re: Airbnb JavaScript Style Guidelines, chapter 1 "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-13 12:49 -0800

#38030 — Re: Airbnb JavaScript Style Guidelines, chapter 1

FromArno Welzel <usenet@arnowelzel.de>
Date2020-01-11 18:56 +0100
SubjectRe: Airbnb JavaScript Style Guidelines, chapter 1
Message-ID<h7ugiqFk9pcU1@mid.individual.net>
Stefan Ram:

>   I really like the Airbnb JavaScript Style Guidelines,
>   and that's why I wanted to read through them carefully.

Airbnb has "JavaScript Style Guidelines"? Really?

Oh yes... <https://github.com/airbnb/javascript>

>   Today, I read the first chapter "Types".
> 
>   This chapter is disappointing, though.

The whole business model of Airbnb is evil:

<https://www.theguardian.com/commentisfree/2018/aug/31/airbnb-sharing-economy-cities-barcelona-inequality-locals>



-- 
Arno Welzel
https://arnowelzel.de

[toc] | [next] | [standalone]


#38032

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2020-01-11 11:43 -0800
Message-ID<3a27cadc-4cd3-4380-81a4-deb9d548e04b@googlegroups.com>
In reply to#38030
On Saturday, January 11, 2020 at 11:56:48 AM UTC-6, Arno Welzel wrote:
> Stefan Ram:
> 
> >   I really like the Airbnb JavaScript Style Guidelines,
> >   and that's why I wanted to read through them carefully.
> 
> Airbnb has "JavaScript Style Guidelines"? Really?
> 
> Oh yes... <https://github.com/airbnb/javascript>
> 
> >   Today, I read the first chapter "Types".
> > 
> >   This chapter is disappointing, though.
> 
> The whole business model of Airbnb is evil:
> 
> <https://www.theguardian.com/commentisfree/2018/aug/31/airbnb-sharing-economy-cities-barcelona-inequality-locals>
> 

They have their own style-guide; good for them and irrelevant to anyone else unless they plan on interop with external developers.

Most of it looks to be obvious, but many seem to be redundant if they used modern JavaScript with Babel or the like and an autofixing linter. A couple examples being the use of IIFE vs a block or the usage of Symbols.

The section on iterators/generators I don't get. Seems to be a failing of tooling on their part. Generators compile fine from TypeScript:

<https://www.typescriptlang.org/play/index.html?downlevelIteration=true&target=1#code/GYVwdgxgLglg9mABAKgOYFMwAoCUiDeiAUIqYgJ4zoA2AJogIwDcJZlN9ATC2RVXYgDMLAL5A>

(ignore the error, it's an artifact of not being able to set the "lib" option from the user interface)

section 15.5 on switch statements is interesting:

<https://github.com/airbnb/javascript#comparison--switch-blocks>

I avoid the use of switch statements though <http://wiki.c2.com/?SwitchStatementsSmell>


Most of the rest seem to be idiosyncrasies.

- I'm not a fan of implicit type coercion of truthy values and references.
- 2 character indent? Really?
- I never understood the argument for a trailing newline in the file

This is just dumb:

"Do not use JavaScript getters/setters as they cause unexpected side effects..."

[toc] | [prev] | [next] | [standalone]


#38034

FromJulio Di Egidio <julio@diegidio.name>
Date2020-01-11 23:11 -0800
Message-ID<93ff6476-7dbf-4155-8674-a6ffd6c1731a@googlegroups.com>
In reply to#38032
On Saturday, 11 January 2020 20:43:17 UTC+1, Michael Haufe (TNO)  wrote:
> On Saturday, January 11, 2020 at 11:56:48 AM UTC-6, Arno Welzel wrote:
> > Stefan Ram:
> > >   I really like the Airbnb JavaScript Style Guidelines,
> > >   and that's why I wanted to read through them carefully.
> > 
> > Airbnb has "JavaScript Style Guidelines"? Really?
> > 
> > Oh yes... <https://github.com/airbnb/javascript>
<snip>
> Most of the rest seem to be idiosyncrasies.

Isn't that unavoidable?  It's even properly named, a *style*
guide.  And I'd agree that it's not bad at all, compared to
what most companies seem able to do, those that even try.

That said, I do not understand so much scorn: as I am sure
we all know, the main point of a coding convention, assuming
it is at least reasonable, is not so much in the details of
the rules therein, rather in the fact that there *are* common
rules everybody is following.  And, while few things I have
disliked myself, I have seen just nothing in that set of
rules that has prompted a "sh*t, then I cannot (reasonably)
do this and that", which is what primarily counts.

Indeed, more generally, as long as the language at hand
(and conventions may be thought of as restrictions on the
language) is expressive enough, the specifics of the
language and how "smart" it is are quite a minor factor
re the bigger scheme of things...

Julio

[toc] | [prev] | [next] | [standalone]


#38060

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2020-01-13 21:03 +0100
Message-ID<5467553.MhkbZ0Pkbq@PointedEars.de>
In reply to#38032
Michael Haufe (TNO) wrote:

> On Saturday, January 11, 2020 at 11:56:48 AM UTC-6, Arno Welzel wrote:
>> Stefan Ram:
>> >   Today, I read the first chapter "Types".
>> > 
>> >   This chapter is disappointing, though.
>> 
>> The whole business model of Airbnb is evil:

1. Fallacy: Poisoning the well.  Airbnb’s other business is irrelevant to
   their style guide.

2. Bullshit.  I have been Airbnb-ing from Lombardia (Italy) to Scotland (UK)   
   in recent years and have not heard a single complaint from my hosts about
   the business model (most of them are friends now).
 
> They have their own style-guide; good for them and irrelevant to anyone
> else unless they plan on interop with external developers.

It is used by more than one company, including one (or two?) for which I 
have worked recently.
 
> Most of it looks to be obvious, but many seem to be redundant if they used
> modern JavaScript with Babel or the like and an autofixing linter.

It turns out that autofixing code is a Really Bad Idea[tm], and Babel is 
irrelevant in that regard.  In fact, there are incompatibilities that Babel 
cannot (could not/is not going to) fix, e. g. for-of loops (some of us still 
had/have to consider IE).

> Most of the rest seem to be idiosyncrasies.

I found it necessary to change some of their ESLint rules in my ESLint 
configuration, but on the whole their Style Guide made a lot of sense
(in particular as I was working with people who were not that into code 
consistency as I am).  Some rules are also only recommendations or do not 
advocate strictly for one style.

> This is just dumb:
> 
> "Do not use JavaScript getters/setters as they cause unexpected side
> effects..."

IBTD.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#38062

FromArno Welzel <usenet@arnowelzel.de>
Date2020-01-13 21:42 +0100
Message-ID<h8430tFpb7kU1@mid.individual.net>
In reply to#38060
Thomas 'PointedEars' Lahn:

[About Airbnb]
> 2. Bullshit.  I have been Airbnb-ing from Lombardia (Italy) to Scotland (UK)   
>    in recent years and have not heard a single complaint from my hosts about
>    the business model (most of them are friends now).

Of course a host which makes money with one or multiple Airbnb flats
won't complain about the business model. But my point was something else:

<https://www.theguardian.com/commentisfree/2018/aug/31/airbnb-sharing-economy-cities-barcelona-inequality-locals>

Quote:

Landlords have realised they can make more money out of short lets to
well-off Airbnb users than from renting to conventional tenants who live
and work in the city year round, so when contracts come up for renewal
it’s not uncommon to find the rent suddenly shooting up to levels that
young Spaniards can’t pay. Once they’re forced out of the neighbourhood,
the empty flat promptly disappears into what’s still sometimes
euphemistically known as the “sharing economy”, although what happens
next sounds like the antithesis of sharing.



-- 
Arno Welzel
https://arnowelzel.de

[toc] | [prev] | [next] | [standalone]


#38063

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2020-01-13 12:49 -0800
Message-ID<870fc439-afdf-40a8-91ce-64186f004021@googlegroups.com>
In reply to#38060
On Monday, January 13, 2020 at 2:04:03 PM UTC-6, Thomas 'PointedEars' Lahn wrote:
> Michael Haufe (TNO) wrote:

> > Most of it looks to be obvious, but many seem to be redundant if they used
> > modern JavaScript with Babel or the like and an autofixing linter.
> 
> It turns out that autofixing code is a Really Bad Idea[tm], and Babel is 
> irrelevant in that regard.  In fact, there are incompatibilities that Babel 
> cannot (could not/is not going to) fix, e. g. for-of loops (some of us still 
> had/have to consider IE).

I'll concede this may be true depending on your setup. In TypeScript land it's expected that code must Type-check before linting occurs to avoid weird refactorings. It also does better for a number of these edge cases for legacy environment targets. ex:

<https://mariusschulz.com/blog/downlevel-iteration-for-es3-es5-in-typescript>

> > Most of the rest seem to be idiosyncrasies.
> 
> I found it necessary to change some of their ESLint rules in my ESLint 
> configuration, but on the whole their Style Guide made a lot of sense
> (in particular as I was working with people who were not that into code 
> consistency as I am).  Some rules are also only recommendations or do not 
> advocate strictly for one style.

ACK

> > This is just dumb:
> > 
> > "Do not use JavaScript getters/setters as they cause unexpected side
> > effects..."
> 
> IBTD.

What makes it unexpected? What's the justification? Violating SOLID isn't a getter/setter's fault

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web