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(config): clean flags for settings #4960

Merged
merged 2 commits into from
Apr 13, 2018
Merged

Conversation

patrickhulce
Copy link
Collaborator

alternative to #4958

this brings back -A, it didn't come out quite as clean as I had hoped, but it is typesafe which is kinda nice :)

@@ -24,11 +24,11 @@ declare global {
settings?: SettingsJson;
passes?: PassJson[];
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

someone's got a diff trailing space editor setting it seems :)

Copy link
Member

Choose a reason for hiding this comment

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

ah, damn, eslint isn't checking .ts files, obvs. I'll find the setting :P

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

an alternative to this approach would be to JSON.parse(JSON.strigify(settings)) each of them before here:

// TODO(phulce): allow change of throttling method to `simulate`
if (!isDeepEqual(normalizedGatherSettings, normalizedAuditSettings)) {

wdyt about that instead? seems like an option, though I don't feel so strongly about it.

* @param {LH.Flags=} flags
* @return {Partial<LH.Config.Settings>}
*/
function cleanFlagsForSettings(flags = {}) {
Copy link
Member

Choose a reason for hiding this comment

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

semantically this is removedUndefinedProperties right?

could we call it that instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure I'm following you, this is looking at what properties are not on constants.defaultSettings and dropping them from flags regardless of their value.

the JSON.parse(JSON.stringify()) approach would address the specific undefined yargs case but not an underlying problem that having miscellaneous junk present that isn't part of settings throws off our isDeepEqual later

Copy link
Member

Choose a reason for hiding this comment

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

oh got it.

what properties are not on constants.defaultSettings

ahhh.. mmhmmm.

k lgtm

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -26,10 +26,24 @@ const throttling = {
},
};

/** @type {LH.Config.Settings} */
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -24,11 +24,11 @@ declare global {
settings?: SettingsJson;
passes?: PassJson[];
}

Copy link
Member

Choose a reason for hiding this comment

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

ah, damn, eslint isn't checking .ts files, obvs. I'll find the setting :P

@@ -246,8 +246,24 @@ function expandArtifacts(artifacts) {
return artifacts;
}

/**
* @param {LH.Flags=} flags
Copy link
Member

Choose a reason for hiding this comment

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

maybe add a function description that this is dropping any flag not found on settings?

@brendankenny brendankenny merged commit 6d6af51 into master Apr 13, 2018
@brendankenny brendankenny deleted the cleaner_config_settings branch April 13, 2018 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants