Skip to content

Commit

Permalink
core(scoreDisplayMode): use scoreDisplayMode, no more informative/manual
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed May 3, 2018
1 parent a3737fe commit 1ec13a4
Show file tree
Hide file tree
Showing 36 changed files with 107 additions and 229 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,22 @@ module.exports = [
score: 0,
},
'aria-valid-attr': {
notApplicable: true,
scoreDisplayMode: 'not-applicable',
},
'aria-allowed-attr': {
notApplicable: true,
scoreDisplayMode: 'not-applicable',
},
'color-contrast': {
score: 1,
},
'image-alt': {
notApplicable: true,
scoreDisplayMode: 'not-applicable',
},
'label': {
notApplicable: true,
scoreDisplayMode: 'not-applicable',
},
'tabindex': {
notApplicable: true,
scoreDisplayMode: 'not-applicable',
},
'content-width': {
score: 1,
Expand Down Expand Up @@ -144,10 +144,10 @@ module.exports = [
score: 0,
},
'aria-valid-attr': {
notApplicable: true,
scoreDisplayMode: 'not-applicable',
},
'aria-allowed-attr': {
notApplicable: true,
scoreDisplayMode: 'not-applicable',
},
'color-contrast': {
score: 1,
Expand All @@ -156,10 +156,10 @@ module.exports = [
score: 0,
},
'label': {
notApplicable: true,
scoreDisplayMode: 'not-applicable',
},
'tabindex': {
notApplicable: true,
scoreDisplayMode: 'not-applicable',
},
'content-width': {
score: 1,
Expand Down
12 changes: 6 additions & 6 deletions lighthouse-cli/test/smokehouse/pwa-expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ module.exports = [
// "manual" audits. Just verify in the results.
'pwa-cross-browser': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
'pwa-page-transitions': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
'pwa-each-page-has-url': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
},
},
Expand Down Expand Up @@ -207,15 +207,15 @@ module.exports = [
// "manual" audits. Just verify in the results.
'pwa-cross-browser': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
'pwa-page-transitions': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
'pwa-each-page-has-url': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions lighthouse-cli/test/smokehouse/pwa2-expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ module.exports = [
// "manual" audits. Just verify in the results.
'pwa-cross-browser': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
'pwa-page-transitions': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
'pwa-each-page-has-url': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
},
},
Expand Down Expand Up @@ -215,15 +215,15 @@ module.exports = [
// "manual" audits. Just verify in the results.
'pwa-cross-browser': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
'pwa-page-transitions': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
'pwa-each-page-has-url': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions lighthouse-cli/test/smokehouse/pwa3-expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ module.exports = [
// "manual" audits. Just verify in the results.
'pwa-cross-browser': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
'pwa-page-transitions': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
'pwa-each-page-has-url': {
score: 0,
manual: true,
scoreDisplayMode: 'manual',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-cli/test/smokehouse/seo/expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = [
},
'robots-txt': {
rawValue: true,
notApplicable: true,
scoreDisplayMode: 'not-applicable',
},
},
},
Expand Down
12 changes: 5 additions & 7 deletions lighthouse-core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ class Audit {
}

/**
* @return {LH.Audit.ScoringModes}
* @return {LH.Audit.ScoreDisplayModes}
*/
static get SCORING_MODES() {
return {
NUMERIC: 'numeric',
BINARY: 'binary',
MANUAL: 'manual',
INFORMATIVE: 'informative',
NOT_APPLICABLE: 'not-applicable',
};
}

Expand Down Expand Up @@ -155,14 +158,12 @@ class Audit {
throw new Error('generateAuditResult requires a rawValue');
}

// eslint-disable-next-line prefer-const
let {score, scoreDisplayMode} = Audit._normalizeAuditScore(audit, result);

// If the audit was determined to not apply to the page, we'll reset it as informative only
let informative = audit.meta.informative;
if (result.notApplicable) {
score = 1;
informative = true;
scoreDisplayMode = Audit.SCORING_MODES.NOT_APPLICABLE;
result.rawValue = true;
}

Expand All @@ -183,9 +184,6 @@ class Audit {
debugString: result.debugString,
extendedInfo: result.extendedInfo,
scoreDisplayMode,
informative,
manual: audit.meta.manual,
notApplicable: result.notApplicable,
name: audit.meta.name,
description: auditDescription,
helpText: audit.meta.helpText,
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/audits/byte-efficiency/offscreen-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class OffscreenImages extends ByteEfficiencyAudit {
return {
name: 'offscreen-images',
description: 'Defer offscreen images',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText:
'Consider lazy-loading offscreen and hidden images after all critical resources have ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class RenderBlockingResources extends Audit {
return {
name: 'render-blocking-resources',
description: 'Eliminate render-blocking resources',
informative: true,
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
helpText:
'Resources are blocking the first paint of your page. Consider ' +
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/audits/byte-efficiency/unminified-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class UnminifiedCSS extends ByteEfficiencyAudit {
return {
name: 'unminified-css',
description: 'Minify CSS',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Minifying CSS files can reduce network payload sizes. ' +
'[Learn more](https://developers.google.com/speed/docs/insights/MinifyResources).',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class UnminifiedJavaScript extends ByteEfficiencyAudit {
return {
name: 'unminified-javascript',
description: 'Minify JavaScript',
informative: true,

scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Minifying JavaScript files can reduce payload sizes and script parse time. ' +
'[Learn more](https://developers.google.com/speed/docs/insights/MinifyResources).',
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/audits/byte-efficiency/unused-css-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class UnusedCSSRules extends ByteEfficiencyAudit {
return {
name: 'unused-css-rules',
description: 'Unused CSS rules',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Remove unused rules from stylesheets to reduce unnecessary ' +
'bytes consumed by network activity. ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
return {
name: 'unused-javascript',
description: 'Unused JavaScript',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Remove unused JavaScript to reduce bytes consumed by network activity.',
requiredArtifacts: ['JsUsage', 'devtoolsLogs'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class UsesOptimizedImages extends ByteEfficiencyAudit {
return {
name: 'uses-optimized-images',
description: 'Efficiently encode images',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Optimized images load faster and consume less cellular data. ' +
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/optimize-images).',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class UsesResponsiveImages extends ByteEfficiencyAudit {
return {
name: 'uses-responsive-images',
description: 'Properly size images',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText:
'Serve images that are appropriately-sized to save cellular data ' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class ResponsesAreCompressed extends ByteEfficiencyAudit {
static get meta() {
return {
name: 'uses-text-compression',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
description: 'Enable text compression',
helpText: 'Text-based responses should be served with compression (gzip, deflate or brotli)' +
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/audits/byte-efficiency/uses-webp-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class UsesWebPImages extends ByteEfficiencyAudit {
return {
name: 'uses-webp-images',
description: 'Serve images in next-gen formats',
informative: true,
scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
helpText: 'Image formats like JPEG 2000, JPEG XR, and WebP often provide better ' +
'compression than PNG or JPEG, which means faster downloads and less data consumption. ' +
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/critical-request-chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CriticalRequestChains extends Audit {
return {
name: 'critical-request-chains',
description: 'Critical Request Chains',
informative: true,
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
helpText: 'The Critical Request Chains below show you what resources are ' +
'issued with a high priority. Consider reducing ' +
'the length of chains, reducing the download size of resources, or ' +
Expand Down
5 changes: 2 additions & 3 deletions lighthouse-core/audits/manual/manual-audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ const Audit = require('../audit');

class ManualAudit extends Audit {
/**
* @return {Pick<LH.Audit.Meta, 'informative'|'manual'|'requiredArtifacts'>}
* @return {Pick<LH.Audit.Meta, 'scoreDisplayMode'|'requiredArtifacts'>}
*/
static get partialMeta() {
return {
informative: true,
manual: true,
scoreDisplayMode: Audit.SCORING_MODES.MANUAL,
requiredArtifacts: [],
};
}
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Metrics extends Audit {
static get meta() {
return {
name: 'metrics',
informative: true,
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
description: 'Metrics',
helpText: 'Collects all available metrics.',
requiredArtifacts: ['traces', 'devtoolsLogs'],
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/audits/mixed-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class MixedContent extends Audit {
return {
name: 'mixed-content',
description: 'All resources loaded are secure',
informative: true,
failureDescription: 'Some insecure resources can be upgraded to HTTPS',
helpText: `Mixed content warnings can prevent you from upgrading to HTTPS.
This audit shows which insecure resources this page uses that can be
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/network-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NetworkRequests extends Audit {
static get meta() {
return {
name: 'network-requests',
informative: true,
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
description: 'Network Requests',
helpText: 'Lists the network requests that were made during page load.',
requiredArtifacts: ['devtoolsLogs'],
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/screenshot-thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ScreenshotThumbnails extends Audit {
static get meta() {
return {
name: 'screenshot-thumbnails',
informative: true,
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
description: 'Screenshot Thumbnails',
helpText: 'This is what the load of your site looked like.',
requiredArtifacts: ['traces', 'devtoolsLogs'],
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/audits/time-to-first-byte.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class TTFBMetric extends Audit {
return {
name: 'time-to-first-byte',
description: 'Keep server response times low (TTFB)',
informative: true,
helpText: 'Time To First Byte identifies the time at which your server sends a response.' +
' [Learn more](https://developers.google.com/web/tools/chrome-devtools/network-performance/issues).',
requiredArtifacts: ['devtoolsLogs', 'URL'],
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/user-timings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class UserTimings extends Audit {
static get meta() {
return {
name: 'user-timings',
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
description: 'User Timing marks and measures',
helpText: 'Consider instrumenting your app with the User Timing API to create custom, ' +
'real-world measurements of key user experiences. ' +
'[Learn more](https://developers.google.com/web/tools/lighthouse/audits/user-timing).',
requiredArtifacts: ['traces'],
informative: true,
};
}

Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/audits/uses-rel-preconnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class UsesRelPreconnectAudit extends Audit {
return {
name: 'uses-rel-preconnect',
description: 'Avoid multiple, costly round trips to any origin',
informative: true,
helpText:
'Consider adding preconnect or dns-prefetch resource hints to establish early ' +
`connections to important third-party origins. [Learn more](https://developers.google.com/web/fundamentals/performance/resource-prioritization#preconnect).`,
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/audits/uses-rel-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class UsesRelPreloadAudit extends Audit {
return {
name: 'uses-rel-preload',
description: 'Preload key requests',
informative: true,
helpText: 'Consider using <link rel=preload> to prioritize fetching late-discovered ' +
'resources sooner. [Learn more](https://developers.google.com/web/updates/2016/03/link-rel-preload).',
requiredArtifacts: ['devtoolsLogs', 'traces', 'URL'],
Expand Down
3 changes: 1 addition & 2 deletions lighthouse-core/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ function assertValidAudit(auditDefinition, auditPath) {

// If it'll have a ✔ or ✖ displayed alongside the result, it should have failureDescription
if (typeof auditDefinition.meta.failureDescription !== 'string' &&
auditDefinition.meta.informative !== true &&
auditDefinition.meta.scoreDisplayMode !== Audit.SCORING_MODES.NUMERIC) {
auditDefinition.meta.scoreDisplayMode === Audit.SCORING_MODES.BINARY) {
throw new Error(`${auditName} has no failureDescription and should.`);
}

Expand Down
Loading

0 comments on commit 1ec13a4

Please sign in to comment.