@casomoltd/tooling 0.33.0 → 0.33.2

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.
@@ -29,7 +29,7 @@
29
29
  * stylesheet is read verbatim, and an `.mjs` file's default export is the
30
30
  * field's value.
31
31
  */
32
- import {existsSync} from "node:fs";
32
+ import {existsSync, readFileSync} from "node:fs";
33
33
  import {mkdir, readdir, readFile, writeFile} from "node:fs/promises";
34
34
  import os from "node:os";
35
35
  import path from "node:path";
@@ -77,6 +77,14 @@ const IDENTITY = ["id", "publicId", "username"];
77
77
  /** Hrefs Buttondown draws itself, which no socials entry names. */
78
78
  const BUTTONDOWN_LINKS = ["buttondown.com"];
79
79
 
80
+ /** The shared web rules' opening line, which marks a composed skin, and
81
+ * the variables those rules read, which such a skin must declare. */
82
+ const BASE_WEB = readFileSync(new URL("./base-web.css", import.meta.url), "utf8");
83
+ const BASE_MARK = BASE_WEB.slice(0, BASE_WEB.indexOf("\n"));
84
+ const BASE_VARS = [...new Set(
85
+ [...BASE_WEB.matchAll(/var\((--[\w-]+)/g)].map((m) => m[1]),
86
+ )];
87
+
80
88
  /** Values of `content:` that remove text rather than inject it. */
81
89
  const NO_CONTENT = new Set(["none", "normal", '""', "''"]);
82
90
 
@@ -246,14 +254,20 @@ export async function runCheck(settings) {
246
254
  + "statement before its first rule, which a browser ignores");
247
255
  }
248
256
 
249
- // Every --bd-* role the shared rules read must be declared, or the
250
- // declaration reading it is dropped without an error.
251
- const declared = new Set([...stripComments(web)
252
- .matchAll(/(--bd-[\w-]+)\s*:/g)].map((m) => m[1]));
253
- for (const role of new Set([...stripComments(web)
254
- .matchAll(/var\((--bd-[\w-]+)/g)].map((m) => m[1]))) {
255
- if (!declared.has(role)) {
256
- problems.push(`the web skin reads ${role}, which nothing declares: `
257
+ // Every variable the shared rules read, and every --bd-* role read
258
+ // anywhere, must be declared, or the declaration reading it is dropped
259
+ // without an error.
260
+ const plain = stripComments(web);
261
+ const declared = new Set(
262
+ [...plain.matchAll(/(--[\w-]+)\s*:/g)].map((m) => m[1]),
263
+ );
264
+ const read = new Set([
265
+ ...web.includes(BASE_MARK) ? BASE_VARS : [],
266
+ ...[...plain.matchAll(/var\((--bd-[\w-]+)/g)].map((m) => m[1]),
267
+ ]);
268
+ for (const name of read) {
269
+ if (!declared.has(name)) {
270
+ problems.push(`the web skin reads ${name}, which nothing declares: `
257
271
  + "map it in the TOKENS block");
258
272
  }
259
273
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casomoltd/tooling",
3
- "version": "0.33.0",
3
+ "version": "0.33.2",
4
4
  "description": "Casomo's shared dev config: ESLint, Prettier, commitlint, knip & jscpd presets and dev CLIs (git hooks, readability, screenshots, design specs)",
5
5
  "license": "MIT",
6
6
  "repository": {