-
Notifications
You must be signed in to change notification settings - Fork 2
Javascript coding guidelines
This document defines some coding guidelines for Eppabasic. Guidelines are based on Felix Geisendörfer's javascript guidelines.
Use 4 spaces for indenting the code.
Use UNIX-newlines (\n).
Use semicolons after every statement and assignment.
Use single quotes (') for string literals.
Opening braces go on the same line as the statement. Closing braces go to a new line and are indented as the original statement.
Declare only one variable per var.
Use lowerCamelCase for variables, properties and function names. Use UpperCamelCase for class names. Use UPPERCASE for constants.
Define short arrays on the same line as the var. For long array definitions use trailing slashes.
One item per line. Use trailing slashes. Use quotes on keys only when needed.
Use alway either === or !== for comparing stuff.
Name closures with descriptive names
Use slashes for comments, alos multiline. Comment only to explain the code at higher levels.
Use /**/ for documenting functions and classes.
/*
* Allows editing code with autocorrecting editor
*/
function Editor() {
// ...
}
Editor.prototype = {
/*
* Inserts text at spesified position
*/
insert: function insert(pos, text) {
if (typeof pos === 'string') {
text = pos;
pos = // ...
}
// ...
},
/*
* Selects text
*/
select: function select(start, end) {
// ---
}
};