Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Lint both suffix-rule probes in one oxlint run (#7733)
Nick Gomez84f33e4f8782
diff --git a/knip.config.ts b/knip.config.tsindex e04bf5228..fac2580fe 100644--- a/knip.config.ts+++ b/knip.config.ts@@ -157,11 +157,15 @@ export default {'src/shadow-fixture-launch.test-helper.mjs',],project: 'src/**',- ignoreDependencies: ['@types/shell-quote'],+ ignoreDependencies: [+ '@types/shell-quote',+ ],},'packages/cli': {entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],- ignoreDependencies: ['yjs'],+ ignoreDependencies: [+ 'yjs',+ ],},'packages/desktop': {entry: [diff --git a/lint-plugins/ok-rules/README.md b/lint-plugins/ok-rules/README.mdindex 4d42626e5..62ead4aa8 100644--- a/lint-plugins/ok-rules/README.md+++ b/lint-plugins/ok-rules/README.md@@ -712,7 +712,7 @@ Included: `**/*.ts`, `**/*.tsx`, `**/*.mts`, `**/*.cts`, `**/*.js`, `**/*.jsx`,The shared module owns the definition. The portability test inventories only the sibling dependency-free `.mjs` implementation modules; it does not classify TypeScript, and its test-file exclusion remains local. Scanners that deliberately inspect test helpers retain that scope rather than inheriting the production default.-The fixture pairs 15 violations with adjacent negatives. The self-test also plants a check under `scripts/` and invokes the real lint configuration, verifies the shared-predicate replacement passes, and removes the planted file. The rule and its self-test run in the existing lint and uncached test jobs.+The fixture pairs 15 violations with adjacent negatives. The self-test also plants a check and its shared-predicate replacement side by side under `scripts/`, lints both with the real lint configuration in one invocation, expects the diagnostic on the planted check alone, and removes both files. One invocation pays the type-aware startup once rather than once per file. The rule and its self-test run in the existing lint and uncached test jobs.Rule: [`no-hand-rolled-test-file-suffix.mjs`](rules/no-hand-rolled-test-file-suffix.mjs). Fixture: [`no-hand-rolled-test-file-suffix.fixture.tsx`](__fixtures__/no-hand-rolled-test-file-suffix.fixture.tsx). Test: [`no-hand-rolled-test-file-suffix.uncached.test.mjs`](tests/no-hand-rolled-test-file-suffix.uncached.test.mjs).diff --git a/lint-plugins/ok-rules/tests/no-hand-rolled-test-file-suffix.uncached.test.mjs b/lint-plugins/ok-rules/tests/no-hand-rolled-test-file-suffix.uncached.test.mjsindex b24d4b892..9e88bd50c 100644--- a/lint-plugins/ok-rules/tests/no-hand-rolled-test-file-suffix.uncached.test.mjs+++ b/lint-plugins/ok-rules/tests/no-hand-rolled-test-file-suffix.uncached.test.mjs@@ -1,6 +1,6 @@import { spawnSync } from 'node:child_process';import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';-import { join } from 'node:path';+import { join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { describe, expect, test } from 'vitest';import {@@ -15,21 +15,26 @@ const RULE = 'no-hand-rolled-test-file-suffix';const FIXTURE = `lint-plugins/ok-rules/__fixtures__/${RULE}.fixture.tsx`;const README = 'lint-plugins/ok-rules/README.md';-function lint(args) {- const result = spawnSync(join(ROOT, 'node_modules/.bin/oxlint'), ['-f', 'json', ...args], {- cwd: ROOT,- encoding: 'utf8',- windowsHide: true,- maxBuffer: 64 * 1024 * 1024,- });+function lint(files) {+ const result = spawnSync(+ join(ROOT, 'node_modules/.bin/oxlint'),+ ['-f', 'json', '--max-warnings', '0', ...files],+ {+ cwd: ROOT,+ encoding: 'utf8',+ windowsHide: true,+ maxBuffer: 64 * 1024 * 1024,+ },+ );expect(result.error).toBeUndefined();expect(typeof result.status).toBe('number');const output = JSON.parse(result.stdout);- expect(output.number_of_files).toBe(1);+ expect(output.number_of_files).toBe(files.length);expect(output.number_of_rules).toBeGreaterThan(0);return {status: result.status,- diagnostics: output.diagnostics.filter((diagnostic) => diagnostic.code === `ok(${RULE})`),+ diagnosticsIn: (file) =>+ output.diagnostics.filter((diagnostic) => resolve(ROOT, diagnostic.filename) === file),};}@@ -66,19 +71,20 @@ describe('shared test-file predicate enforcement', () => {test('the real lint configuration rejects a planted check and accepts the shared predicate', () => {const dir = mkdtempSync(join(ROOT, 'scripts/test-file-predicate-'));- const file = join(dir, 'probe.ts');+ const planted = join(dir, 'planted.ts');+ const shared = join(dir, 'shared.ts');try {- writeFileSync(file, "export const probe = (path: string) => path.endsWith('.test.ts');\n");- const positive = lint(['--max-warnings', '0', file]);- expect(positive.status).toBe(1);- expect(positive.diagnostics).toHaveLength(1);+ writeFileSync(planted, "export const probe = (path: string) => path.endsWith('.test.ts');\n");writeFileSync(- file,+ shared,"import { isTestOnlySourceFile } from '../../test-support/test-only-source-file.mjs';\nexport const probe = (path: string) => isTestOnlySourceFile(path);\n",);- const negative = lint(['--max-warnings', '0', file]);- expect(negative.status).toBe(0);- expect(negative.diagnostics).toEqual([]);+ const result = lint([planted, shared]);+ expect(result.status).toBe(1);+ expect(+ result.diagnosticsIn(planted).filter((diagnostic) => diagnostic.code === `ok(${RULE})`),+ ).toHaveLength(1);+ expect(result.diagnosticsIn(shared)).toEqual([]);} finally {rmSync(dir, { recursive: true, force: true });}@@ -104,8 +110,9 @@ describe('shared test-file predicate enforcement', () => {expect(prose).toContain(`### \`${RULE}\``);expect(prose).toContain(`rules/${RULE}.mjs`);expect(prose).toContain('Scanners classify test-only TypeScript through');- const excluded = lint(['--max-warnings', '0', 'lint-plugins/no-comments/portability.test.mjs']);+ const exempt = join(ROOT, 'lint-plugins/no-comments/portability.test.mjs');+ const excluded = lint([exempt]);expect(excluded.status).toBe(0);- expect(excluded.diagnostics).toEqual([]);+ expect(excluded.diagnosticsIn(exempt)).toEqual([]);});});diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.tsindex a50b00123..4549c74b3 100644--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts@@ -1,3 +1,4 @@+import { readFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.tsindex 6fcdc23f2..4fc2c11f9 100644--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { normalizeBridge } from '@inkeep/open-knowledge-core';import { updateYFragment } from '@tiptap/y-tiptap';diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.tsindex 40b5cdfd6..9f2f6feb6 100644--- a/packages/app/tests/integration/interior-edit-freshness.test.ts+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.tsindex 93666af70..2a085742b 100644--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.tsindex 867598d34..878d5196b 100644--- a/packages/app/tests/integration/producer-guard-wiring.test.ts+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts@@ -1,3 +1,4 @@+import { setTimeout as wait } from 'node:timers/promises';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';import { afterAll, beforeAll, describe, expect, test } from 'vitest';diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.tsindex 0970ac12f..4ada3cf26 100644--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts@@ -1,3 +1,4 @@+import { randomUUID } from 'node:crypto';import { afterEach, describe, expect, test } from 'vitest';import { agentWriteMd, createTestServer, type TestServer } from './test-harness';diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.tsindex b632185e1..cbe2b705f 100644--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts@@ -1,3 +1,4 @@+import { execFileSync } from 'node:child_process';import { randomUUID } from 'node:crypto';import { join } from 'node:path';diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.tsindex c530ce4ba..89bc9b4d9 100644--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts@@ -1,3 +1,4 @@+import { randomUUID } from 'node:crypto';import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';import type * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.tsindex d3767adc9..a78aeb0e4 100644--- a/packages/app/tests/integration/undo-after-rollback.test.ts+++ b/packages/app/tests/integration/undo-after-rollback.test.ts@@ -1,3 +1,4 @@+import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';import { afterAll, beforeAll, describe, expect, test } from 'vitest';import * as Y from 'yjs';diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.tsindex b076f955c..e7cc69c3f 100644--- a/packages/app/tests/integration/undo-recycle-reset.test.ts+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts@@ -1,3 +1,4 @@+import { writeFileSync } from 'node:fs';import { join } from 'node:path';import { setTimeout as wait } from 'node:timers/promises';diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.tsindex 7935e35f8..9ddcd0730 100644--- a/packages/app/tests/integration/undo-rederive-survival.test.ts+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts@@ -1,3 +1,4 @@+import { prependFrontmatter } from '@inkeep/open-knowledge-core';import { Plugin, PluginKey } from '@tiptap/pm/state';import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.tsindex f4cc8a286..2a597ec3d 100644--- a/packages/core/src/bridge/compose.ts+++ b/packages/core/src/bridge/compose.ts@@ -1,3 +1,4 @@+import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.tsindex e7e63f43d..ffd8fce06 100644--- a/packages/core/src/bridge/doc-boundary-space.ts+++ b/packages/core/src/bridge/doc-boundary-space.ts@@ -1,3 +1,4 @@+import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.tsindex fc267cbea..fb0ba5a7c 100644--- a/packages/core/src/markdown/comment-promoter.ts+++ b/packages/core/src/markdown/comment-promoter.ts@@ -1,3 +1,4 @@+import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.tsindex 861003fb4..ae8cb390b 100644--- a/packages/core/src/markdown/merged-walker.ts+++ b/packages/core/src/markdown/merged-walker.ts@@ -1,3 +1,4 @@+import type { Nodes, Parent, Root } from 'mdast';import { SKIP, visit } from 'unist-util-visit';import type { VFile } from 'vfile';diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.tsindex 4d3250d3a..8be632ba4 100644--- a/packages/core/src/markdown/safe-url.ts+++ b/packages/core/src/markdown/safe-url.ts@@ -1,3 +1,4 @@+export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');