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(fr): add audit mode filter #12649

Merged
merged 6 commits into from
Jun 15, 2021
Merged

core(fr): add audit mode filter #12649

merged 6 commits into from
Jun 15, 2021

Conversation

adamraine
Copy link
Member

Implementation of our ideas in #12595 (comment)

This feels good to me, but I would be receptive to making applicableModes required for two reasons:

  • It's more explicit about when the audit will be run.
  • It would be helpful to throw an error if the available artifacts don't meet our expectations, instead of silently skipping any audits that have a missing artifact.

@adamraine adamraine requested a review from a team as a code owner June 10, 2021 20:55
@adamraine adamraine requested review from patrickhulce and removed request for a team June 10, 2021 20:55
@google-cla google-cla bot added the cla: yes label Jun 10, 2021
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

nice work!

* @return {LH.Config.FRConfig['audits']}
*/
function filterAuditsByAvailableArtifacts(audits, availableArtifacts) {
function filterAudits(audits, availableArtifacts, mode) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

separate function filterAuditsByGatherMode? the BySomeVerboseSingleThing was intentional for clarity :)

My lessons from the way config evolved the past 5 years and how important these files are was to be as excessively clear as possible in v2 ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried filterAuditsByGatherModeAndAvailableArtifacts but that was too long. I'm ok excluding one of the filters from the name if you are though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that I think about it filterAuditsByAvailableArtifacts makes more sense because we will filtering by artifacts most of the time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

WDYT about two functions?

filterAuditsByAvailableArtifacts
filterAuditsByGatherMode

filterCategories invokes both of them in sequence

types/audit.d.ts Outdated
@@ -57,6 +57,8 @@ declare global {
__internalOptionalArtifacts?: Array<keyof Artifacts>;
/** A string identifying how the score should be interpreted for display. */
scoreDisplayMode?: Audit.ScoreDisplayMode;
/** A list of gather modes that this audit is applicable to. */
applicableModes?: Gatherer.GatherMode[],
Copy link
Collaborator

Choose a reason for hiding this comment

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

WDYT about matching supportedModes? was the use of applicable instead an intentional differentiator?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was different intentionally to avoid mismatch with gatherers. supportedModes does make sense though so I'm fine going back.

@patrickhulce
Copy link
Collaborator

I would be receptive to making applicableModes required for two reasons:

Feels like a solid v9 breaking change to make :)

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM!

lighthouse-core/fraggle-rock/config/filters.js Outdated Show resolved Hide resolved
@devtools-bot devtools-bot merged commit 8cd6821 into master Jun 15, 2021
@devtools-bot devtools-bot deleted the fr-audit-mode-filter branch June 15, 2021 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants