-
Notifications
You must be signed in to change notification settings - Fork 784
Code Style
Julian Descottes edited this page Apr 14, 2015
·
1 revision
Consistency matters. For example, Piskel is using the following conventions :
- indentation : indent with spaces, 2 spaces per indent
- case : variable names are in camelcase, constant names are in uppercase
-
private : 'private' methods are suffixed with one underscore :
myPublicMethod
andmyPrivateMethod_
- blocks : curly braces are mandatory around blocks in loops and conditionals
Code Style is now checked at build time with JSCS. JSCS checks code style rules, and will fail the build if they are not respected.
It is executed during the default grunt
build.
You can also run it explicitly via grunt lint
or grunt jscs:js
(the former also runs jshint and leadingIndent validations).
The code style used inherits from Google code style with a few modifications. See configuration below :
options : {
"preset": "google",
"maximumLineLength": 120,
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
"validateQuoteMarks": { "mark": "'", "escape": true },
"disallowMultipleVarDecl": "exceptUndefined",
"disallowSpacesInAnonymousFunctionExpression": null
}
The average file size in Piskel is between 80 and 90 lines. Files with more than 300 lines should really be exceptional.