Skip to content

Commit

Permalink
feat: add scoringMode to AuditResult (#1967)
Browse files Browse the repository at this point in the history
* feat: add scoringMode to AuditResult

* switch to enum-style

* caps-ify
  • Loading branch information
patrickhulce authored and ebidel committed Apr 5, 2017
1 parent 907d21a commit 17046b3
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lighthouse-cli/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface AuditFullResult {
displayValue: string;
debugString?: string;
score: boolean|number;
scoringMode: string;
error?: boolean;
description: string;
name: string;
Expand Down
11 changes: 11 additions & 0 deletions lighthouse-core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ class Audit {
return DEFAULT_PASS;
}

/**
* @return {{NUMERIC: string, BINARY: string}}
*/
static get SCORING_MODES() {
return {
NUMERIC: 'numeric',
BINARY: 'binary',
};
}

/**
* @throws {Error}
*/
Expand Down Expand Up @@ -75,6 +85,7 @@ class Audit {
debugString: result.debugString,
optimalValue: result.optimalValue,
extendedInfo: result.extendedInfo,
scoringMode: audit.meta.scoringMode || Audit.SCORING_MODES.BINARY,
informative: audit.meta.informative,
name: audit.meta.name,
category: audit.meta.category,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TotalByteWeight extends Audit {
'Network transfer size [costs users real dollars](https://whatdoesmysitecost.com/) ' +
'and is [highly correlated](http://httparchive.org/interesting.php#onLoad) with long load times. ' +
'Try to find ways to reduce the size of required files.',
scoringMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['networkRecords']
};
}
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/dobetterweb/dom-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class DOMSize extends Audit {
'children/parent element. A large DOM can increase memory, cause longer ' +
'[style calculations](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), ' +
'and produce costly [layout reflows](https://developers.google.com/speed/articles/reflow). [Learn more](https://developers.google.com/web/fundamentals/performance/rendering/).',
scoringMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['DOMStats']
};
}
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/estimated-input-latency.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class EstimatedInputLatency extends Audit {
'of latency, or less. 10% of the time a user can expect additional latency. If your ' +
'score is higher than Lighthouse\'s target score, users may perceive your app as ' +
'laggy. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/estimated-input-latency).',
scoringMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces']
};
}
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/first-meaningful-paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class FirstMeaningfulPaint extends Audit {
optimalValue: SCORING_POINT_OF_DIMINISHING_RETURNS.toLocaleString() + 'ms',
helpText: 'First meaningful paint measures when the primary content of a page is visible. ' +
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/first-meaningful-paint).',
scoringMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces']
};
}
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/speed-index-metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SpeedIndexMetric extends Audit {
helpText: 'Speed Index shows how quickly the contents of a page are visibly populated. ' +
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/speed-index).',
optimalValue: SCORING_POINT_OF_DIMINISHING_RETURNS.toLocaleString(),
scoringMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces']
};
}
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/audits/time-to-interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class TTIMetric extends Audit {
'enough to interact with. ' +
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/time-to-interactive).',
optimalValue: SCORING_TARGET.toLocaleString() + 'ms',
scoringMode: Audit.SCORING_MODES.NUMERIC,
requiredArtifacts: ['traces']
};
}
Expand Down
3 changes: 3 additions & 0 deletions lighthouse-core/closure/typedefs/AuditResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ function AuditFullResult() {}
/** @type {(boolean|number)} */
AuditFullResult.prototype.score;

/** @type {string} */
AuditFullResult.prototype.scoringMode;

/** @type {string} */
AuditFullResult.prototype.displayValue;

Expand Down

0 comments on commit 17046b3

Please sign in to comment.