gocardless / javascript-style-guide Goto Github PK
View Code? Open in Web Editor NEWThe GoCardless JavaScript styleguide
The GoCardless JavaScript styleguide
I love this style guide -- especially the ES6 section -- and I'm going to adopt it as my own.
I just had a comment about your use of const
and let
... I assume that section is outdated, because Babel (formerly 6to5) now has great support for them.
Examples:
const c = 5;
c = 10;
Error: "c" is read-only
let i = 0;
for (let i = 0; i < 10; i++) {
console.log(i);
}
for (let i = 0; i < 10; i++) {
console.log(function(){ return i; });
}
Compiled output:
"use strict";
var i = 0;
for (var _i = 0; _i < 10; _i++) {
console.log(_i);
}
for (var _i2 = 0; _i2 < 10; _i2++) {
(function (_i2) {
console.log(function () {
return _i2;
});
})(_i2);
}
It would be nice to get consistent when adding spacing around code blocks. For example, spaces here are probably unnecessary:
function1(var1, var2) {
function2('some_string', function(var3, var4) {
…
});
return;
}
but spaces deeply indented are useful:
]).config([
'$stateProvider',
function accessTokensCreateRoute($stateProvider) {
$stateProvider.state(ACCESS_TOKENS_CREATE_ROUTE_STATE, {
url: '/create',
onEnter: [
'$state',
'Dialog',
function($state, Dialog) {
Dialog.show({
template: template,
controller: 'AccessTokensCreateController',
controllerAs: 'ctrl',
dialogHeader: 'Create Access Token',
onDismissDialog: function onDismissDialog() {
$state.go(ACCESS_TOKENS_INDEX_ROUTE_STATE);
},
});
},
],
});
},
]);
In some places we’re adding a space above but not below a chunk of code. I think it should be both or neither. Any other spacing issues, feel free to add 'em.
Thoughts @jackfranklin @harrison @samjewell @jamesshedden?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.