c3b-lint
v0.0.32
Published
Lints a co:lab project against the rules a tool can check: ESLint, Stylelint, the HTML, WCAG 2.2 and SEO/agent-readability rules, the 500-line limit and the shared .editorconfig; --init writes the config files.
Readme
c3b-lint
Lints a co:lab project against the rules in the llm-instructions markdown that a tool can check, with one command and one config to install. It runs, in this order:
- Project structure: singular directory names, lowercase kebab-case asset names (and no camera exports), and,
when
src/holds pages, CSS only insrc/style/+style/page/+style/animation/, JS only insrc/script/(an experiment undersrc/experiment/<name>/keeps its own beside itsindex.html), fonts only insrc/asset/font/as woff2, file names starting with a letter. A directory whose plural-looking name is a proper name (a client's brand) is listed inpackage.jsonunder"c3b-lint": { "singularDirectories": [...] }. Also here:- Assets: a camera export is caught by its prefix (
img-,dsc-,pxl-) or by a year and counter (studio-2026-0287.webp). Warnings, because the images are usually gitignored and a machine without them must lint the same: the same file twice insrc/asset/, an image over 500 KB, the page'sog:imageover 300 KB and a video over 5 MB. An asset that no page, stylesheet, script or data file undersrc/names by its path (asset/home/hero.webp) is an error: delete it, or put it underignore. Where there is ad8e-asset-manifest.jsonthe manifest is the list that is checked, so the result is the same with or without the images on disk; a file that is only on this machine and not in the manifest yet is a warning. - Vendored files (
src/**/vendor/,vendor/) carry their version in the name (gsap-3.13.0.min.js), or in the folder's for a library kept as one (three-0.160.0/build/three.module.js). - The three stylesheets: a site with CSS in
src/style/hasreset.css,tokens.cssandmain.css. Withouttokens.cssthe token check (3) has nothing to read. - The repo baseline from
general.md:c3b-lintruns inpretestortest, and a site runsc3b-lint --initinpostinstall(npm run lintcounts when that script is the lint); everypre<name>script has its<name>(npm's own hooks likeprepare, and words likepreview, aside); Node is pinned inengineswith a.nvmrcnaming the same major;package-lock.jsonexists; and.gitignorecovers.DS_Store,.idea/,.llm-rules/,.env*andnode_modules/.
- Assets: a camera export is caught by its prefix (
- HTML on every page under
src/(partials are skipped): doctype,lang, charset, viewport withoutuser-scalable=no, the required head set (title, description, absolute canonical,og:*with an absoluteog:image,twitter:card, one SVG favicon; anoindexpage is excused the canonical and social tags), no external stylesheets (webfonts are self-hosted; a warning, not an error), stylesheet order (reset,tokens,main, …, page file last), the skip-link rule (<a id="skip-link" href="#main">first in<body>when there is a header or nav, absent otherwise, landing on<main id="main">— or on the id<main>already has), one<h1>,alton every image, no inline handlers, no<style>orstyle=""(except a JS-driven custom property), relative paths only (a Barba site's links outside its container — header, menu — stay root-relative), kebab-case ids and classes, no duplicate ids, no class that a single element on a single page carries (that is an id's job;is-*state classes, a partial's markup, a<template>'s content and classes a script adds are not counted),integrityon CDN scripts. Scripts sit at the bottom of<body>as its direct children, importmaps first, then plain scripts, then deferred, then modules. In<head>, only anasynctag (analytics) or an inline line that must run before first paint; a Barba container keeps its page's own scripts; a typed data block (JSON-LD) is not a script. An inline<script>is a warning wherever it is, unless a comment excuses it (see Excusing a finding). - Token hygiene across all the CSS, which no per-file linter can do: a literal that duplicates a token's value
(
#2b4b6fwhere--color-primaryis that), a literal colour, font-family or spacing value used in two or more rules (that is a token by definition), and a token nothing uses (CSSvar(), or JS/HTML by name). With it, because it also reads the CSS itself: no copy text incontent:(a glyph, an escape,attr(), a counter and the alternative text after a/are fine). - Accessibility, the WCAG 2.2 A/AA criteria a parser can check, each finding naming its criterion: form fields
labelled (a placeholder is not a label) and
autocompleteon email/tel/url fields, links and buttons with an accessible name and link text that says where it goes, nohref="#"controls, notabindexabove 0, noaria-hiddenon anything focusable,role/aria-*names that exist and id references that resolve, heading levels that don't skip,<th>in data tables,<iframe>titles, inline<svg>eitheraria-hiddenorrole="img"with a name, no file-name or "image of" alt text, captions on<video>/<audio>and a way to stop autoplay (controls, a button witharia-controlsnaming it, or for a muted video aprefers-reduced-motion: reducerule on it), no<meta http-equiv="refresh">, a validlang, and in the CSS nooutline: noneunless the rule shows focus another way or is:focus:not(:focus-visible), and aprefers-reduced-motion: reduceblock in every file with a transition or animation (unless it sits in ano-preferenceblock). Amutedvideo needs no captions; a<template>'s content is not checked (it is not in the document). What needs a rendered page (contrast, target size, focus order, what JS adds) stays with c10g's axe-core run. - SEO and agent readability, what a search engine or an AI agent needs to index the site and say what each
page is:
src/robots.txtwith aSitemap:line andsrc/sitemap.xml, every indexable page in the sitemap and every sitemap entry a page; on every indexable page the canonical,og:urland sitemap entry naming the same URL (.htmlor not on all three —d8e --clean-urlscleans them all); JSON-LD on every indexable page that parses, carries"@context": "https://schema.org"and a@type(or a@graphof typed items); a page titled FAQ typedFAQPage(a warning). And the build:d8e --clean-urlswhen and only whenvercel.jsonhascleanUrls, andd8e --markdownso agents get Markdown twins andllms.txt(a warning without it). Anoindexpage, and a page under a pathrobots.txtdisallows, is excused. - That the project's
.editorconfigis the shared one — it carries the JetBrainsij_*code-style keys, so WebStorm and IntelliJ format the same way without committing.idea/. - The 500-line limit on
src/**/*.{css,html}(ESLint reports the JS); inline<svg>art is not counted, nor is a colab-partial region whose partial is insrc/partial/(one line each: the partial is counted on its own). - ESLint on every
.jsfile — classic browser scripts undersrc/(IIFE required, no top-level declarations, noconsole.log), ES modules everywhere else — witheslint:recommendedplus the rules fromfrontend.md: braces on everyif,const/letnevervar,===, a blank line beforereturn, 500 lines max, and areplace()/replaceAll()whose replacement comes from data must pass a function (a string one expands$&). Insrc/, a page URL is written out whole, never ended with'.html'after a value ('./' + slug + '.html'): d8e--clean-urlscan only rewrite the literal. A Playwright spec (test/e2e/**,*.spec.js) is a Node module whose callbacks run in the page, so it also gets the browser's globals and the project'sglobals. Insrc/, a script attaches its API towindow.App, never to a global of its own (window.LBReady = …; a callback a third party calls by name and the analytics tag's settings are not ours to move), and an ES module there is reported as one rather than as a bare parsing error. - Stylelint on
src/**/*.csswithstylelint-config-recommendedplus the rules fromfrontend.md: no!important, max 3 compound selectors, kebab-case ids/classes withis-*states and--variants,:rootonly intokens.css(andreset.css), token names--{category}-{role},remfont sizes,emletter-spacing, neverdvh, no colour literal with an alpha channel (rgba(),rgb(… / 20%),#0003: alpha variants usecolor-mix), no styling offdata-*(warning), and breakpoints of1024px,768pxand480pxonly (warning).
Formatting itself (indent, quotes, spacing) is not linted: the .editorconfig and the IDE own it.
A Node library that keeps its modules in src/ (c10g) is not a site: its eslint.config.js is
export default [...base, librarySrc]; (both from c3b-lint/config/eslint.config.js), which lints src/ with the
Node rules, and the site-layout checks only apply when src/ holds pages.
Setup
npm install --save-dev c3b-lint
npx c3b-lint --init--init writes four files at the project root, all to commit:
.editorconfig— the shared one (a copy; editors need a real file).eslint.config.jsandstylelint.config.js— one line each, re-exporting this package's configs, so WebStorm shows the same errors inline as the CLI reports. Bumpingc3b-lintchanges the rules everywhere. Written only when missing: a project that has extended its config keeps it..githooks/pre-commit, andgit config core.hooksPath .githooks— the lint runs before every commit, so a commit that fails it never lands, whoever makes it. The hook lives in the repo, so after a clone one--init(ornpx c3b-lint --initinpostinstall) wires it up. Ifnode_modulesis missing it says so and lets the commit through; the test gate catches it later.
Then in package.json:
"postinstall": "c3b-lint --init",
"lint": "c3b-lint",
"pretest": "colab-partial --check && c3b-lint"postinstall keeps the four files current and wires the hook on every clone with no extra step (--init only
writes, it never fails an install); pretest makes a lint error fail npm test and anything that runs it.
Project settings
A project's own settings go in its package.json, under "c3b-lint":
"c3b-lint": {
"ignore": ["src/experiment/**"],
"globals": ["THREE", "gsap", "ScrollTrigger"],
"singularDirectories": ["mannequin-films"],
"ignoreLength": ["src/index.html"]
}ignore— globs, from the project root, that no check looks at: ESLint, Stylelint and every check c3b-lint runs itself (HTML, structure, tokens, file lengths). For code that is not the site's own, like standalone experiments.globals— the names a page's CDN<script>tags define (THREE,gsap,Lenis, …). ESLint lints each file on its own and never reads the HTML, so without them every use is "not defined". Read-only,src/scripts only.singularDirectories— plural-looking directory names that are proper names (a client's brand).ignoreLength— globs exempt from the 500-line limit and nothing else: the HTML, token, structure, ESLint and Stylelint checks still run on them. For a file that can't be split. A page made long by the partials it carries needs none: their regions count as one line each.
The ESLint and Stylelint configs read these too, so WebStorm reports what the CLI does.
Excusing a finding
A rule is fixed, not switched off. The few that have a legitimate permanent exception can be excused where they occur, with a comment that says why:
- HTML —
<!-- c3b-lint-disable inline-script: must run before first paint -->directly before the inline<script>.inline-scriptis the only rule that can be excused this way. A comment with no reason, an unknown rule, or nothing after it to excuse is itself a warning, and every run prints how many findings were excused (exemptionsin the JSON report). - CSS — Stylelint's own
/* stylelint-disable-next-line <rule> -- <reason> */. One with no reason, or that no longer silences anything, is a warning. - JS — ESLint's own
// eslint-disable-next-line <rule> -- <reason>. ESLint warns about one that no longer silences anything; it has no check for a missing reason, so that is left to review.
The token, structure, asset and length checks report on a value or a file across the project rather than on a line:
ignore and ignoreLength above are what they have.
Usage
c3b-lint # lint; exits 1 on any error
c3b-lint --fix # apply the fixes ESLint and Stylelint consider safe (var -> const, braces, …); reformat in the IDE after
c3b-lint --init # (re)write .editorconfig, eslint.config.js, stylelint.config.js, the pre-commit hook
c3b-lint --helpThe version is printed first, so you can tell which install is running.
Findings print in sections, in the order they run — --- c3b-lint --- (checks 1–7), --- eslint ---,
--- stylelint --- — each grouped under the file's absolute path the way ESLint prints, with a ✖ N problems total.
A section with no findings is not printed. The timings follow, then the error count.
With C3B_LINT_REPORT=<path> in the environment, every finding of the run is also written to that file as JSON,
passed or failed: { version, errors, warnings, findings }, each finding
{ check, file, line, column, severity, rule, message, fixable } — check is structure, html, accessibility, seo, tokens,
editorconfig, lengths, eslint or stylelint, file is relative to the project root, rule and fixable
come from ESLint and Stylelint (null and false for c3b-lint's own checks). It's for a program reading the run —
colab-desktop's Output summary. An environment variable rather than a flag: a caller that sets it for every project
can't know which c3b-lint each one pins, and an older version ignores it where it would refuse a flag.
Not covered
Rules that need judgement stay with review: whether two selectors are structurally disjoint, flex vs grid, whether
a one-off literal should be a token anyway, where a component style belongs. no-descending-specificity is off for
the same reason. The checks that need a browser (console errors, broken links and images, the accessibility of the
rendered page — contrast, target size, focus order, what JS adds — and overflow) stay in
c10g; its SEO and duplicate-id suites now overlap with the HTML check here. Java projects use colab-checkstyle and the same
.editorconfig.
