pkgjs / wiby

"Will I break you" - a tool for testing dependents
Apache License 2.0
33 stars 7 forks source link

Switch coding style #60

Closed dominykas closed 3 years ago

dominykas commented 3 years ago

OK, I'll be straight up - I can't handle standard anymore 😂 It's slowing me down.

My preferred style is https://hapi.dev/policies/styleguide/ (the key being loooots of whitespace - 4 spaces, extra line at the start of the function, no no-multiple-empty-lines, etc) - unless there's objections, I'd like to switch to that?

rodion-arr commented 3 years ago

Hi, in support package we switched to semi-standard. What about keep same code style across org? Don't really like idea to have different code styles in every repo of same org :)

dominykas commented 3 years ago

I'm not sure "same org" argument applies here. We have a bunch of very different tools and people maintaining them, and then there's the nodejs umbrella org.

Does semi-standard allow more (and arbitrary) blank lines?

ljharb commented 3 years ago

We’d discussed switching off standard entirely and using eslint; I’d suggested the Airbnb guide, since that’s the most popular styleguide in js (it overlaps with prettier almost completely, as well). I’m not familiar at all with hapi’s guide, but an extra line at the start of a function seems silly to me.

dominykas commented 3 years ago

I looked at the airbnb style, but it also uses 2 space indentation and forbids multiple empty lines.

I'm not set on enforcing the empty line at the function start, as it does take getting used to, but I have grown quite accustomed to it, as it makes function declarations stand out, so I find it easier to navigate then file. Think of it as a sub-heading in a document. What is silly is not allowing that extra line to be there and in some other places at all.

ljharb commented 3 years ago

We can certainly update the indentation - my preference is tabs, but whatever people like is fine with me.

Multiple empty lines should be forbidden.

For me, syntax highlighting and indentation is more than sufficient to make function declarations (and everything else) stand out.

dominykas commented 3 years ago

Yeah, so I'm not in a mood to debate the pros/cons of every single setting available in eslint, and definitely not the tabs vs spaces.

Whitespace does not lead to bugs and we can be reasonable about it, there's no need to restrict it.

I'm just listing out things I'm struggling with and will continue to struggle with, so hopefully there's a well established preset, without being too opinionated to discourage people (or me) from actually contributing code, that can satisfy the need here.

ljharb commented 3 years ago

Whitespace absolutely leads to bugs - linters enforcing whitespace have caught bugs for me in many languages, and gotofail was arguably caused due to incorrect indentation.

I’m very on board with addressing friction, and finding a well-established preset - but Airbnb and/or prettier are the two most commonly used presets in the js ecosystem by any metric (standard is third) so I’d suggest sticking to some combination of those.