Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1602/coding-style-guide
https://github.com/1602/coding-style-guide
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/1602/coding-style-guide
- Owner: 1602
- Created: 2013-11-28T10:45:02.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2013-11-29T10:54:32.000Z (almost 11 years ago)
- Last Synced: 2024-04-14T09:15:41.043Z (7 months ago)
- Size: 102 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Naming
- use camelCase everywhere, except constants which are `UPPER_CASE_WITH_UNDERSCORE`
- start constructor name with upper case letter
- do not use short variable names### Spaces
- operators should be surrounded with spaces
- anonyous function should not have space between `function` and `(`
- maned function should have not have space between function name and `(`### Identation
We use 4 spaces for identation. No deep identation, i.e. use this way:
```javascrtipt
do.something.awesome(function(imdone) {
imdone();
});
```instead of this
```javascrtipt
do.something.awesome(function(imdone) {
imdone();
});
```### Callback names
Use `done`, `next`, `callback`, `cb` or `fn` as callback param name.
### Callback context binding, using `self` and `that`
Do not use bind, do not save `this` in `self` or `that` variable. Use meaningful
variable name, for example:```javascrtipt
Listing.prototype.update = function(done) {
var listing = this;
listing.products.update(function() {
listing.update(done);
});
};
```### Strings
Do not use `"`, use `'` for strings.
### Objects, arrays formatting
Right:
```
[
'hello',
'world',
{ foo: 'bar' }
];
```Wrong:
[ 'hello'
, 'world'
, { 'foo': 'bar'
, 'bar': 'baz'
}
]### Chaining
Do not indent, start with dot:
```javascrtipt
$('#element')
.addClass('active')
.show();
```### Semicolons
Use them