Bug 1290142 - Lint devtools/client/performance/modules/; r?jsantell draft
authorGreg Tatum <tatum.creative@gmail.com>
Thu, 28 Jul 2016 11:53:20 -0500
changeset 396788 bd06592e430cf0f5b887bc044f6154e8d3d44d15
parent 396787 f9547f79c085ec1ef0b568fb3841c9921306fd68
child 396789 082e3c2686eee4bd6807d2341808f9826e5d46dd
push id25105
push userbmo:gtatum@mozilla.com
push dateThu, 04 Aug 2016 13:36:29 +0000
reviewersjsantell
bugs1290142
milestone51.0a1
Bug 1290142 - Lint devtools/client/performance/modules/; r?jsantell MozReview-Commit-ID: 5Q71TImHlgW
.eslintignore
devtools/client/performance/modules/categories.js
devtools/client/performance/modules/constants.js
devtools/client/performance/modules/io.js
devtools/client/performance/modules/marker-blueprint-utils.js
devtools/client/performance/modules/marker-dom-utils.js
devtools/client/performance/modules/marker-formatters.js
devtools/client/performance/modules/markers.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -79,17 +79,16 @@ devtools/client/canvasdebugger/**
 devtools/client/commandline/**
 devtools/client/debugger/**
 devtools/client/eyedropper/**
 devtools/client/framework/**
 devtools/client/jsonview/lib/**
 devtools/client/memory/**
 devtools/client/netmonitor/test/**
 devtools/client/netmonitor/har/test/**
-devtools/client/performance/modules/**
 devtools/client/performance/test/**
 devtools/client/projecteditor/**
 devtools/client/promisedebugger/**
 devtools/client/responsivedesign/**
 devtools/client/scratchpad/**
 devtools/client/shadereditor/**
 devtools/client/shared/*.jsm
 devtools/client/shared/webgl-utils.js
--- a/devtools/client/performance/modules/categories.js
+++ b/devtools/client/performance/modules/categories.js
@@ -47,26 +47,34 @@ const CATEGORIES = [{
   label: L10N.getStr("category.tools")
 }];
 
 /**
  * Mapping from category bitmasks in the profiler data to additional details.
  * To be kept in sync with the js::ProfileEntry::Category in ProfilingStack.h
  */
 const CATEGORY_MAPPINGS = {
-  "16": CATEGORIES[0],    // js::ProfileEntry::Category::OTHER
-  "32": CATEGORIES[1],    // js::ProfileEntry::Category::CSS
-  "64": CATEGORIES[2],    // js::ProfileEntry::Category::JS
-  "128": CATEGORIES[3],   // js::ProfileEntry::Category::GC
-  "256": CATEGORIES[3],   // js::ProfileEntry::Category::CC
-  "512": CATEGORIES[4],   // js::ProfileEntry::Category::NETWORK
-  "1024": CATEGORIES[5],  // js::ProfileEntry::Category::GRAPHICS
-  "2048": CATEGORIES[6],  // js::ProfileEntry::Category::STORAGE
-  "4096": CATEGORIES[7],  // js::ProfileEntry::Category::EVENTS
-
+  // js::ProfileEntry::Category::OTHER
+  "16": CATEGORIES[0],
+  // js::ProfileEntry::Category::CSS
+  "32": CATEGORIES[1],
+  // js::ProfileEntry::Category::JS
+  "64": CATEGORIES[2],
+  // js::ProfileEntry::Category::GC
+  "128": CATEGORIES[3],
+  // js::ProfileEntry::Category::CC
+  "256": CATEGORIES[3],
+  // js::ProfileEntry::Category::NETWORK
+  "512": CATEGORIES[4],
+  // js::ProfileEntry::Category::GRAPHICS
+  "1024": CATEGORIES[5],
+  // js::ProfileEntry::Category::STORAGE
+  "2048": CATEGORIES[6],
+  // js::ProfileEntry::Category::EVENTS
+  "4096": CATEGORIES[7],
   // non-bitmasks for specially-assigned categories
   "9000": CATEGORIES[8],
 };
 
 /**
  * Get the numeric bitmask (or set of masks) for the given category
  * abbreviation. See `CATEGORIES` and `CATEGORY_MAPPINGS` above.
  *
@@ -95,19 +103,18 @@ const [CATEGORY_MASK, CATEGORY_MASK_LIST
         if (bitmasksForCategory[name].length != 1) {
           throw new Error(`Expected exactly one category number for "${name}".`);
         } else {
           return bitmasksForCategory[name][0];
         }
       } else {
         if (index > bitmasksForCategory[name].length) {
           throw new Error(`Index "${index}" too high for category "${name}".`);
-        } else {
-          return bitmasksForCategory[name][index - 1];
         }
+        return bitmasksForCategory[name][index - 1];
       }
     },
 
     function (name) {
       if (!(name in bitmasksForCategory)) {
         throw new Error(`Category abbreviation "${name}" does not exist.`);
       }
       return bitmasksForCategory[name];
--- a/devtools/client/performance/modules/constants.js
+++ b/devtools/client/performance/modules/constants.js
@@ -1,9 +1,11 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 exports.Constants = {
-  FRAMERATE_GRAPH_LOW_RES_INTERVAL: 100, // ms
-  FRAMERATE_GRAPH_HIGH_RES_INTERVAL: 16, // ms
+  // ms
+  FRAMERATE_GRAPH_LOW_RES_INTERVAL: 100,
+  // ms
+  FRAMERATE_GRAPH_HIGH_RES_INTERVAL: 16,
 };
--- a/devtools/client/performance/modules/io.js
+++ b/devtools/client/performance/modules/io.js
@@ -74,17 +74,18 @@ function loadRecordingFromFile(file) {
 
   channel.contentType = "text/plain";
 
   return new Promise((resolve, reject) => {
     NetUtil.asyncFetch(channel, (inputStream) => {
       let recordingData;
 
       try {
-        let string = NetUtil.readInputStreamToString(inputStream, inputStream.available());
+        let string = NetUtil.readInputStreamToString(inputStream,
+                                                     inputStream.available());
         recordingData = JSON.parse(string);
       } catch (e) {
         reject(new Error("Could not read recording data file."));
         return;
       }
 
       if (recordingData.fileType != PERF_TOOL_SERIALIZER_IDENTIFIER) {
         reject(new Error("Unrecognized recording data file."));
--- a/devtools/client/performance/modules/marker-blueprint-utils.js
+++ b/devtools/client/performance/modules/marker-blueprint-utils.js
@@ -69,17 +69,18 @@ exports.MarkerBlueprintUtils = {
     let dynamic = typeof blueprint.label === "function";
     let generic = dynamic ? blueprint.label() : blueprint.label;
 
     // If no class name found, attempt to throw a descriptive error as to
     // how the marker implementor can fix this.
     if (!generic) {
       let message = `Could not find marker generic name for "${markerName}".`;
       if (typeof blueprint.label === "function") {
-        message += ` The following function must return a generic name string when no marker passed: ${blueprint.label}`;
+        message += ` The following function must return a generic name string when no` +
+                   ` marker passed: ${blueprint.label}`;
       } else {
         message += ` ${markerName}.label must be defined in the marker blueprint.`;
       }
       throw new Error(message);
     }
 
     return generic;
   },
--- a/devtools/client/performance/modules/marker-dom-utils.js
+++ b/devtools/client/performance/modules/marker-dom-utils.js
@@ -62,17 +62,18 @@ exports.MarkerDOMUtils = {
    * @param document doc
    * @param object marker
    * @return nsIDOMNode
    */
   buildDuration: function (doc, marker) {
     let label = L10N.getStr("marker.field.duration");
     let start = L10N.getFormatStrWithNumbers("timeline.tick", marker.start);
     let end = L10N.getFormatStrWithNumbers("timeline.tick", marker.end);
-    let duration = L10N.getFormatStrWithNumbers("timeline.tick", marker.end - marker.start);
+    let duration = L10N.getFormatStrWithNumbers("timeline.tick",
+                                                marker.end - marker.start);
 
     let el = this.buildNameValueLabel(doc, label, duration);
     el.classList.add("marker-details-duration");
     el.setAttribute("tooltiptext", `${start} → ${end}`);
 
     return el;
   },
 
@@ -103,17 +104,18 @@ exports.MarkerDOMUtils = {
   },
 
   /**
    * Builds a stack trace in an element.
    *
    * @param document doc
    * @param object params
    *        An options object with the following members:
-   *          - string type: string identifier for type of stack ("stack", "startStack" or "endStack"
+   *          - string type: string identifier for type of stack ("stack", "startStack"
+                             or "endStack"
    *          - number frameIndex: the index of the topmost stack frame
    *          - array frames: array of stack frames
    */
   buildStackTrace: function (doc, { type, frameIndex, frames }) {
     let container = doc.createElement("vbox");
     container.className = "marker-details-stack";
     container.setAttribute("type", type);
 
--- a/devtools/client/performance/modules/marker-formatters.js
+++ b/devtools/client/performance/modules/marker-formatters.js
@@ -13,29 +13,29 @@ const { L10N, PREFS } = require("devtool
 // String used to fill in platform data when it should be hidden.
 const GECKO_SYMBOL = "(Gecko)";
 
 /**
  * Mapping of JS marker causes to a friendlier form. Only
  * markers that are considered "from content" should be labeled here.
  */
 const JS_MARKER_MAP = {
-  "<script> element":          L10N.getStr("marker.label.javascript.scriptElement"),
-  "promise callback":          L10N.getStr("marker.label.javascript.promiseCallback"),
-  "promise initializer":       L10N.getStr("marker.label.javascript.promiseInit"),
-  "Worker runnable":           L10N.getStr("marker.label.javascript.workerRunnable"),
-  "javascript: URI":           L10N.getStr("marker.label.javascript.jsURI"),
+  "<script> element": L10N.getStr("marker.label.javascript.scriptElement"),
+  "promise callback": L10N.getStr("marker.label.javascript.promiseCallback"),
+  "promise initializer": L10N.getStr("marker.label.javascript.promiseInit"),
+  "Worker runnable": L10N.getStr("marker.label.javascript.workerRunnable"),
+  "javascript: URI": L10N.getStr("marker.label.javascript.jsURI"),
   // The difference between these two event handler markers are differences
   // in their WebIDL implementation, so distinguishing them is not necessary.
-  "EventHandlerNonNull":       L10N.getStr("marker.label.javascript.eventHandler"),
+  "EventHandlerNonNull": L10N.getStr("marker.label.javascript.eventHandler"),
   "EventListener.handleEvent": L10N.getStr("marker.label.javascript.eventHandler"),
   // These markers do not get L10N'd because they're JS names.
-  "setInterval handler":       "setInterval",
-  "setTimeout handler":        "setTimeout",
-  "FrameRequestCallback":      "requestAnimationFrame",
+  "setInterval handler": "setInterval",
+  "setTimeout handler": "setTimeout",
+  "FrameRequestCallback": "requestAnimationFrame",
 };
 
 /**
  * A series of formatters used by the blueprint.
  */
 exports.Formatters = {
   /**
    * Uses the marker name as the label for markers that do not have
@@ -49,16 +49,17 @@ exports.Formatters = {
 
   StylesFields: function (marker) {
     if ("restyleHint" in marker) {
       let label = marker.restyleHint.replace(/eRestyle_/g, "");
       return {
         [L10N.getStr("marker.field.restyleHint")]: label
       };
     }
+    return null;
   },
 
   /* Group 1 - JS */
 
   DOMEventFields: function (marker) {
     let fields = Object.create(null);
 
     if ("type" in marker) {
@@ -94,29 +95,29 @@ exports.Formatters = {
 
   JSFields: function (marker) {
     if ("causeName" in marker && !JS_MARKER_MAP[marker.causeName]) {
       let label = PREFS["show-platform-data"] ? marker.causeName : GECKO_SYMBOL;
       return {
         [L10N.getStr("marker.field.causeName")]: label
       };
     }
+    return null;
   },
 
   GCLabel: function (marker) {
     if (!marker) {
       return L10N.getStr("marker.label.garbageCollection2");
     }
     // Only if a `nonincrementalReason` exists, do we want to label
     // this as a non incremental GC event.
     if ("nonincrementalReason" in marker) {
       return L10N.getStr("marker.label.garbageCollection.nonIncremental");
-    } else {
-      return L10N.getStr("marker.label.garbageCollection.incremental");
     }
+    return L10N.getStr("marker.label.garbageCollection.incremental");
   },
 
   GCFields: function (marker) {
     let fields = Object.create(null);
 
     if ("causeName" in marker) {
       let cause = marker.causeName;
       let label = L10N.getStr(`marker.gcreason.label.${cause}`) || cause;
@@ -154,25 +155,27 @@ exports.Formatters = {
 
   WorkerFields: function (marker) {
     if ("workerOperation" in marker) {
       let label = L10N.getStr(`marker.worker.${marker.workerOperation}`);
       return {
         [L10N.getStr("marker.field.type")]: label
       };
     }
+    return null;
   },
 
   MessagePortFields: function (marker) {
     if ("messagePortOperation" in marker) {
       let label = L10N.getStr(`marker.messagePort.${marker.messagePortOperation}`);
       return {
         [L10N.getStr("marker.field.type")]: label
       };
     }
+    return null;
   },
 
   /* Group 2 - User Controlled */
 
   ConsoleTimeFields: {
     [L10N.getStr("marker.field.consoleTimerName")]: "causeName"
   },
 
@@ -185,10 +188,12 @@ exports.Formatters = {
  * Takes a main label (e.g. "Timestamp") and a property name (e.g. "causeName"),
  * and returns a string that represents that property value for a marker if it
  * exists (e.g. "Timestamp (rendering)"), or just the main label if it does not.
  *
  * @param string mainLabel
  * @param string propName
  */
 exports.Formatters.labelForProperty = function (mainLabel, propName) {
-  return (marker = {}) => marker[propName] ? `${mainLabel} (${marker[propName]})` : mainLabel;
+  return (marker = {}) => marker[propName]
+    ? `${mainLabel} (${marker[propName]})`
+    : mainLabel;
 };
--- a/devtools/client/performance/modules/markers.js
+++ b/devtools/client/performance/modules/markers.js
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 const { L10N } = require("devtools/client/performance/modules/global");
-const { Formatters, labelForProperty } = require("devtools/client/performance/modules/marker-formatters");
+const { Formatters } = require("devtools/client/performance/modules/marker-formatters");
 
 /**
  * A simple schema for mapping markers to the timeline UI. The keys correspond
  * to marker names, while the values are objects with the following format:
  *
  * - group: The row index in the overview graph; multiple markers
  *          can be added on the same row. @see <overview.js/buildGraphImage>
  * - label: The label used in the waterfall to identify the marker. Can be a
@@ -145,24 +145,26 @@ const TIMELINE_BLUEPRINT = {
     fields: Formatters.MessagePortFields
   },
 
   /* Group 2 - User Controlled */
 
   "ConsoleTime": {
     group: 2,
     colorName: "graphs-blue",
-    label: Formatters.labelForProperty(L10N.getStr("marker.label.consoleTime"), "causeName"),
+    label: Formatters.labelForProperty(L10N.getStr("marker.label.consoleTime"),
+                                       "causeName"),
     fields: Formatters.ConsoleTimeFields,
     nestable: false,
     collapsible: false,
   },
   "TimeStamp": {
     group: 2,
     colorName: "graphs-blue",
-    label: Formatters.labelForProperty(L10N.getStr("marker.label.timestamp"), "causeName"),
+    label: Formatters.labelForProperty(L10N.getStr("marker.label.timestamp"),
+                                       "causeName"),
     fields: Formatters.TimeStampFields,
     collapsible: false,
   },
 };
 
 // Exported symbols.
 exports.TIMELINE_BLUEPRINT = TIMELINE_BLUEPRINT;