Inertia Lighting | Code Style Guide > JavaScript
We use 4 spaces for indentation.
Example:
function foo() {
return 'bar';
}
We use single quotes for strings and graves for template literals.
Example:
const foo = 'bar';
const bar = `${foo}`;
We use semi-colons in our javascript.
Example:
doSomething();
doSomethingElse();
We use trailing commas in multi-line array / object literals.
Example:
const foo = [
'bar',
];
const bar = [ 'baz' ];
We use braces on the same line as the method declaration.
Example:
function someMethod() {
return 'bar';
}
We use snake_case for variable names;
camelCase for function / method names;
and PascalCase for class names.
Example:
class Foo {
constructor(bar) {
this.bar = bar;
}
outputBar() {
console.log(this.bar);
}
}
const foo = new Foo('bar');
foo.outputBar();