Repository: GoogleChrome/lighthouse
Pull request #6380 (2018-10-24 15:59:39)

misc: lantern script path resolution fix
**Summary**
easier if the path is resolved against, cwd instead of relative to scripts directory, the only usage in our codebase of run-once already fully resolves the path anyway.

**Related Issues/PRs**
#6378



Patch:
diff --git a/.eslintrc.js b/.eslintrc.js
index 4e8c67a86..35e3acb70 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -52,6 +52,7 @@ module.exports = {
       argsIgnorePattern: '(^reject$|^_$)',
       varsIgnorePattern: '(^_$)',
     }],
+    'space-infix-ops': 2,
     'strict': [2, 'global'],
     'prefer-const': 2,
     'curly': [2, 'multi-line'],
diff --git a/lighthouse-core/audits/dobetterweb/dom-size.js b/lighthouse-core/audits/dobetterweb/dom-size.js
index 72cccf38f..fa34ae8b7 100644
--- a/lighthouse-core/audits/dobetterweb/dom-size.js
+++ b/lighthouse-core/audits/dobetterweb/dom-size.js
@@ -104,7 +104,7 @@ class DOMSize extends Audit {
     const headings = [
       {key: 'statistic', itemType: 'text', text: str_(UIStrings.columnStatistic)},
       {key: 'element', itemType: 'code', text: str_(UIStrings.columnElement)},
-      {key: 'value', itemType: 'text', text: str_(UIStrings.columnValue)},
+      {key: 'value', itemType: 'numeric', text: str_(UIStrings.columnValue)},
     ];
 
     /** @type {Array<Object<string, LH.Audit.DetailsItem>>} */
diff --git a/lighthouse-core/audits/uses-rel-preconnect.js b/lighthouse-core/audits/uses-rel-preconnect.js
index a7d82710b..6cbb3aab8 100644
--- a/lighthouse-core/audits/uses-rel-preconnect.js
+++ b/lighthouse-core/audits/uses-rel-preconnect.js
@@ -130,7 +130,7 @@ class UsesRelPreconnectAudit extends Audit {
       // Sometimes requests are done simultaneous and the connection has not been made
       // chrome will try to connect for each network record, we get the first record
       const firstRecordOfOrigin = records.reduce((firstRecord, record) => {
-        return (record.startTime < firstRecord.startTime) ? record: firstRecord;
+        return (record.startTime < firstRecord.startTime) ? record : firstRecord;
       });
 
       // Skip the origin if we don't have timing information
diff --git a/lighthouse-core/gather/computed/page-dependency-graph.js b/lighthouse-core/gather/computed/page-dependency-graph.js
index 557d4f3c0..4b6deeadc 100644
--- a/lighthouse-core/gather/computed/page-dependency-graph.js
+++ b/lighthouse-core/gather/computed/page-dependency-graph.js
@@ -89,7 +89,7 @@ class PageDependencyGraph {
 
       // Skip all trace events that aren't schedulable tasks with sizable duration
       if (
-        !TracingProcessor.isScheduleableTask(evt)||
+        !TracingProcessor.isScheduleableTask(evt) ||
         !evt.dur ||
         evt.dur < minimumEvtDur
       ) {
diff --git a/lighthouse-core/gather/gatherers/dobetterweb/domstats.js b/lighthouse-core/gather/gatherers/dobetterweb/domstats.js
index 4c6affc6e..307738342 100644
--- a/lighthouse-core/gather/gatherers/dobetterweb/domstats.js
+++ b/lighthouse-core/gather/gatherers/dobetterweb/domstats.js
@@ -84,7 +84,7 @@ function elementPathInDOM(element) {
  * @return {LH.Artifacts.DOMStats}
  */
 /* istanbul ignore next */
-function getDOMStats(element, deep=true) {
+function getDOMStats(element, deep = true) {
   let deepestNode = null;
   let maxDepth = 0;
   let maxWidth = 0;
@@ -94,7 +94,7 @@ function getDOMStats(element, deep=true) {
    * @param {Element} element
    * @param {number} depth
    */
-  const _calcDOMWidthAndHeight = function(element, depth=1) {
+  const _calcDOMWidthAndHeight = function(element, depth = 1) {
     if (depth > maxDepth) {
       deepestNode = element;
       maxDepth = depth;
diff --git a/lighthouse-core/lib/page-functions.js b/lighthouse-core/lib/page-functions.js
index fea4e6f7c..b759644e2 100644
--- a/lighthouse-core/lib/page-functions.js
+++ b/lighthouse-core/lib/page-functions.js
@@ -111,7 +111,7 @@ function getElementsInDocument(selector) {
  * @return {string}
  */
 /* istanbul ignore next */
-function getOuterHTMLSnippet(element, ignoreAttrs=[]) {
+function getOuterHTMLSnippet(element, ignoreAttrs = []) {
   const clone = element.cloneNode();
 
   ignoreAttrs.forEach(attribute =>{
diff --git a/lighthouse-core/report/html/renderer/details-renderer.js b/lighthouse-core/report/html/renderer/details-renderer.js
index a5cf44b33..22a30af5b 100644
--- a/lighthouse-core/report/html/renderer/details-renderer.js
+++ b/lighthouse-core/report/html/renderer/details-renderer.js
@@ -80,6 +80,8 @@ class DetailsRenderer {
       case 'opportunity':
         // @ts-ignore - TODO(bckenny): Fix type hierarchy
         return this._renderOpportunityTable(details);
+      case 'numeric':
+        return this._renderNumeric(/** @type {StringDetailsJSON} */ (details));
       default: {
         throw new Error(`Unknown type: ${details.type}`);
       }
@@ -181,6 +183,16 @@ class DetailsRenderer {
     return element;
   }
 
+  /**
+   * @param {{value: string}} text
+   * @return {Element}
+   */
+  _renderNumeric(text) {
+    const element = this._dom.createElement('div', 'lh-numeric');
+    element.textContent = text.value;
+    return element;
+  }
+
   /**
    * Create small thumbnail with scaled down image asset.
    * If the supplied details doesn't have an image/* mimeType, then an empty span is returned.
diff --git a/lighthouse-core/report/html/report-styles.css b/lighthouse-core/report/html/report-styles.css
index 0024dd5f8..9ec8323f8 100644
--- a/lighthouse-core/report/html/report-styles.css
+++ b/lighthouse-core/report/html/report-styles.css
@@ -905,7 +905,8 @@
 
 .lh-table-column--bytes,
 .lh-table-column--timespanMs,
-.lh-table-column--ms {
+.lh-table-column--ms,
+.lh-table-column--numeric {
   text-align: right;
 }
 
diff --git a/lighthouse-core/scripts/lantern/run-once.js b/lighthouse-core/scripts/lantern/run-once.js
index 4e3901625..13fb3e3e1 100755
--- a/lighthouse-core/scripts/lantern/run-once.js
+++ b/lighthouse-core/scripts/lantern/run-once.js
@@ -15,9 +15,9 @@ const traceSaver = require('../../../lighthouse-core/lib/lantern-trace-saver');
 if (process.argv.length !== 4) throw new Error('Usage $0 <trace file> <devtools file>');
 
 async function run() {
-  const tracePath = require.resolve(process.argv[2]);
+  const tracePath = path.resolve(process.cwd(), process.argv[2]);
   const traces = {defaultPass: require(tracePath)};
-  const devtoolsLogs = {defaultPass: require(process.argv[3])};
+  const devtoolsLogs = {defaultPass: require(path.resolve(process.cwd(), process.argv[3]))};
   const artifacts = {traces, devtoolsLogs};
 
   const context = {computedCache: new Map()};
diff --git a/lighthouse-logger/index.js b/lighthouse-logger/index.js
index 6ccf1190f..4c6304a59 100644
--- a/lighthouse-logger/index.js
+++ b/lighthouse-logger/index.js
@@ -106,12 +106,12 @@ class Log {
     Log._logToStdErr(`${prefix}:${level || ''}`, [method, snippet]);
   }
 
-  static time({msg, id, args=[]}, level='log') {
+  static time({msg, id, args = []}, level = 'log') {
     marky.mark(id);
     Log[level]('status', msg, ...args);
   }
 
-  static timeEnd({msg, id, args=[]}, level='verbose') {
+  static timeEnd({msg, id, args = []}, level = 'verbose') {
     Log[level]('statusEnd', msg, ...args);
     marky.stop(id);
   }
diff --git a/proto/sample_v2_round_trip.json b/proto/sample_v2_round_trip.json
index 31e0e2521..b45178870 100644
--- a/proto/sample_v2_round_trip.json
+++ b/proto/sample_v2_round_trip.json
@@ -460,7 +460,7 @@
                         "text": "Element"
                     }, 
                     {
-                        "itemType": "text", 
+                        "itemType": "numeric", 
                         "key": "value", 
                         "text": "Value"
                     }


Test patch:
diff --git a/lighthouse-core/test/results/sample_v2.json b/lighthouse-core/test/results/sample_v2.json
index c9c6dd959..fa7f08eb1 100644
--- a/lighthouse-core/test/results/sample_v2.json
+++ b/lighthouse-core/test/results/sample_v2.json
@@ -2182,7 +2182,7 @@
           },
           {
             "key": "value",
-            "itemType": "text",
+            "itemType": "numeric",
             "text": "Value"
           }
         ],