Changes between Version 5 and Version 6 of WebInspectorCodingStyleGuide


Ignore:
Timestamp:
Dec 1, 2013 11:14:23 AM (8 years ago)
Author:
Brian Burg
Comment:

Fix tt styles, add links to mechanization tracking bug, repository directory, and Map/Set spec draft

Legend:

Unmodified
Added
Removed
Modified
  • WebInspectorCodingStyleGuide

    v5 v6  
    1 These are JavaScript coding styles used in the Source/WebInspectorUI/UserInterface folder.
     1These are JavaScript coding styles used in the [https://trac.webkit.org/browser/trunk/Source/WebInspectorUI/ Source/WebInspectorUI/UserInterface] folder.
    22
    33(Note: Few if any of these guidelines are checked by `check-webkit-style`. There's a tracking bug for that: [https://bugs.webkit.org/show_bug.cgi?id=125045])
     
    55* No trailing whitespace
    66* Indent with 4 spaces
    7 * The opening bracket "{" after a named function goes on the next line. Anywhere else, the opening bracket "{" stays on the same line.
    8 * Style for JavaScript Object Literals is: {key1: value1, key2: value2}.
    9 * Calling a constructor with no arguments should have no ( ). eg. "var map = new Map;"
    10 * Inline anonymous functions, especially if they don't need a .bind(). Example:
     7* The opening bracket `'{'` after a named, non-inlined function goes on the next line. Anywhere else, the opening bracket `'{'` stays on the same line.
     8* Style for object literals is: `{key1: value1, key2: value2}`.
     9* Calling a constructor with no arguments should have no parenthesis `'()'`. eg. `var map = new Map;`
     10* Inline anonymous functions, especially if they don't need a bound `this`-object (using `.bind()`). Example:
    1111{{{
    1212    this.requestRootDOMNode(function(rootNode) {
     
    1414    });
    1515}}}
    16 * Avoid using the "on" prefix where possible. The "_onFoo" methods can just be "_foo".
    17 * New class names should use the name of the base class as a sufix.
     16* Avoid using the "on" prefix where possible. The `_onFoo` methods can just be `_foo`.
     17* New class names should use the name of the base class as a suffix. (ex: `TimelinesContentView` < `ContentView`). Exceptions: classes extending `WebInspector.Object` (unless they are a represented object), and deep hierarchies such as `DebuggerSidebarPanel` < `NavigationSidebarPanel` < `SidebarPanel` < `Object`.
    1818* Add new lines before and after different tasks performed in the same function.
    19 * Consider using Map structure instead of Object.
    20 * Consider using rgb() over hex colors in CSS
    21 * Firewall the protocol inside the Manager classes. JSON objects received from the protocol are called "payload" in the code. The payload is usually deconstructed at the Managers level and passes down as smart objects inheriting from WebInspector.Object.
     19* Consider using [http://people.mozilla.org/~jorendorff/es6-draft.html#sec-keyed-collection `Map` and `Set` collections] instead of plain objects.
     20* Consider using `rgb()` over hex colors in CSS
     21* Firewall the protocol inside the Manager classes. JSON objects received from the protocol are called "payload" in the code. The payload is usually deconstructed at the Managers level and passes down as smart objects inheriting from `WebInspector.Object`.
    2222
    23 The new JS object types should have the following format:
     23The new Inspector object classes should have the following format:
    2424
    2525{{{