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(lhr): lhr-lite type declaration #4983

Merged
merged 6 commits into from
Apr 23, 2018
Merged

core(lhr): lhr-lite type declaration #4983

merged 6 commits into from
Apr 23, 2018

Conversation

brendankenny
Copy link
Member

ready for feedback on design/implementation of the design :)

* 'notApplicable': the audit turned out to not apply to the page. Ignore the score.
* 'manual': The audit exists only to tell you to review something yourself. Ignore the score.
*/
scoreDisplayMode: 'binary' | 'numeric' | 'informative' | 'notApplicable' | 'manual';
Copy link
Member Author

Choose a reason for hiding this comment

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

should we have an 'error' scoreDisplayMode? That brings us (basically) back to a boolean and a string, which isn't ideal, but it also makes sense as it affects interpretation of the score in the same way that 'informative' 'notApplicable', and 'manual' do (you should ignore whatever is in score) and you won't have to look in multiple places to see how you should interpret score (like you do currently)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like it 👍

wastedMs: number
wastedBytes?: number
headings: AuditColumnHeading[];
rows: AuditTableRow[];
Copy link
Member

Choose a reason for hiding this comment

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

renaming items to rows, eh? :)

I prefer items personally because it doesn't imply these table semantics. Table-ness is a visual/report thing, which i don't think is relevant to most consumers of the LHR

Copy link
Member Author

Choose a reason for hiding this comment

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

renaming items to rows, eh? :)

hehe, caught me. I can switch back, but "headings" doesn't really make sense without some matrix/table-ness structure imposed on the data anyways

valueType: 'url' | 'text' | 'link' | 'timespanMs';
}

export type AuditTableRow = WastedBytesDetailsRow | WastedTimeDetailsRow;
Copy link
Member

Choose a reason for hiding this comment

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

can u inline this into the two uses above?

export interface AuditOpportunityDetails {
type: 'opportunity';
wastedMs: number
wastedBytes?: number
Copy link
Member Author

Choose a reason for hiding this comment

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

should we rename these totalWastedMs/totalWastedBytes? To make it clear what they are

Copy link
Member

Choose a reason for hiding this comment

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

Crazy idea. since these are opportunities, we could stay on the optimistic side.. something like.. "estimatedSavingsMs" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

estimatedSavingsMs

I'm on board with that @patrickhulce

/** An object containing the top-level categories, their overall scores, and reference to member audits. */
categories?: Record<string, ResultLite.Category>;
/** Descriptions of the audit groups referenced by AuditRefs. */
categoryGroups?: Record<string, ResultLite.CategoryGroup>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did we decide of groups for this? I don't remember at this point 😆 or auditGroups aka "groups of related audits"

/** The version of Lighthouse with which these results were generated. */
lighthouseVersion: string;
/** An object containing the results of the audits. */
audits: Record<string, ResultLite.Audit>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

since we don't have any references to what auditId really is how do you feel about aliases like type AuditId = string?

* 'notApplicable': the audit turned out to not apply to the page. Ignore the score.
* 'manual': The audit exists only to tell you to review something yourself. Ignore the score.
*/
scoreDisplayMode: 'binary' | 'numeric' | 'informative' | 'notApplicable' | 'manual';
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like it 👍

export interface AuditColumnHeading {
key: string;
label: string;
valueType: 'url' | 'text' | 'link' | 'timespanMs';
Copy link
Collaborator

Choose a reason for hiding this comment

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

also have bytes and duration

Copy link
Member Author

Choose a reason for hiding this comment

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

duration -> timespanMs I thought? Also do we actually have text or links if it's just WastedBytesDetailsItem or WastedTimeDetailsItem?

}

export interface AuditTableDetails {
type: 'table';
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we actually have any of these that we want to expose? seems like we're only wanting to expose the opportunities which all use the table headings/rows types

@brendankenny
Copy link
Member Author

oh yeah, a big one is explanation. Currently it's on details...should it just be on the audit result?

/** An object containing the results of the audits. */
audits: Record<string, ResultLite.Audit>;
/** An object containing the top-level categories, their overall scores, and reference to member audits. */
categories?: Record<string, ResultLite.Category>;
Copy link
Member Author

Choose a reason for hiding this comment

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

should be required, even if an empty object (API responses should always have categories, so no need to make people jump through hoops checking for categories existence every time)

@brendankenny
Copy link
Member Author

I think the last decision is categoryGroups/groups/auditGroups/etc? (I believe with the split on where the groups should live we decided on the status quo of leaving at the top level).

Any thoughts on that and last changes before I commit us to this? :)

@patrickhulce
Copy link
Collaborator

I think the last decision is categoryGroups/groups/auditGroups/etc? (I believe with the split on where the groups should live we decided on the status quo of leaving at the top level).
Any thoughts on that and last changes before I commit us to this? :)

Aw shoot sorry I forgot to submit my review!! Yes I have a thought. Do we even need these in LHR lite?
I realized they're a display-only concern and my favorite names for them are just groups/displayGroups. Seems like we can punt from LHR lite but maybe I'm missing something?

@brendankenny
Copy link
Member Author

if it were groups vs displayGroups I'd tip slightly toward displayGroups.

I can't remember exactly why we added them to LHR-lite but I believe @paulirish thought it would be desired by consumers/trivial to add.

@paulirish
Copy link
Member

okay i'm on board with leaving groups out of LHR-lite. we're not 100% on them and there's not a high priority reason to include them. (i think i started with "hey, might as well.")

  • metrics & opps are already distinguishable from details.type.
  • and manual audits are also distinguishable.
  • so that just leaves the grouping within a11y and seo.

The only one there that could be useful is seo-mobile, our mobile friendly group. but.. eh.

k let's boot groups.

@patrickhulce
Copy link
Collaborator

cool cool +1 to brendan's fav for displayGroups and displayGroupId for our real LHR :)

@brendankenny brendankenny changed the title [WIP] core(lhr): lhr-lite proposed types core(lhr): lhr-lite type declaration Apr 20, 2018
@brendankenny
Copy link
Member Author

ready for final 🎖 💯

@vinamratasingal FYI on API return value

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.

I think this is great! I left 😬 everywhere I have a sinking feeling I'll regret that in ~6 months, but IMO this could ship today and I'm 👍

/** The overall score of the category, the weighted average of all its audits. */
score: number;
/** An array of references to all the audit members of this category. */
auditRefs: AuditRef[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

😬

/** An array of references to all the audit members of this category. */
auditRefs: AuditRef[];
/** An optional description for manual audits within this category. */
manualDescription?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

😬

/** A more detailed description that describes why the audit is important and links to Lighthouse documentation on the audit; markdown links supported. */
description: string;
/** The scored value determined by the audit, in the range `0-1`, or null if `scoreDisplayMode` indicates not scored. */
score: number | null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

FWIW I'd prefer score?: number

export interface MetricDetails {
type: 'metric';
/** The value of the metric expressed in milliseconds. */
timespanMs?: number;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm still 😬, but I think we mostly exhausted options. last-ditch effort anyone like ms timeMs timingMs more?

Copy link
Member

Choose a reason for hiding this comment

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

i consider timespanMs/ms/timingMs to be equally 😬 and i'd be fine with any of those.

@paulirish paulirish mentioned this pull request Apr 20, 2018
82 tasks
@brendankenny
Copy link
Member Author

@paulirish up to you now

@brendankenny brendankenny merged commit cf76f05 into master Apr 23, 2018
@brendankenny brendankenny deleted the lhrliteproposal branch April 23, 2018 18:39
kdzwinel pushed a commit to kdzwinel/lighthouse that referenced this pull request Aug 16, 2018
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