Skip to content

core(fr): add audit mode filter#12649

Merged
devtools-bot merged 6 commits into
masterfrom
fr-audit-mode-filter
Jun 15, 2021
Merged

core(fr): add audit mode filter#12649
devtools-bot merged 6 commits into
masterfrom
fr-audit-mode-filter

Conversation

@adamraine

Copy link
Copy Markdown
Contributor

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

@patrickhulce patrickhulce left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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
Copy Markdown
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

Comment thread types/audit.d.ts Outdated
/** 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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
Collaborator

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

Feels like a solid v9 breaking change to make :)

@patrickhulce patrickhulce left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

Comment thread lighthouse-core/fraggle-rock/config/filters.js Outdated
Co-authored-by: Patrick Hulce <patrick.hulce@gmail.com>
@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