2623
Comment:
|
2719
|
Deletions are marked like this. | Additions are marked like this. |
Line 10: | Line 10: |
* '''NO NEW SCRIPT FILES SHOULD BE PULLED IN BY THE YAHOO COMBO-LOADER''' | * '''NO NEW SCRIPT FILES SHOULD BE PULLED IN BY THE YAHOO COMBO-LOADER''' (use [[JavaScriptBuildSystem|these instructions]] to add the scripts properly) |
Line 16: | Line 16: |
* If 3 or more lines of strings are to be joined together, use the [].join("") form. | * If 3 or more lines of strings are to be joined together, use the `[str1, str2, ...].join("")` form. |
JavaScript Review Notes
These are items that any code reviewer should keep in mind when reviewing JavaScript.
CRITICAL
ALL JAVASCRIPT FILES MUST BE LINT-FREE
NO NEW SCRIPT FILES SHOULD BE PULLED IN BY THE YAHOO COMBO-LOADER (use these instructions to add the scripts properly)
Plain Old JavaScript
JavaScript blocks should be indented by 4 spaces.
If 3 or more lines of strings are to be joined together, use the [str1, str2, ...].join("") form.
- 1 and 2 character variable names are to be avoided.
- Regular expression literals should be avoided.
- All functions, methods, and object properties should be described with JSDoc comment strings.
C++ style comments ("//") should only be used inside function bodies.
Per-line var statements are preferred inside function bodies.
CSS files should come before JavaScript files in the document head.
Event Handling
event.halt() should be preferred over event.stopPropagation().
Document-wide keypress handlers are dangerous, and should be detached as soon as they are no longer needed.
JavaScript Modules
Modules should have a JSDoc string with the @module or @submodule tag.
Module names should have the form PROJECTNAME.foo.
- Module-body content does not have to be indented.
- Module-wide constants should go at the top of the file, after the module JSDoc string.
Multi-line var statements may be used in the module-wide constants block.
Namespaces
Modules should declare a PROJECTNAME namespace.
A module's public functions should be attached to the PROJECTNAME namespace object.
A module's public functions should not be attached directly to the Y object.
Widgets and Plugins
- Protected and private method names should be prefixed with an underscore.
All protected methods should have the @protected JSDoc tag, even ones like initializer and renderUI.
Event handler method names should be prefixed with _on or _after.
- Custom events should be documented immediately preceding the line on which they are published.
All JSDoc strings for attributes should have @attribute, @type, and @default tags.
Objects such as Node instances should not be instantiated in the widget's ATTRS hash using value:, use valueFn: instead.
- Widget should have a functional example page.
(Not implemented) Widget example pages should follow the Example page Template.
- The widget unit test suite should leave a clean DOM tree in between tests.