All go code must follow the golang official Style Guide
In addition all code must be run though the official go formatter tool gofmt
Part of the build process is running ESLint. ESLint is the final authority on all style issues. PRs will not be accepted unless there are no errors or warnings running ESLint. The ESLint configuration file can be found in: web/react/.eslintrc
Instructions on how to use ESLint with your favourite editor can be found here: http://eslint.org/docs/user-guide/integrations
The following is an abridged version of the Airbnb Javascript Style Guide, with modifications. Anything that is unclear here follow that guide. If there is a conflict, follow what is said below.
- Indentation is four spaces
- Use a space before the leading brace
- Use one space between the comma and the next argument in a bracketed list. No other space.
- Use whitespace to make code more readable.
- Do not use more than one newline to separate code blocks.
- Do not use a newline as the first line of a function
// Correct
function myFunction(parm1, parm2) {
stuff...;
morestuff;
}
// Incorrect
function myFunction ( parm1, parm2 ){
stuff...;
morestuff;
}
- You must use them always
// Correct
var x = 1;
// Incorrect
var x = 1
- Declarations must always use var, let or const.
- Prefer let or const over var.
- camelCase for all variable names.
// Correct
let myVariable = 4;
// OK
var myVariable = 4;
// Incorrect
myVariable = 4;
var my_variable = 4;
- Braces must be used on all blocks.
- Braces must start on the same line as the statement starting the block.
- Else and else if must be on the same line as the if block closing brace.
// Correct
if (somthing) {
stuff...;
} else if (otherthing) {
stuff...;
}
// Incorrect
if (somthing)
{
stuff...;
}
else
{
stuff...;
}
// Incorrect
if (somthing) stuff...;
if (somthing)
stuff...;
- Use template strings instead of concatenation.
// Correct
function getStr(stuff) {
return "This is the ${stuff} string";
}
// Incorrect
function wrongGetStr(stuff) {
return "This is the " + stuff + " string";
}
Part of the build process is running ESLint. ESLint is the final authority on all style issues. PRs will not be accepted unless there are no errors or warnings running ESLint. The ESLint configuration file can be found in: web/react/.eslintrc
Instructions on how to use ESLint with your favourite editor can be found here: http://eslint.org/docs/user-guide/integrations
This is an abridged version of the Airbnb React/JSX Style Guide. Anything that is unclear here follow that guide. If there is a conflict, follow what is said below.
- Include only one React component per file.
- Use class <name> extends React.Component over React.createClass unless you need mixins
- CapitalCamelCase with .jsx extension for component filenames.
- Filenames should be the component name.
- Follow alignment styles shown below:
// Correct
<Tag
propertyOne="1"
propertyTwo="2"
>
<Child />
</Tag>
// Correct
<Tag propertyOne="1" />
- Property names use camelCase.
- React component names use CapitalCamelCase.
- Do not use an underscore for internal methods in a react component.
// Correct
<ReactComponent propertyOne="value" />