Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(lhr): drop informative/manual, moving them to scoreDisplayMode #5105

Merged
merged 6 commits into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 6 additions & 8 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 @@ -125,7 +128,7 @@ class Audit {
/**
* @param {typeof Audit} audit
* @param {LH.Audit.Product} result
* @return {{score: number, scoreDisplayMode: LH.Audit.ScoringModeValue}}
* @return {{score: number, scoreDisplayMode: LH.Audit.ScoreDisplayMode}}
*/
static _normalizeAuditScore(audit, result) {
// Cast true/false to 1/0
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be enforcing the other things we say we do? Like no score if not binary or numeric display mode?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we're gonna do that in followup

informative = true;
scoreDisplayMode = Audit.SCORING_MODES.NOT_APPLICABLE;
result.rawValue = true;
}

Expand All @@ -181,9 +182,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 @@ -29,7 +29,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 @@ -24,7 +24,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 @@ -17,7 +17,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
Loading