c3b-lint 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/check/html.js +11 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,9 +17,9 @@ markdown that a tool can check, with one command and one config to install. It r
|
|
|
17
17
|
4. **HTML** on every page under `src/` (partials are skipped): doctype, `lang`, charset, viewport without
|
|
18
18
|
`user-scalable=no`, the required head set (title, description, absolute canonical, `og:*` with an absolute
|
|
19
19
|
`og:image`, `twitter:card`, one SVG favicon; a `noindex` page is excused the canonical and social tags), no external
|
|
20
|
-
stylesheets (webfonts are self-hosted), stylesheet order (`reset`, `tokens`, `main`, …, page file last),
|
|
20
|
+
stylesheets (webfonts are self-hosted; a warning, not an error), stylesheet order (`reset`, `tokens`, `main`, …, page file last),
|
|
21
21
|
the skip-link rule (`<a id="skip-link" href="#main">` first in `<body>` when there is a header or nav, absent
|
|
22
|
-
otherwise, `<main id="main">`), one `<h1>`, `alt` on every image, no inline handlers, no `<style>` or `style=""`
|
|
22
|
+
otherwise, landing on `<main id="main">` — or on the id `<main>` already has), one `<h1>`, `alt` on every image, no inline handlers, no `<style>` or `style=""`
|
|
23
23
|
(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,
|
|
24
24
|
`integrity` on CDN scripts.
|
|
25
25
|
5. **Project structure**: singular directory names, lowercase kebab-case asset names (and no camera exports), and,
|
package/check/html.js
CHANGED
|
@@ -128,9 +128,11 @@ function checkPage(report, file, source) {
|
|
|
128
128
|
// --- stylesheet link order: reset, tokens, main, components, page file last
|
|
129
129
|
const allSheets = headEls.filter((el) => el.name === 'link' && attr(el, 'rel') === 'stylesheet')
|
|
130
130
|
.map((el) => ({ el, href: attr(el, 'href') ?? '' }));
|
|
131
|
-
// frontend.md: webfonts are self-hosted woff2 in src/asset/font/; no stylesheet comes from another origin
|
|
131
|
+
// frontend.md: webfonts are self-hosted woff2 in src/asset/font/; no stylesheet comes from another origin.
|
|
132
|
+
// A warning, not an error: a licensed font can come with a stylesheet that has to load from the foundry
|
|
133
|
+
// (Monotype's tracking CSS), and a font still waiting on its licence shouldn't block every commit.
|
|
132
134
|
for (const sheet of allSheets.filter((s) => /^(https?:)?\/\//.test(s.href))) {
|
|
133
|
-
report.
|
|
135
|
+
report.warn(at(sheet.el), `external stylesheet ${ sheet.href } — self-host it (fonts as woff2 in src/asset/font/)`);
|
|
134
136
|
}
|
|
135
137
|
const sheets = allSheets.filter((s) => !/^(https?:)?\/\//.test(s.href));
|
|
136
138
|
const names = sheets.map((s) => basename(s.href.split('?')[0]));
|
|
@@ -151,11 +153,14 @@ function checkPage(report, file, source) {
|
|
|
151
153
|
const skipLink = first && first.tagName === 'a' && attr(first, 'id') === 'skip-link';
|
|
152
154
|
const main = all.find((el) => el.name === 'main');
|
|
153
155
|
if (hasChrome) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
// The skip link lands on <main> by its id: "main" by default, or the id <main> already has
|
|
157
|
+
// (a Barba site scopes each page's CSS by it)
|
|
158
|
+
const target = main && attr(main, 'id');
|
|
159
|
+
if (!target) {
|
|
160
|
+
report.error(file, '<main> carries an id for the skip link to land on (id="main", or the one it already has)');
|
|
156
161
|
}
|
|
157
|
-
if (!
|
|
158
|
-
report.error(file,
|
|
162
|
+
if (!skipLink || attr(first, 'href') !== `#${ target || 'main' }`) {
|
|
163
|
+
report.error(file, `a page with a header or nav starts <body> with <a id="skip-link" href="#${ target || 'main' }">`);
|
|
159
164
|
}
|
|
160
165
|
} else if (skipLink) {
|
|
161
166
|
report.error(at(first), 'a page with no header or nav has no skip link');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c3b-lint",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Lints a co:lab project against the rules a tool can check: ESLint, Stylelint, the 500-line limit and the shared .editorconfig; --init writes the config files.",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"type": "module",
|