Functions
The package is ESM. Everything below is a named export of safi-studio-scanner.
audit
Crawls from startUrl, runs the selected rules against every page, scores the findings, and resolves to the report object. This is the only function that performs a run; everything else either wraps it or formats its output.
Order of work: fetch robots.txt and sitemap.xml, crawl the pages, render them if a browser or a PageSpeed key was supplied, run the rules, aggregate.
Throws if startUrl is not a valid URL. A page that fails to fetch is still reported, carrying its status and error rather than taking the run down.
auditToHtml
Runs an audit and returns the report as one self-contained HTML document: inline styles, no external requests. Write it to a file, serve it, or attach it to an email.
auditToMarkdown
Runs an audit and returns Markdown: a score summary, then per-category headings with a findings table.
auditScore
Runs an audit and returns only the overall score, 0 to 100. The whole audit still runs, so this is a convenience, not a fast path.
render
Formats a report you already have. Synchronous. Audit once, emit every format:
allRules
Every built-in rule, in registration order. 94 of them.
auditStream
Runs the same audit as audit() and reports progress while it does. The audit starts on the call, not on the first read.
Iterating and .on() can be used together, and both see every event. finalReport() resolves with the same object the audit_complete event carries; awaiting it without iterating runs the audit exactly as audit() would. A failed audit throws from the iterator and rejects finalReport().
See streaming progress for the event list and worked examples.
selectRules
Filters a rule array by category. only is applied first, then skip removes from what is left. This is the same function audit() uses internally, exported so you can preview exactly what a set of options will run.
It is generic over anything with a category, so it filters collectors too.
allCollectors
Every built-in measurement collector. A collector returns numbers rather than verdicts; see the measurement catalog for what each one reports.
value and table
The helpers a collector builds its output with. table applies the row cap (25 by default) and records the true row count, so a renderer can print "showing 25 of 340". See writing a collector.
DEFAULTS
The default option object. Read it rather than hard-coding values, so your code follows the package if a default changes.
Types
Every type is exported as well: AuditOptions, AuditReport, PageReport, CategoryScore, Finding, Rule, RuleResult, RuleContext, PageContext, SiteContext, Format, Status, Severity. See types.