lighthouse

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package lighthouse provides Lighthouse audit runners and score-to-issue conversion.

Index

Constants

View Source
const (
	// PerfCriticalThreshold is the performance score below which an issue is critical.
	PerfCriticalThreshold = 50
	// PerfWarningThreshold is the performance score below which an issue is a warning.
	PerfWarningThreshold = 90
	// AccessibilityWarningThreshold is the accessibility score below which an issue is a warning.
	AccessibilityWarningThreshold = 90
	// SEOWarningThreshold is the SEO score below which an issue is a warning.
	SEOWarningThreshold = 90
)

Score thresholds for converting Lighthouse scores to issues.

View Source
const (
	CheckPerformance   = "lighthouse/performance"
	CheckAccessibility = "lighthouse/accessibility"
	CheckSEO           = "lighthouse/seo"
)

Check name constants.

View Source
const (
	// PSIEndpoint is the PageSpeed Insights API URL.
	PSIEndpoint = "https://www.googleapis.com/pagespeedonline/v5/runPagespeed"
	// PSITimeout is the per-request timeout for PSI calls.
	PSITimeout = 60 * time.Second
)

PSI API constants.

Variables

This section is empty.

Functions

func ScoreToIssues

func ScoreToIssues(result *model.LighthouseResult) []model.Issue

ScoreToIssues converts a LighthouseResult into issues based on score thresholds.

Types

type BrowserlessClient

type BrowserlessClient struct {
	// contains filtered or unexported fields
}

BrowserlessClient runs Lighthouse audits via a browserless container.

func NewBrowserlessClient

func NewBrowserlessClient(browserlessURL string, l logger.Logger) *BrowserlessClient

NewBrowserlessClient creates a new browserless client.

func (*BrowserlessClient) Run

func (c *BrowserlessClient) Run(ctx context.Context, targetURL string) (*model.LighthouseResult, error)

Run executes a Lighthouse audit via browserless and returns the result.

type PSIClient

type PSIClient struct {
	// contains filtered or unexported fields
}

PSIClient calls the PageSpeed Insights API.

func NewPSIClient

func NewPSIClient(apiKey, strategy string, l logger.Logger) *PSIClient

NewPSIClient creates a PSI client with appropriate rate limiting.

func (*PSIClient) RateLimit

func (c *PSIClient) RateLimit() *rate.Limiter

RateLimit returns the current rate limiter for testing inspection.

func (*PSIClient) Run

func (c *PSIClient) Run(ctx context.Context, targetURL string) (*model.LighthouseResult, error)

Run executes a Lighthouse audit via the PSI API and returns the result.

type Runner

type Runner interface {
	Run(ctx context.Context, url string) (*model.LighthouseResult, error)
}

Runner runs Lighthouse audits against a URL.

func NewRunner

func NewRunner(cfg *config.Config, l logger.Logger) (Runner, error)

NewRunner creates the appropriate lighthouse Runner based on config.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL