Changes between Version 5 and Version 6 of WebInspectorCodingStyleGuide
- Timestamp:
- Dec 1, 2013, 11:14:23 AM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WebInspectorCodingStyleGuide
v5 v6 1 These are JavaScript coding styles used in the Source/WebInspectorUI/UserInterfacefolder.1 These are JavaScript coding styles used in the [https://trac.webkit.org/browser/trunk/Source/WebInspectorUI/ Source/WebInspectorUI/UserInterface] folder. 2 2 3 3 (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]) … … 5 5 * No trailing whitespace 6 6 * 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: 11 11 {{{ 12 12 this.requestRootDOMNode(function(rootNode) { … … 14 14 }); 15 15 }}} 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 suf ix.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`. 18 18 * 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 CSS21 * 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`. 22 22 23 The new JS object types should have the following format:23 The new Inspector object classes should have the following format: 24 24 25 25 {{{