-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
@@ -24,11 +24,11 @@ declare global { | |||
settings?: SettingsJson; | |||
passes?: PassJson[]; | |||
} | |||
|
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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
There was a problem hiding this 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:
lighthouse/lighthouse-core/runner.js
Lines 186 to 187 in 0ab7775
// 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.
lighthouse-core/config/config.js
Outdated
* @param {LH.Flags=} flags | ||
* @return {Partial<LH.Config.Settings>} | ||
*/ | ||
function cleanFlagsForSettings(flags = {}) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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} */ |
There was a problem hiding this comment.
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[]; | |||
} | |||
|
There was a problem hiding this comment.
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
lighthouse-core/config/config.js
Outdated
@@ -246,8 +246,24 @@ function expandArtifacts(artifacts) { | |||
return artifacts; | |||
} | |||
|
|||
/** | |||
* @param {LH.Flags=} flags |
There was a problem hiding this comment.
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?
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 :)