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(tsc): type check config files #5858

Merged
merged 1 commit into from
Aug 20, 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
5 changes: 4 additions & 1 deletion lighthouse-core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const UIStrings = {

const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);

module.exports = {
/** @type {LH.Config.Json} */
const defaultConfig = {
settings: constants.defaultSettings,
passes: [{
passName: 'defaultPass',
Expand Down Expand Up @@ -445,3 +446,5 @@ Object.defineProperty(module.exports, 'UIStrings', {
enumerable: false,
get: () => UIStrings,
});

module.exports = defaultConfig;
6 changes: 5 additions & 1 deletion lighthouse-core/config/full-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/
'use strict';

module.exports = {
/** @type {LH.Config.Json} */
const fullConfig = {
extends: 'lighthouse:default',
settings: {},
passes: [
Expand All @@ -19,6 +20,7 @@ module.exports = {
audits: [
'byte-efficiency/unused-javascript',
],
// @ts-ignore TODO(bckenny): type extended Config where e.g. category.title isn't required
Copy link
Member Author

Choose a reason for hiding this comment

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

If a config is extending another one, there's no reason for it to have anything in particular defined, so maybe these could be RecursivePartial<LH.Config.Json>, but we don't want to apply that to e.g. defaultConfig. So we'll have to figure out a good way to conditionally apply it another day.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we have to split the full config typedef from the valid config typedef?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe we have to split the full config typedef from the valid config typedef?

yeah, that seems like that might be the only decent way to do it without making the full config typedef useless

categories: {
'performance': {
auditRefs: [
Expand All @@ -27,3 +29,5 @@ module.exports = {
},
},
};

module.exports = fullConfig;
5 changes: 4 additions & 1 deletion lighthouse-core/config/mixed-content-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/
'use strict';

module.exports = {
/** @type {LH.Config.Json} */
const mixedContentConfig = {
// This performs two passes:
// (1) Gather the default resources requested by the page, and
// (2) Re-load page but attempt to upgrade each request to HTTPS.
Expand Down Expand Up @@ -35,3 +36,5 @@ module.exports = {
},
},
};

module.exports = mixedContentConfig;
5 changes: 4 additions & 1 deletion lighthouse-core/config/perf-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
*/
'use strict';

module.exports = {
/** @type {LH.Config.Json} */
const perfConfig = {
extends: 'lighthouse:default',
settings: {
throttlingMethod: 'devtools',
onlyCategories: ['performance'],
},
};

module.exports = perfConfig;
5 changes: 4 additions & 1 deletion lighthouse-core/config/plots-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/
'use strict';

module.exports = {
/** @type {LH.Config.Json} */
const plotsConfig = {
extends: 'lighthouse:default',
settings: {
onlyAudits: [
Expand All @@ -17,3 +18,5 @@ module.exports = {
],
},
};

module.exports = plotsConfig;
5 changes: 3 additions & 2 deletions typings/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ declare global {

export interface CategoryJson {
title: string;
description: string;
auditRefs: AuditRefJson[];
description?: string;
manualDescription?: string;
}

export interface GroupJson {
title: string;
description: string;
description?: string;
}

export type AuditJson = {
Expand Down