[Screeninvader] Javascript code convention

Jascha jascha at jaeh.at
Fri Apr 10 18:48:07 CEST 2015


@conventions:
most of the crockford rules are being followed, the main thing that i
(we?) do differently is commas in variable declarations and 2 space
indentation.

this guide also describes some nice practices:
https://docs.npmjs.com/misc/coding-style
and kind of is the standard of the node community.
contrary to the npm guide i always use semicolons and always use
{} to open and close blocks, even for one-liners.
if ( true ) { do(); } not if (true) do()

there is no standardized (and broadly accepted) javascript coding
style afaik, only partially formulated stuff not covering all details,
which means that we will have to create our own style or use the style
guide of an organization like linkedin, washington post and some others
who published their rules.

my favorite approach would be to throw together the style rules we
already use in a pastebin, discuss the points, extend and
finish a document which we can push to the github screeninvader
faq repo and also create lint rules for.

@linting:
phaer and i talked about linting and agreed that it is a nice to
have but not important enough to implement in the project build steps
directly as long as we do not get significant pull requests.

https://github.com/screeninvader/outta_space/blob/master/.jshintrc
this file lints outta_space and should work, phaer's emac lints on
every safe.

greetings
j.

On Fri, 10 Apr 2015 13:38:00 +0200
pl <c at c0mm.it> wrote:

> Is his guide complete? Are there already linters filled with his
> schematics?
> 
> What I've read in the past is airbnb's JavaScript Style Guide [0],
> they are also providing linter configurations and their approach with
> bad / good examples are easy to follow. Since I haven't had much to
> do with the js code yet - but: The current approach with declaring
> variables looks weird for me (an indented semicolon after multiple
> variable declerations). Airbnb's guide suggests (like google too[1])
> to use only single var declarations. Idiomatic.js is different there
> [2], though I think airbnb's reasoning is more correct. I think the
> main problem jaeh had, was that he was not using a code linter and
> created his styling around being able to reduce nitpicks, which, in
> my opinion, don't happen if you are using a correctly configured
> editor including a linter (sorry jaeh).
> 
> We should setup stuff like jscs [3] for enforcing code styles before
> you can send pull requests.
> 
> [0]: https://github.com/airbnb/javascript
> [1]:
> https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
> [2]: https://github.com/rwaldron/idiomatic.js [3]: http://jscs.info/
> 
> _______________________________________________
> Screeninvader mailing list
> Screeninvader at lists.metalab.at
> https://lists.metalab.at/mailman/listinfo/screeninvader




More information about the Screeninvader mailing list