From 20fb67a71df0367807de2c6c339db0e4daadb761 Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Tue, 24 Nov 2026 15:36:26 +0200 Subject: [PATCH 01/30] chore(deps): move to @uxfront/oxlint-config 0.2.0, with its failing rules off 0.2.0 builds on Cloudflare's oxlint config. oxlint reads env and ignorePatterns only from the root config, so they are restated here. Each rule that fails turns off for now; the commits after this one fix its errors or keep it off with its reason. Co-authored-by: multica-agent --- oxlint.config.ts | 29 +++++++++++++++ package.json | 2 +- pnpm-lock.yaml | 86 +++++++++++++++++++++++++++++++++++++++++---- pnpm-workspace.yaml | 1 + 4 files changed, 111 insertions(+), 7 deletions(-) diff --git a/oxlint.config.ts b/oxlint.config.ts index c7e8a38..8a699c5 100644 --- a/oxlint.config.ts +++ b/oxlint.config.ts @@ -3,7 +3,36 @@ import { defineConfig } from "oxlint"; export default defineConfig({ extends: [vue], + // oxlint reads env and ignorePatterns only from the root config, not through extends. + env: vue.env, + ignorePatterns: vue.ignorePatterns, rules: { + // Baseline for 0.2.0: the rules it adds that fail here, each fixed in its own commit. + "curly": "off", + "@typescript-eslint/array-type": "off", + "typescript/no-non-null-assertion": "off", + "quality/no-unknown-returns": "off", + "unicorn/consistent-function-scoping": "off", + "unicorn/prefer-string-replace-all": "off", + "quality/no-known-value-widening": "off", + "no-console": "off", + "import/consistent-type-specifier-style": "off", + "unicorn/prefer-number-properties": "off", + "quality/no-unsafe-dictionary-type": "off", + "unicorn/prefer-string-raw": "off", + "unicorn/numeric-separators-style": "off", + "unicorn/prefer-set-has": "off", + "quality/no-array-filter-map": "off", + "no-promise-executor-return": "off", + "quality/no-chained-type-assertions": "off", + "@nkzw/no-instanceof": "off", + "quality/no-conditional-empty-object-spread": "off", + "unicorn/text-encoding-identifier-case": "off", + "quality/no-object-parameters": "off", + "import-x/no-namespace": "off", + "preserve-caught-error": "off", + "no-empty": "off", + "eqeqeq": "off", // Destructuring a key beside a rest element is how the code copies an object without // that key, like `({ component, ...contract }) => contract`, so the key is unused on // purpose. Setting an option drops oxlint's defaults, so the `^_` patterns restate them. diff --git a/package.json b/package.json index cd8f87d..0d8ee35 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "@testing-library/vue": "^8.1.0", "@types/node": "^24.13.6", "@uxfront/oxfmt-config": "^0.1.1", - "@uxfront/oxlint-config": "^0.1.1", + "@uxfront/oxlint-config": "^0.2.0", "@vitejs/plugin-vue": "^6.0.9", "ajv": "^8.20.0", "ajv-formats": "^3.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 89865f6..d5b52c2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -73,8 +73,8 @@ importers: specifier: ^0.1.1 version: 0.1.1(oxfmt@0.79.0) '@uxfront/oxlint-config': - specifier: ^0.1.1 - version: 0.1.1(oxlint@1.94.0) + specifier: ^0.2.0 + version: 0.2.0(eslint@10.11.0(jiti@2.7.0))(oxlint@1.94.0) '@vitejs/plugin-vue': specifier: ^6.0.9 version: 6.0.9(vite@8.3.1(@types/node@24.13.6)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.1))(vue@3.5.43(typescript@6.0.3)) @@ -370,6 +370,21 @@ packages: resolution: {integrity: sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg==} engines: {node: '>=22.0.0'} + '@cloudflare/oxlint-config@0.2.0': + resolution: {integrity: sha512-HENc8yIzCuIPvUyQbX47UKv2kgA26iZt1XRsrlQXayJG6cWmBNlnHXfPy7oNCghqWpTBcbFRdGwsHd1Ahe3zhw==} + engines: {node: ^22.18.0 || >=24.0.0} + peerDependencies: + oxlint: ^1.94.0 + tsrs: '>=7.1.0-beta.tsrs2' + vite-plus: '>=1.7.0' + peerDependenciesMeta: + oxlint: + optional: true + tsrs: + optional: true + vite-plus: + optional: true + '@cloudflare/unenv-preset@2.16.2': resolution: {integrity: sha512-JBP1+Z7ZSNG/d4mRP+y8VC5dka3tZVMLEZRvS+rzQ4DGV1EoxRFQckcJTTkXbHSQiTj0DtNI01Zwb/V2fX0mvQ==} peerDependencies: @@ -1662,6 +1677,31 @@ packages: '@emnapi/core': ^1.7.1 || ^2.0.0-alpha.4 '@emnapi/runtime': ^1.7.1 || ^2.0.0-alpha.4 + '@nkzw/eslint-plugin@3.0.0': + resolution: {integrity: sha512-J6Ms/OzUxx7BNBggCKOqFWbESgAJYjvXvekCjjpxVJA2fBv5xOsC5P+2WDYqQUMCvDOU3GxBgG/jrmbqf+/wQA==} + peerDependencies: + eslint: '>= 9' + peerDependenciesMeta: + eslint: + optional: true + + '@nkzw/oxlint-config@4.1.0': + resolution: {integrity: sha512-uFJxSqD8LPGe+uYVh+EC9BwndUGr3h7+aHQhKcdUANNSV4c1vvRoOqqHUTlML5RnHtvABtapW1ZyY4gkz6sKOA==} + peerDependencies: + eslint-plugin-perfectionist: ^5.14.0 + oxlint: '>=1.94.0' + tsrs: '>=0.25.0-ts7.1.0-beta || ^7.1.0-beta.tsrs2' + vite-plus: '>=1.7.0' + peerDependenciesMeta: + eslint-plugin-perfectionist: + optional: true + oxlint: + optional: true + tsrs: + optional: true + vite-plus: + optional: true + '@noble/hashes@2.4.0': resolution: {integrity: sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA==} engines: {node: '>= 20.19.0'} @@ -3694,10 +3734,10 @@ packages: peerDependencies: oxfmt: '>=0.70.0 <1' - '@uxfront/oxlint-config@0.1.1': - resolution: {integrity: sha512-Cs5EdissO5MmD5ebnFJ5A/TAhDZRjspwWSbWmElgOYB/05uhEGyRbz+z5bYCZ3Ethbi5CdKUlqOch3w/9xS80A==} + '@uxfront/oxlint-config@0.2.0': + resolution: {integrity: sha512-GvMe1wC06+J3rdsYWwzb6lwMhrP3FEV89syI+xpvxexuJWXRosR4BMuUydcq1b8/GvC1n8WygUfrC/H6Aacfvw==} peerDependencies: - oxlint: ^1.45.0 + oxlint: ^1.94.0 '@uxfront/scene@0.5.1': resolution: {integrity: sha512-SCbqe1f/8TQ5+dcEC8cvxw0sSF1kPojdKop1rTme7FCrjuOAOukhdLbJVrQBi5QB1N+sHMCa1Y+Sl8+GE8ZkvQ==} @@ -4816,6 +4856,10 @@ packages: engines: {node: '>=6.0'} hasBin: true + eslint-plugin-no-only-tests@3.4.0: + resolution: {integrity: sha512-4S3/9Nb7A2tiMcpzEQE9bQSlpeOz6WJkgryBuou/SA8W2x2c8Zf4j0NvTKBjv6qNhF9T79tmkecm/0CHqV0UGg==} + engines: {node: '>=5.0.0'} + eslint-scope@9.1.2: resolution: {integrity: sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==} engines: {node: ^20.19.0 || ^22.13.0 || >=24} @@ -8514,6 +8558,15 @@ snapshots: '@cloudflare/kv-asset-handler@0.5.0': {} + '@cloudflare/oxlint-config@0.2.0(eslint@10.11.0(jiti@2.7.0))(oxlint@1.94.0)': + dependencies: + '@nkzw/oxlint-config': 4.1.0(eslint@10.11.0(jiti@2.7.0))(oxlint@1.94.0) + optionalDependencies: + oxlint: 1.94.0 + transitivePeerDependencies: + - eslint + - eslint-plugin-perfectionist + '@cloudflare/unenv-preset@2.16.2(unenv@2.0.0-rc.24)(workerd@1.20261001.1)': dependencies: unenv: 2.0.0-rc.24 @@ -9434,6 +9487,19 @@ snapshots: '@tybys/wasm-util': 0.10.4 optional: true + '@nkzw/eslint-plugin@3.0.0(eslint@10.11.0(jiti@2.7.0))': + optionalDependencies: + eslint: 10.11.0(jiti@2.7.0) + + '@nkzw/oxlint-config@4.1.0(eslint@10.11.0(jiti@2.7.0))(oxlint@1.94.0)': + dependencies: + '@nkzw/eslint-plugin': 3.0.0(eslint@10.11.0(jiti@2.7.0)) + eslint-plugin-no-only-tests: 3.4.0 + optionalDependencies: + oxlint: 1.94.0 + transitivePeerDependencies: + - eslint + '@noble/hashes@2.4.0': {} '@nodelib/fs.scandir@2.1.5': @@ -11790,9 +11856,15 @@ snapshots: dependencies: oxfmt: 0.79.0 - '@uxfront/oxlint-config@0.1.1(oxlint@1.94.0)': + '@uxfront/oxlint-config@0.2.0(eslint@10.11.0(jiti@2.7.0))(oxlint@1.94.0)': dependencies: + '@cloudflare/oxlint-config': 0.2.0(eslint@10.11.0(jiti@2.7.0))(oxlint@1.94.0) oxlint: 1.94.0 + transitivePeerDependencies: + - eslint + - eslint-plugin-perfectionist + - tsrs + - vite-plus '@uxfront/scene@0.5.1': {} @@ -13150,6 +13222,8 @@ snapshots: optionalDependencies: source-map: 0.6.1 + eslint-plugin-no-only-tests@3.4.0: {} + eslint-scope@9.1.2: dependencies: '@types/esrecurse': 4.3.1 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index b4e2884..003865d 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -21,3 +21,4 @@ minimumReleaseAgeExclude: - '@uxfront/layer-ui@0.1.11' - '@uxfront/scene@0.5.1' - '@uxfront/ui@0.9.1' + - '@uxfront/oxlint-config@0.2.0' From f5b842f9e61f89704817918b026d90ed10849558 Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Tue, 24 Nov 2026 15:37:48 +0200 Subject: [PATCH 02/30] chore: keep the html charset as utf-8 under unicorn/text-encoding-identifier-case Co-authored-by: multica-agent --- nuxt.config.ts | 2 ++ oxlint.config.ts | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 7e4a030..8dd6ca1 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -213,6 +213,8 @@ export default defineNuxtConfig({ head: { htmlAttrs: { lang: "en" }, meta: [ + // The HTML standard asks for `charset="utf-8"` exactly, so the rule's `utf8` would be invalid. + // oxlint-disable-next-line unicorn/text-encoding-identifier-case { charset: "utf-8" }, { name: "viewport", content: "width=device-width, initial-scale=1" }, ], diff --git a/oxlint.config.ts b/oxlint.config.ts index 8a699c5..219ebb8 100644 --- a/oxlint.config.ts +++ b/oxlint.config.ts @@ -27,7 +27,6 @@ export default defineConfig({ "quality/no-chained-type-assertions": "off", "@nkzw/no-instanceof": "off", "quality/no-conditional-empty-object-spread": "off", - "unicorn/text-encoding-identifier-case": "off", "quality/no-object-parameters": "off", "import-x/no-namespace": "off", "preserve-caught-error": "off", From 57c85debb725c2c6a8b85073312ed42713cf1114 Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Tue, 24 Nov 2026 15:37:56 +0200 Subject: [PATCH 03/30] chore: group long numbers under unicorn/numeric-separators-style Co-authored-by: multica-agent --- mcp/lib/pages.test.ts | 4 ++-- mcp/lib/pages.ts | 2 +- mcp/lib/paging.test.ts | 2 +- mcp/server/mcp/prompts/review-component.ts | 2 +- mcp/server/mcp/prompts/review-usage.ts | 2 +- oxlint.config.ts | 1 - scripts/check-mcp.mjs | 4 ++-- 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mcp/lib/pages.test.ts b/mcp/lib/pages.test.ts index 039d14f..a387369 100644 --- a/mcp/lib/pages.test.ts +++ b/mcp/lib/pages.test.ts @@ -186,7 +186,7 @@ describe("outline", () => { heading(2, "Token paths", 910), heading(3, "Groups", 364), heading(2, "Component variables", 970, 580), - heading(4, "Deep", 8_700), + heading(4, "Deep", 8700), ]; it("lists the headings, indented from the top level, with their length", () => { @@ -225,7 +225,7 @@ describe("count", () => { [994, "990"], [1000, "1k"], [1049, "1k"], - [8_700, "8.7k"], + [8700, "8.7k"], [20_000, "20k"], [35_213, "35.2k"], ])("rounds %d to %s", (value, expected) => { diff --git a/mcp/lib/pages.ts b/mcp/lib/pages.ts index 48efc57..4ecefde 100644 --- a/mcp/lib/pages.ts +++ b/mcp/lib/pages.ts @@ -15,7 +15,7 @@ export const PAGE_LIMIT = 8000; * instead: under what MCP clients pass on whole by default, like Gemini CLI's * 40,000 characters and Codex's 48,000 bytes. Longer replies get cut short. */ -export const REPLY_LIMIT = 36000; +export const REPLY_LIMIT = 36_000; /** * Finds a page from what an agent might call it: its path (`/docs/components/button`), diff --git a/mcp/lib/paging.test.ts b/mcp/lib/paging.test.ts index 9feaff8..e7b356f 100644 --- a/mcp/lib/paging.test.ts +++ b/mcp/lib/paging.test.ts @@ -48,6 +48,6 @@ describe("paginate", () => { it("fits a page of the longest rules well under the 40,000 characters some clients pass on", () => { const longest = [...rules].sort((a, b) => JSON.stringify(b).length - JSON.stringify(a).length); - expect(JSON.stringify(paginate(longest)).length).toBeLessThan(30000); + expect(JSON.stringify(paginate(longest)).length).toBeLessThan(30_000); }); }); diff --git a/mcp/server/mcp/prompts/review-component.ts b/mcp/server/mcp/prompts/review-component.ts index bd7719b..a7a00be 100644 --- a/mcp/server/mcp/prompts/review-component.ts +++ b/mcp/server/mcp/prompts/review-component.ts @@ -12,7 +12,7 @@ export default defineMcpPrompt({ (value = "") => names.contracts.filter((name) => name.startsWith(value.trim().toLowerCase().replace(/[\s_]+/g, "-"))), ), // Clients like VS Code can pass a whole file, or the selection, as an argument. - code: z.string().max(200000).optional().describe("The code to review, or the files or folder it's in, like src/components/Button.tsx."), + code: z.string().max(200_000).optional().describe("The code to review, or the files or folder it's in, like src/components/Button.tsx."), }, handler: async ({ component: key, code }) => { const standard = await useStandard(); diff --git a/mcp/server/mcp/prompts/review-usage.ts b/mcp/server/mcp/prompts/review-usage.ts index 5bfa498..60e185c 100644 --- a/mcp/server/mcp/prompts/review-usage.ts +++ b/mcp/server/mcp/prompts/review-usage.ts @@ -14,7 +14,7 @@ export default defineMcpPrompt({ // Clients like VS Code can pass a whole file, or the selection, as an argument. screen: z .string() - .max(200000) + .max(200_000) .optional() .describe('The screen to review, like "our checkout page", or its code. Defaults to "our app".'), }, diff --git a/oxlint.config.ts b/oxlint.config.ts index 219ebb8..05cfa9d 100644 --- a/oxlint.config.ts +++ b/oxlint.config.ts @@ -20,7 +20,6 @@ export default defineConfig({ "unicorn/prefer-number-properties": "off", "quality/no-unsafe-dictionary-type": "off", "unicorn/prefer-string-raw": "off", - "unicorn/numeric-separators-style": "off", "unicorn/prefer-set-has": "off", "quality/no-array-filter-map": "off", "no-promise-executor-return": "off", diff --git a/scripts/check-mcp.mjs b/scripts/check-mcp.mjs index 64ccd4a..7997718 100644 --- a/scripts/check-mcp.mjs +++ b/scripts/check-mcp.mjs @@ -20,7 +20,7 @@ const PROMPTS = ["adopt-token-paths", "build-component", "review-component", "re // What some MCP clients pass on of a tool's result before cutting it short, like // Gemini CLI's 40,000 characters (Codex's is 48,000 bytes, and Claude Code's // 25,000 tokens). -const MAX_RESULT = 40000; +const MAX_RESULT = 40_000; const problems = []; const check = (ok, problem) => ok || problems.push(problem); @@ -382,7 +382,7 @@ async function checkServer() { ["build-component for a component that doesn't exist", () => client.getPrompt({ name: "build-component", arguments: { component: "nope" } })], ]) { const error = await request().then(() => undefined, (error) => error); - check(error?.code === -32602, `${what} returned ${error ? `error ${error.code}` : "no error"}, not -32602`); + check(error?.code === -32_602, `${what} returned ${error ? `error ${error.code}` : "no error"}, not -32602`); } // Resources: the same bytes as the files the site publishes at their URIs. From 2b87cc8b89c95f42c380c2bd5190f48fb0b61aca Mon Sep 17 00:00:00 2001 From: Alex Grozav Date: Tue, 24 Nov 2026 15:38:00 +0200 Subject: [PATCH 04/30] chore: write escaped backslashes with String.raw under unicorn/prefer-string-raw Co-authored-by: multica-agent --- app/reference/popover/Popover.vue | 2 +- content/docs/3.components/popover/index.md | 2 +- mcp/lib/markdown.ts | 2 +- mcp/lib/search.test.ts | 2 +- mcp/lib/search.ts | 2 +- mcp/lib/standard.test.ts | 2 +- oxlint.config.ts | 1 - scripts/check-seo.mjs | 2 +- server/lib/checklists.ts | 2 +- server/lib/components-hub.test.ts | 2 +- server/lib/contract.ts | 2 +- 11 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/reference/popover/Popover.vue b/app/reference/popover/Popover.vue index 4c92c1d..22f7a48 100644 --- a/app/reference/popover/Popover.vue +++ b/app/reference/popover/Popover.vue @@ -105,7 +105,7 @@ function initialFocus(el: HTMLElement) { } // The buttons that point at it with `popovertarget`. -const triggers = () => document.querySelectorAll(`[popovertarget="${id.replace(/["\\]/g, "\\$&")}"]`); +const triggers = () => document.querySelectorAll(`[popovertarget="${id.replace(/["\\]/g, String.raw`\$&`)}"]`); // The trigger is the button the browser says opened it, where it says so, or else the // first one that points at it. TypeScript doesn't know `source` yet. diff --git a/content/docs/3.components/popover/index.md b/content/docs/3.components/popover/index.md index 52d7b8a..762d327 100644 --- a/content/docs/3.components/popover/index.md +++ b/content/docs/3.components/popover/index.md @@ -183,7 +183,7 @@ function initialFocus(el: HTMLElement) { } // The buttons that point at it with `popovertarget`. -const triggers = () => document.querySelectorAll(`[popovertarget="${id.replace(/["\\]/g, "\\$&")}"]`); +const triggers = () => document.querySelectorAll(`[popovertarget="${id.replace(/["\\]/g, String.raw`\$&`)}"]`); // The trigger is the button the browser says opened it, where it says so, or else the // first one that points at it. TypeScript doesn't know `source` yet. diff --git a/mcp/lib/markdown.ts b/mcp/lib/markdown.ts index 009df76..b51402c 100644 --- a/mcp/lib/markdown.ts +++ b/mcp/lib/markdown.ts @@ -48,7 +48,7 @@ export function cells(row: string): string[] { .trim() .replace(/^\||\|$/g, "") .split(/(? cell.trim().replaceAll("\\|", "|")); + .map((cell) => cell.trim().replaceAll(String.raw`\|`, "|")); } /** diff --git a/mcp/lib/search.test.ts b/mcp/lib/search.test.ts index e4517e0..a64b2a3 100644 --- a/mcp/lib/search.test.ts +++ b/mcp/lib/search.test.ts @@ -119,7 +119,7 @@ describe("createSearch", () => { for (const { excerpt } of everything) { expect(excerpt.length).toBeGreaterThan(0); expect(excerpt.length).toBeLessThanOrEqual(240); - expect(excerpt).not.toContain("\\|"); + expect(excerpt).not.toContain(String.raw`\|`); expect(excerpt).not.toContain("$/; * under its name, or only `framework`'s. Where an example doesn't come in it, * that example shows the first framework it has, with a note, as the site does. */ -export function renderFrameworks(markdown: string, frameworks: Framework[], framework?: string): string { +export function renderFrameworks(markdown: string, frameworks: Array, framework?: string): string { const label = (value: string) => frameworks.find((f) => f.value === value)?.label ?? value; - const lines: string[] = []; - let slots: Map | undefined; - let current: string[] | undefined; + const lines: Array = []; + let slots: Map> | undefined; + let current: Array | undefined; for (const line of markdown.split("\n")) { if (line === SWITCHER) { @@ -46,7 +46,7 @@ export function renderFrameworks(markdown: string, frameworks: Framework[], fram } // Drops the blank lines around a slot's code. -function trim(lines: string[]): string[] { +function trim(lines: Array): Array { let start = 0; let end = lines.length; while (start < end && !lines[start]!.trim()) start++; diff --git a/mcp/lib/markdown.ts b/mcp/lib/markdown.ts index 2f26306..6aacd2b 100644 --- a/mcp/lib/markdown.ts +++ b/mcp/lib/markdown.ts @@ -6,7 +6,7 @@ import GithubSlugger from "github-slugger"; * can be indented, as it is inside an `:::accordion-item`, and it closes on a line * of the same character, at least as long, with nothing else on it. */ -export function scan(markdown: string): { text: string; code: boolean }[] { +export function scan(markdown: string): Array<{ text: string; code: boolean }> { let fence: { char: string; length: number } | undefined; return markdown.split("\n").map((text) => { const marker = text.match(/^\s*(`{3,}|~{3,})(.*)$/); @@ -43,7 +43,7 @@ export function anchors(): (text: string) => string { } /** The cells of a markdown table row, with escaped pipes (`\|`) unescaped. */ -export function cells(row: string): string[] { +export function cells(row: string): Array { return row .trim() .replaceAll(/^\||\|$/g, "") diff --git a/mcp/lib/pages.test.ts b/mcp/lib/pages.test.ts index a387369..fe0a205 100644 --- a/mcp/lib/pages.test.ts +++ b/mcp/lib/pages.test.ts @@ -68,7 +68,7 @@ describe("The Button's introduction", () => { }); describe("findSections", () => { - const find = (...names: string[]) => { + const find = (...names: Array) => { const { found, missing } = findSections(button, names); return { found: found.map((heading) => heading.text), missing }; }; diff --git a/mcp/lib/pages.ts b/mcp/lib/pages.ts index 4ecefde..4732925 100644 --- a/mcp/lib/pages.ts +++ b/mcp/lib/pages.ts @@ -54,9 +54,9 @@ export function findPage(standard: Standard, name: string): Page | undefined { * it, like "DX", in US spelling, like "Colors", or singular, like "Toggle button". * The page's own title names its introduction, before its first heading. */ -export function findSections(page: Page, names: string[]): { found: Heading[]; missing: string[] } { - const found: Heading[] = []; - const missing: string[] = []; +export function findSections(page: Page, names: Array): { found: Array; missing: Array } { + const found: Array = []; + const missing: Array = []; const slug = (text: string) => anchors()(text); // Every way a heading can be named loosely: its text without "(DX)", and "DX". const loose = (text: string) => { diff --git a/mcp/lib/paging.ts b/mcp/lib/paging.ts index cf5bee4..d11e731 100644 --- a/mcp/lib/paging.ts +++ b/mcp/lib/paging.ts @@ -12,14 +12,14 @@ export const PAGE_SIZE = 50; * lost its place, while an empty list still has an empty first page. */ export function paginate( - items: T[], + items: Array, { offset = 0, limit = PAGE_SIZE }: { offset?: number; limit?: number } = {}, -): { total: number; items: T[]; nextOffset?: number } | { error: string } { +): { total: number; items: Array; nextOffset?: number } | { error: string } { if (offset > 0 && offset >= items.length) { return { error: `Only ${items.length} match, so there's nothing from offset ${offset}. Start at 0 and follow nextOffset.` }; } const end = offset + limit; - const page: { total: number; items: T[]; nextOffset?: number } = { total: items.length, items: items.slice(offset, end) }; + const page: { total: number; items: Array; nextOffset?: number } = { total: items.length, items: items.slice(offset, end) }; if (end < items.length) { page.nextOffset = end; } diff --git a/mcp/lib/prompts.test.ts b/mcp/lib/prompts.test.ts index 6dfb0bc..6645e8d 100644 --- a/mcp/lib/prompts.test.ts +++ b/mcp/lib/prompts.test.ts @@ -14,10 +14,10 @@ const component = (key: string) => standard.components.find((candidate) => candi const normalise = (text: string) => text.replaceAll(/\s+/g, " ").trim(); // The code blocks in a section, each with the framework slot it's in, if any. -function blocks(page: Page, heading: Heading): { framework?: string; text: string }[] { - const found: { framework?: string; text: string }[] = []; +function blocks(page: Page, heading: Heading): Array<{ framework?: string; text: string }> { + const found: Array<{ framework?: string; text: string }> = []; let framework: string | undefined; - let block: string[] | undefined; + let block: Array | undefined; // The blank line at the end closes a block that ends the section. for (const { text, code } of scan([...page.markdown.split("\n").slice(heading.start, heading.end), ""].join("\n"))) { if (code) { diff --git a/mcp/lib/rules.test.ts b/mcp/lib/rules.test.ts index 24b090c..75c8ceb 100644 --- a/mcp/lib/rules.test.ts +++ b/mcp/lib/rules.test.ts @@ -6,7 +6,7 @@ import type { CheckKind } from "./types"; describe("parseChecks", () => { // Every Check the checklists use today. One the server doesn't know shows up // as a problem when it's built (see standard.test.ts). - it.each<[string, CheckKind[], string[]]>([ + it.each<[string, Array, Array]>([ ["Review", ["review"], []], ["axe `color-contrast`", ["axe"], ["color-contrast"]], ["axe `target-size`", ["axe"], ["target-size"]], diff --git a/mcp/lib/rules.ts b/mcp/lib/rules.ts index 129a5b0..c8b2d0c 100644 --- a/mcp/lib/rules.ts +++ b/mcp/lib/rules.ts @@ -21,19 +21,19 @@ export const LEVELS = ["must", "should"] as const; export const SCOPES = ["component", "usage", "both"] as const; export const LAYERS = ["ui", "ux", "dx", "ax"] as const; -export const CHECK_KINDS = ["axe", ...new Set(Object.values(KINDS))] as [CheckKind, ...CheckKind[]]; +export const CHECK_KINDS = ["axe", ...new Set(Object.values(KINDS))] as [CheckKind, ...Array]; /** Checks that a tool runs, rather than a person. */ -export const AUTOMATED_CHECKS: CheckKind[] = ["unit-test", "axe", "type-check", "lint", "visual-regression"]; +export const AUTOMATED_CHECKS: Array = ["unit-test", "axe", "type-check", "lint", "visual-regression"]; /** * Reads a rule's Check cell, like "axe `button-name`, unit test", into the kinds * of check it names and the axe rules among them. Anything else is `unknown`. */ -export function parseChecks(check: string): { checks: CheckKind[]; axe: string[]; unknown: string[] } { - const checks: CheckKind[] = []; - const axe: string[] = []; - const unknown: string[] = []; +export function parseChecks(check: string): { checks: Array; axe: Array; unknown: Array } { + const checks: Array = []; + const axe: Array = []; + const unknown: Array = []; for (const part of check.split(/,(?=(?:[^`]*`[^`]*`)*[^`]*$)/)) { const value = part.trim().toLowerCase(); const rule = value.match(/^axe `([^`]+)`$/)?.[1]; diff --git a/mcp/lib/search.ts b/mcp/lib/search.ts index 399956e..b31daf8 100644 --- a/mcp/lib/search.ts +++ b/mcp/lib/search.ts @@ -39,7 +39,7 @@ const STOPWORDS = new Set( * A text's terms: lowercased words, without stopwords, and without a plural's * `s`. A contraction stays one word, so `don't` is `dont` rather than `don` and `t`. */ -export function terms(text: string): string[] { +export function terms(text: string): Array { return text .toLowerCase() .replaceAll("’", "'") @@ -56,7 +56,7 @@ export function terms(text: string): string[] { * `focused`), and results that match more of the query's terms come first. */ export function createSearch(standard: Standard) { - const documents: Document[] = []; + const documents: Array = []; // `text` is what an excerpt quotes, and `more` is searched without being quoted. const add = (component: string, result: SearchResult, title: string, text: string, more = "", weight = 1) => { const counts = new Map(); @@ -176,7 +176,7 @@ function prose(markdown: string, standard: Standard): string { } // About 200 characters around the first of the query's terms in a text. -function excerpt(text: string, wanted: string[]): string { +function excerpt(text: string, wanted: Array): string { const lower = text.toLowerCase(); const at = Math.min(...wanted.values().map((term) => lower.indexOf(term)).filter((index) => index >= 0), Infinity); if (text.length <= 220) return text; diff --git a/mcp/lib/standard.test.ts b/mcp/lib/standard.test.ts index 4b77aa5..5025fbb 100644 --- a/mcp/lib/standard.test.ts +++ b/mcp/lib/standard.test.ts @@ -197,11 +197,11 @@ describe("The standard", () => { // A repository of its own, which follows the conventions, for a change at a time // that breaks one: the build reports it as a problem, rather than failing. describe("buildStandard's problems", () => { - const roots: string[] = []; + const roots: Array = []; afterAll(() => roots.forEach((root) => rmSync(root, { recursive: true, force: true }))); const RULE = "| `widget/name` | Must | Component | It has a name | Review |"; - const component = (name: string, options: { rows?: string[]; table?: string; contract?: string; reference?: boolean } = {}) => { + const component = (name: string, options: { rows?: Array; table?: string; contract?: string; reference?: boolean } = {}) => { const { rows = [RULE], table = "### UI rules", contract = `component: ${name}`, reference = true } = options; return [ "---", @@ -227,7 +227,7 @@ describe("buildStandard's problems", () => { ...(reference ? ["## Reference implementation", "", "It's in Vue.", "", `\`\`\`vue [${name}.vue]`, "