-
Indent using spaces. Use 4 space characters for indentation
-
Variable names should be in camel case: isLinked,
-
Keep the names as short and relevant as possible, increases readability
-
Functions names, same as variables.
-
Follow the following indentation and spacing pattern for functions
function compare () { // note the spacing
var val = null // variable declarations in the function scope should be on top
if (a < f) { // note the spacing
val = f // spacing after and before '='
} else {
val = a
}
for (var i = 0; i < 10; i++) { //note the spacing
console.log('lol')
}
return val
}
-
If using semicolons, make sure that every line has semi-colons, if not then avoid using semi colons everywhere.
-
If there are too many declarations, leave a blank line:
function calculate () {
var a = 0
var b = 1
var c = 2
return a * b * c
}
-
Comment wherever possible before a function starts, if a function is having complex operations
-
Parameters and comma separated variables:
function doSomething (a, b, c) { // notice the spacing
var arr = [a, b, c] // spacing for array elements
return arr
}
- Attributes,classes and ids should be named in kebab case, no camel case:
kebab-case
connection-box
<connection class="small-box" my-attr="attrVal"></connection>
this translates into:
myAttr = attrVal in Vue, angular
- Keep the names short and readable.
Follow the naming conventions as used by Bootstrap
-
kebab-case
is the only way to name classes and ids,camelCase
,snake_case
or any mixtures are not preferred. Reason: Conventions followed by bootstrap, perhaps the most readable of all the available casings. -
follow proper indentation and spacing rules:
table-heading-large {
height: 100%,
width: 100%;
margin-top: 10px;
}