astro-post-auditv0.10.0

CASOON Open Source

Audit what you actually ship.

astro-post-audit runs after every astro build and checks the finished dist/ output: SEO signals, broken internal links and lightweight WCAG heuristics. Static analysis in a Rust binary, no browser, no network calls unless you enable external link checks.

npm i -D @casoon/astro-post-audit
pnpm add -D @casoon/astro-post-audit
yarn add -D @casoon/astro-post-audit
MITnpm 0.10.0Astro 5, 6, 7Node 18+
Terminal, excerpt of the real report astro-post-audit prints after the build for the test fixture tests/fixtures/bad: Errors 14, Warnings 7, Info 4, Files 1. Top issue rules: landmarks/content-outside 4 times, links/broken 3 times, buttons/name-missing, canonical/missing and document/lang-missing once each. Then the first two findings for index.html: a missing canonical tag, with the remedy to set site in astro.config.mjs and render a canonical link in the BaseHead component, and a broken internal link to /broken-page/, with the remedy to verify the route in src/pages or the Content Collection slug.
checks per run, listed by progress: verbose
32
presets, from relaxed to production
8
report formats: JSON, Markdown, SARIF, HTML
4
platforms with prebuilt binaries
5

What it does

Captured from the test fixtures

All examples →
✖ astro-post-audit

  Errors: 1   Warnings: 3   Info: 3   Files: 4

● long-title.html (7)
  - The document has no main landmark. [landmarks/main-missing]
    Remedy: Landmarks structure the page for everyone who cannot see it.
  - The document has no navigation landmark. [landmarks/navigation-missing] (medium confidence)
    Remedy: Landmarks structure the page for everyone who cannot see it.
  - The document has no banner landmark. [landmarks/banner-missing] (medium confidence)
    Remedy: Landmarks structure the page for everyone who cannot see it.
  - The document has no contentinfo landmark. [landmarks/contentinfo-missing] (medium confidence)
    Remedy: Landmarks structure the page for everyone who cannot see it.
  - Content is not contained in any landmark. [landmarks/content-outside]
    Remedy: All content belongs inside a landmark.
  - Title is 143 chars (recommended max: 60) [html/title-too-long] at `title`
    Remedy: Shorten the title for better display in search results
  - Meta description is 242 chars (recommended max: 160) [html/meta-description-too-long] at `meta[name='description']`
    Remedy: Shorten the description for better display in search results

A baseline recorded for a clean site, then one page added: the report lists only the new page. Every output on this site is a real run of the audit binary against the fixtures in tests/fixtures, captured with examples/capture.sh.

examples/baseline.ansi

Quickstart

Install, register the integration, build.

  1. Install @casoon/astro-post-audit as a dev dependency.
  2. Add postAudit() to the integrations in astro.config.mjs, after sitemap().
  3. Run astro build. The report follows the build; failOn decides whether findings fail it.
astro.config.mjsJavaScript
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
import postAudit from '@casoon/astro-post-audit';

export default defineConfig({
  site: 'https://example.com',
  integrations: [
    sitemap(),
    // after sitemap(): the audit checks the generated sitemap
    postAudit({ preset: 'standard', failOn: 'errors' }),
  ],
});

New in v0.10.0

Changelog →

Frequently asked questions

Does astro-post-audit make network calls during the build?

No, by default. It's static analysis against the generated dist/ output, with no browser involved. The only opt-in exception is external link checking, which sends HEAD requests to verify third-party URLs.

Will it slow down my build on a large site?

Most checks run in well under a second on typical sites. The one expensive check, full HTML5 conformance validation, caches its results per page by content hash, so an incremental build only re-validates pages that actually changed.

Can I adopt it on a site that already has findings, without failing CI right away?

Yes. Run with writeBaseline: true once to snapshot current findings, then point baseline at that file — only new findings are reported from then on. Delete entries from the baseline to re-enable specific checks.

Where do the accessibility rule ids come from?

From a11y-rules, the shared core crate also used by auditmysite and LiveAudit, so a finding like images/alt-missing carries the same id everywhere. Older ids from before that migration still work in severity overrides and baselines.

Does it replace a browser-based tool like Lighthouse?

No. It never runs a browser, so it can't measure things like computed contrast or runtime performance — those show up in the report as capability_missing rather than silently passing. It covers SEO, links and static WCAG heuristics against what actually shipped.