Skip to content
This repository was archived by the owner on Nov 4, 2020. It is now read-only.

Commit 6c79400

Browse files
added module documentation
1 parent 09631e0 commit 6c79400

File tree

1 file changed

+16
-40
lines changed

1 file changed

+16
-40
lines changed

Diff for: README.md

+16-40
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# Airbnb JavaScript Style Guide() {
1+
# ZocDoc JavaScript Style Guide() {
22

3-
*A mostly reasonable approach to JavaScript*
3+
### Fork of https://github.com/airbnb/javascript
44

5+
*A mostly reasonable approach to JavaScript*
56

67
## <a name='TOC'>Table of Contents</a>
78

@@ -616,7 +617,7 @@
616617
617618
## <a name='comments'>Comments</a>
618619
619-
- Use `/** ... */` for multiline comments. Include a description, specify types and values for all parameters and return values.
620+
- Use `/** ... */` for multiline comments. Include a description, specify types and values for all parameters and return values. This is __required__ for shared components or apis.
620621
621622
```javascript
622623
// bad
@@ -678,7 +679,7 @@
678679
}
679680
```
680681

681-
- Prefixing your comments with `FIXME` or `TODO` helps other developers quickly understand if you're pointing out a problem that needs to be revisited, or if you're suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable. The actions are `FIXME -- need to figure this out` or `TODO -- need to implement`. Always finish your `TODO` or `FIXME` comments with `: NAME` such as `TODO: Guofu`
682+
- Prefixing your comments with `FIXME` or `TODO` helps other developers quickly understand if you're pointing out a problem that needs to be revisited, or if you're suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable. The actions are `FIXME -- need to figure this out` or `TODO -- need to implement`. Always finish your `TODO` or `FIXME` comments with `: Name` such as `TODO: Guofu`
682683

683684
- Use `// FIXME:` to annotate problems
684685

@@ -754,22 +755,6 @@
754755
breed: 'Bernese Mountain Dog'
755756
});
756757
```
757-
- Place an empty newline at the end of the file.
758-
759-
```javascript
760-
// bad
761-
(function(global) {
762-
// ...stuff...
763-
})(this);
764-
```
765-
766-
```javascript
767-
// good
768-
(function(global) {
769-
// ...stuff...
770-
})(this);
771-
772-
```
773758

774759
- Use indentation when making long method chains.
775760

@@ -974,7 +959,7 @@
974959
});
975960
```
976961

977-
- Use PascalCase when naming constructors or classes
962+
- Use PascalCase when naming constructors, classes, directories, files, or modules
978963

979964
```javascript
980965
// bad
@@ -1224,30 +1209,21 @@
12241209
12251210
## <a name='modules'>Modules</a>
12261211
1227-
- The module should start with a `!`. This ensures that if a malformed module forgets to include a final semicolon there aren't errors in production when the scripts get concatenated.
1228-
- The file should be named with camelCase, live in a folder with the same name, and match the name of the single export.
1229-
- Add a method called noConflict() that sets the exported module to the previous version and returns this one.
1230-
- Always declare `'use strict';` at the top of the module.
1212+
- The file should start with Cassette references to its dependencies
1213+
- The code should start with a `;`. This ensures that if a malformed module forgets to include a final semicolon there aren't errors in production when the scripts get concatenated.
1214+
- The file should be named with PascalCase
1215+
- The file should consist of a IIFE that passes in the result of a call to `ZD.module` with the module name
12311216

12321217
```javascript
1233-
// fancyInput/fancyInput.js
1234-
1235-
!function(global) {
1236-
'use strict';
1218+
// @reference /App_Scripts/Framework
12371219
1238-
var previousFancyInput = global.FancyInput;
1220+
;(function(fancyInput) {
12391221
1240-
function FancyInput(options) {
1241-
this.options = options || {};
1242-
}
1243-
1244-
FancyInput.noConflict = function noConflict() {
1245-
global.FancyInput = previousFancyInput;
1246-
return FancyInput;
1247-
};
1222+
fancyInput.FancyInput = function FancyInput(options) {
1223+
this.options = options || {};
1224+
};
12481225
1249-
global.FancyInput = FancyInput;
1250-
}(this);
1226+
}(ZD.module('FancyInput'));
12511227
```
12521228

12531229
**[[⬆]](#TOC)**

0 commit comments

Comments
 (0)