-
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
docs: add plugin guide #8728
docs: add plugin guide #8728
Conversation
docs/plugins.md
Outdated
|
||
Lighthouse plugins are a way to extend the functionality of Lighthouse with insight from domain experts (that's you!) and easily share this extra functionality with other Lighthouse users. At its core, a plugin is a node module that implements a set of checks that will get run by Lighthouse and added to the report as a new category. | ||
|
||
### Do You Need a Custom Audit? |
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.
i dont really understand this section. mostly it feels kinda unnecessary. i have problems with the content too.. so maybe you'll just agree it's not important and we can ignore all that. :)
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.
haha, fair points! My dangling sentence was going to say "consider the criteria for Lighthouse audits when adding your own" (i.e. it's actionable, it's impactful, etc) but if we feel like this is getting too preachy that plugin devs know what they're doing, I understand.
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.
(removed it already but wanted to leave the point here for thought)
- `title: string` **REQUIRED** - The display name of the group in the report. | ||
- `description: string` *OPTIONAL* - A more detailed description of the group's purpose. | ||
|
||
### Plugin Audits |
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.
i like calling these "plugin audits" rather than custom audits. :) seems good!
@@ -73,5 +73,6 @@ lighthouse.getAuditList = Runner.getAuditList; | |||
lighthouse.traceCategories = require('./gather/driver').traceCategories; | |||
lighthouse.Audit = require('./audits/audit'); | |||
lighthouse.Gatherer = require('./gather/gatherers/gatherer'); | |||
lighthouse.NetworkRecords = require('./computed/network-records.js'); |
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.
Wanted to call this change out as the only real functionality change, but fairly large impact on our public API :)
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.
hmm, I don't really have a problem with this one in particular, but this won't work if/when we end up exposing more and more computed artifacts. Do we need a namespace for them? Just point folks at the directory?
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.
yeah at that point I think we should restructure a lot of our exports and expose some aliases so folks can require('lighthouse/types')
require('lighthouse/computed')
etc and we're free to move around files as we wish
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.
lots of ways for these docs to evolve, but i'm happy for this as a start.
I'll take a stab tonight or in the morning, but looking great so far |
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.
this is looking good. Some change suggestions
@@ -73,5 +73,6 @@ lighthouse.getAuditList = Runner.getAuditList; | |||
lighthouse.traceCategories = require('./gather/driver').traceCategories; | |||
lighthouse.Audit = require('./audits/audit'); | |||
lighthouse.Gatherer = require('./gather/gatherers/gatherer'); | |||
lighthouse.NetworkRecords = require('./computed/network-records.js'); |
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.
hmm, I don't really have a problem with this one in particular, but this won't work if/when we end up exposing more and more computed artifacts. Do we need a namespace for them? Just point folks at the directory?
docs/plugins.md
Outdated
| ------------------------------------ | ------ | ------------- | | ||
| Add custom audits | ✅ | ✅ | | ||
| Add custom categories | ✅ | ✅ | | ||
| Easily sharable via NPM | ✅ | ❌ | |
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.
you'd just need an absolute path to the config in an npm module, but sure :)
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.
yeah sharable via NPM felt slightly off, what I want to get at here is that custom configs aren't sustainably sharable. you can only ever use one, they can't extend each other, etc. plugins are the real sharable way to offer bits of lighthouse logic.
better name/phrase to capture that complex thought? :)
Co-Authored-By: patrickhulce <patrick.hulce@gmail.com>
Co-Authored-By: patrickhulce <patrick.hulce@gmail.com>
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.
should we add a section like eslint does with recommended npm keywords? https://eslint.org/docs/developer-guide/working-with-plugins#share-plugins
This is really good :) Added some more suggestions, but I think this is good to go
|
||
- `title: string` **REQUIRED** - The display name of the plugin's category in the report. | ||
- `description: string` _OPTIONAL_ - A more detailed description of the category's purpose. | ||
- `manualDescription: string` _OPTIONAL_ - A more detailed description of all of the manual audits in a plugin. Only use this if you've added manual audits. |
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.
ha, I half feel like we shouldn't even mention this... ("what's a manual audit?")
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.
Heh, yeah I don't think we should encourage them for sure :) but feels like we should at least document what it is
docs/plugins.md
Outdated
|
||
It is an object whose keys are the group IDs and whose values are objects with the following properties: | ||
|
||
- `title: string` **REQUIRED** - The display name of the group in the report. |
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 put these above the screenshots? I forgot we were still talking about groups by the time I passed the images :)
> Images need alt attributes. | ||
|
||
> 4.8.4.4 Requirements for providing text to act as an alternative for images | ||
> Except where otherwise specified, the alt attribute.... 10,000 words later... and that is everything you need to know about the `alt` attribute! |
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.
😆
Co-Authored-By: patrickhulce <patrick.hulce@gmail.com>
Summary
Well this took much longer than expected :)
In a google doc it turned out to be ~15 pages though so that makes a little more sense and I hope it's fairly comprehensive 😆
Only one functionality change (fairly big): Exposes our NetworkRecords computed artifact on the public
Audit
interface