npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@selorax/design-quality

v0.1.2

Published

SeloraX design-quality layer — pure slop linter, brand-aware lint (palette + fonts + WCAG contrast), k-means palette extractor, and craft rule docs. Build-time/runtime-pure (no DB, no network, no LLM).

Downloads

325

Readme

@selorax/design-quality

Pure design-quality engine for the SeloraX Pages platform. Catches AI-slop and brand-contract violations in HTML at save time — no DB, no network, no LLM.

npm i @selorax/design-quality

0.1.1 · pre-1.0.

What it is

A small, deterministic library that takes a string of HTML and returns design findings:

  • Slop linter (Spec 1) — high-confidence anti-patterns AI authors fall into: indigo/violet accents, two-stop "trust" gradients, emoji-as-icon, invented metrics ("10× faster"), card-with-left-accent dashboard tiles, filler copy ("Lorem ipsum"), system sans on display headings.
  • Brand-aware lint (Spec 2) — when you pass a tenant's selorax.design.md brand contract:
    • off-palette-hex — hex codes outside the declared palette
    • off-brand-fontfont-family declarations outside the declared fonts
  • WCAG contrast (always-on) — inline color/background pairs failing AA (< 4.5:1).
  • Craft prompt — concatenates the bundled craft/*.md docs into one system-prompt section for AI authoring.
  • Palette extractor — k-means++ over raw RGBA bytes (e.g. from a logo) so you can seed a brand palette from real data.
  • Contrast helpersparseHex, relativeLuminance, contrastRatio, wcagLevel.

Used by the backend (POST /pages advisory lint), the editor agent (self-correction loop), the MCP write tools, and the editor's BrandView panel. You normally get it transitively; install it directly only if you're building tooling on top.

Pure. No DB, no network, no LLM, no fs writes. Reads craft/*.md from its own package dir via fs.readFileSync once. Safe to run in any environment.

Usage

const dq = require('@selorax/design-quality');

// 1. Slop-only lint
const findings = dq.lint('<h1 style="color:#6366f1">🚀 Hi</h1>');
// → [{severity:'P0', rule:'no-indigo-accent', ...}, {severity:'P0', rule:'no-emoji-icons', ...}]

// 2. Brand-aware lint (palette + fonts from selorax.design.md)
const brand = dq.parseBrandTokens(designMd);
const all = dq.lint(html, {
  tokens: brand.palette,                                // off-palette-hex on
  fonts: Array.from(dq.allowedFontFamilies(brand)),     // off-brand-font on
});

// 3. WCAG contrast (always-on — no opts needed)
dq.contrastRatio('#ffffff', '#ffd0c0');  // → 1.40
dq.wcagLevel(1.40);                       // → 'fail'

// 4. Palette from a logo (k-means)
//    Decode PNG/JPG via sharp / canvas / etc, then:
const palette = dq.extractPalette(rgbaBytes, { k: 5 });
// → [{hex:'#ff5733', weight:0.62, rgb:[255,87,51]}, ...]

// 5. Craft prompt for the AI system message
const prompt = dq.buildCraftPrompt();

API

| Export | Kind | Purpose | |---|---|---| | lint(html, opts?) | function | Returns Finding[]. P0/P1/P2 severities. | | parseBrandTokens(md) | function | Parses YAML frontmatter from selorax.design.md. | | paletteHexSet(tokens) | function | Set of allowed #rrggbb from tokens.palette. | | allowedFontFamilies(tokens) | function | Set of allowed font families from tokens.fonts. | | extractPalette(rgba, opts?) | function | k-means++ over raw RGBA pixel bytes. | | parseHex / relativeLuminance / contrastRatio / wcagLevel | functions | WCAG 2.x helpers. | | buildCraftPrompt() | function | Concatenates CRAFT_FILES from CRAFT_DIR into one prompt string. | | CRAFT_DIR, CRAFT_FILES | const | Absolute path + filename list. |

Full type definitions in dist/index.d.ts.

Graceful degradation

Every consumer in the SeloraX stack lazy-requires this package — if it isn't installed, lint returns [] and the save still happens. lint(html, opts) never throws; malformed input yields [] rather than an error. This is intentional: design quality is always advisory, never blocking.

Tests

bunx vitest run — 101 unit + integration tests.

License

UNLICENSED (private use within SeloraX).