Skip to content

Formatting

stub-roh edited this page Sep 8, 2021 · 4 revisions

2 spaces for indentation

Use 2 spaces for indenting your code and swear an oath to never mix tabs and spaces

Use semicolons

According to scientific research, the usage of semicolons is a core value of our community. Consider the points of the opposition, but be a traditionalist when it comes to abusing error correction mechanisms for cheap syntactic pleasures.

80 characters per line

Limit your lines to 80 characters. Yes, screens have gotten much bigger over the last few years, but your brain has not. Use the additional room for split screen, your editor supports that, right?

Use single quotes

Use single quotes, unless you are writing JSON. This helps you separate your objects’ strings from normal strings.

Right:

var foo = ‘bar’;

Wrong:

var foo = “bar”;

Opening braces go on the same line

Your opening braces go on the same line as the statement.

Right:

if (true) {
  console.log(‘winning’);
}

Wrong:

if (true)
{
  console.log(‘losing’);
}

Also, notice the use of white space before and after the condition statement. What if you want to write ‘else’ or ‘else if’ along with your ‘if’…

Right:

if (true) {
  console.log(‘winning’);
} else if (false) {
  console.log(‘this is good’);
} else {
  console.log(‘finally’);
}

Wrong:

if (true)
{
  console.log(‘losing’);
}
else if (false)
{
  console.log(‘this is bad’);
}
else
{
  console.log(‘not good’);
}

Declare one variable per var statement

Declare one variable per var statement, it makes it easier to re-order the lines.

Right:

var keys = [‘foo’, ‘bar’];
var values = [23, 42];
var object = {};

Wrong:

var keys = [‘foo’, ‘bar’],
values = [23, 42],
object = {},
key;

RFP(Request For Proposal)

CODING STYLE GUIDELINES

MON(Minutes Of Meeting)

  • 20210909
Clone this wiki locally