Comments (7)
In terms of actual style, I'd propose that we use the more immutable functional methods for data manipulation where possible.
Making use of ES5 .map() .filter() .reduce() .concat() .
Related:
- https://eloquentjavascript.net/1st_edition/chapter6.html
- http://cryto.net/~joepie91/blog/2015/05/04/functional-programming-in-javascript-map-filter-reduce/
from gds-way.
And voila: #119
Readable version: https://gist.github.com/maxf/b6ae33e35eb56e58df40d51a8759470a
from gds-way.
Not a comment about what style of JavaScript we recommend but a proposal for the upper limit of new JavaScript features we support.
I'd propose the following:
- Avoid stage-3 candidates and below
- Track the V8 version in the LTS Node.js release
This means avoiding transpiling entirely, and use only features natively available.
See https://zeit.co/blog/next#data-fetching-is-up-to-the-developer
"Our stance of what features we transpile (like async/await) can be summed up as: we target V8's capabilities. Since our goal is code-sharing between server and client, this gives us great performance when executing the code on Node and developing on Chrome or Brave, for example."
from gds-way.
We definitely need to expand the Node.js style guide to have a section on preferred JavaScript coding styles.
@Nooshu shared this link to a repo of best practices a couple of weeks back and we could just wholesale appropriate a lot of it as our own opinions.
We could enforce these opinions with an even more opinionated linter than Standard such as xo.
For instance xo prefers const
over var
(unless a let
is appropriate) and also =>
vs function
.
Right now on Pay we’re still on node 6.11.12 so we’re not doing any async/await
stuff so I dunno what we’d say about that stuff.
from gds-way.
I can't find the article now, it was by Google or Mozilla.
But their argument for writing async/await
was that they intend to optimise the implementation heavily in future so while it may be slower now, in future it will be the fastest way to handle async.
from gds-way.
I think I'll try and write something up, maybe during the next firebreak.
from gds-way.
Max's PR was merged, closing.
from gds-way.
Related Issues (20)
- Re: 'Linting Python at GDS' HOT 2
- Provide guidance in the GDS Way on the use of static site publishing tools HOT 1
- Link up dockerfile guidance and docker dependency management suggestions? HOT 1
- Overlapping content on the Pull Requests and How to review code pages HOT 2
- Include User support/Support operations on Technical Operations page HOT 3
- Re: 'Programming languages' HOT 1
- Re: 'JavaScript coding style'
- Building accessible services page overlap with service manual HOT 1
- Re: 'HTML coding style' typo @ line 131 HOT 1
- Update HTML guidance HOT 6
- NodeJS guidance on Koa HOT 2
- Re: 'How to do penetration tests' HOT 2
- Re: 'Threat Modelling' HOT 1
- Markdown guidance HOT 4
- Re: 'The GDS Way' HOT 2
- Improve alt text guidance in accessibility.html.md.erb
- Replace Git Pre-commit Hooks guidance
- Replace the Recovery Time Objective example on the Disaster Recovery page
- Expand guidance on use of GitHub organisations to explain the GOV.UK One Login now uses govuk-one-login HOT 1
- Absurdly strict grammatical point
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gds-way.