From ed099a093dd86ce6c8f26bb1f846c4d6083ceddf Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 18 Sep 2026 23:03:13 +0200 Subject: [PATCH] =?UTF-8?q?AGENTS.md=20=C2=A711:=20a=20sort=20keys=20on=20?= =?UTF-8?q?the=20name=20a=20line=20introduces,=20so=20an=20import=20sorts?= =?UTF-8?q?=20on=20its=20first=20binding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 4 +++- browser-tests/run.js | 2 +- src/adf-property.test.ts | 2 +- src/adf-schema.test.ts | 6 +++--- src/commonmark-spec.test.ts | 4 ++-- src/corpus.test.ts | 4 ++-- src/flavour.test.ts | 4 ++-- src/markdown-property.test.ts | 2 +- src/markdown/commonmark/entity-references.test.ts | 4 ++-- src/markdown/emit/image.ts | 2 +- src/markdown/emit/line-escaping.ts | 4 ++-- src/markdown/emit/pipe-table.ts | 2 +- src/markdown/opaque-carry.ts | 2 +- src/markdown/parse/blocks.ts | 2 +- src/markdown/parse/inline-content.ts | 2 +- src/property-harness.ts | 2 +- src/result.test.ts | 4 ++-- 17 files changed, 27 insertions(+), 25 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e005118..93bb31f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -266,7 +266,9 @@ someone spells it or pins it. ## 11. Code rules - Two-space indent, strict TypeScript, English everywhere. Alphabetical order wherever order - carries no meaning. + carries no meaning, keyed on the name a line introduces rather than where it came from: an + import sorts on its first binding, type imports ahead of value imports, so moving or renaming a + module reorders nothing (the maintainer, 2026-09-18). - Failures are values: everything returns `Result` — `{ ok: true; value } | { ok: false; error: ConvertError }` — nothing throws. `try/catch` only wrapped tightly around a call that genuinely throws, converted to a result on diff --git a/browser-tests/run.js b/browser-tests/run.js index 3967467..0369402 100644 --- a/browser-tests/run.js +++ b/browser-tests/run.js @@ -1,7 +1,7 @@ import assert from 'node:assert/strict' -import { readFileSync, readdirSync } from 'node:fs' import { createServer } from 'node:http' import { extname, join } from 'node:path' +import { readFileSync, readdirSync } from 'node:fs' import { toEditorNormal } from '../dist/adf/editor-normal.js' const contentTypes = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript' } diff --git a/src/adf-property.test.ts b/src/adf-property.test.ts index 41e4410..f52789e 100644 --- a/src/adf-property.test.ts +++ b/src/adf-property.test.ts @@ -1,5 +1,5 @@ -import fc from 'fast-check' import assert from 'node:assert/strict' +import fc from 'fast-check' import test from 'node:test' import { adfDocument, propertyRuns, propertyTimeout } from './property-harness.ts' diff --git a/src/adf-schema.test.ts b/src/adf-schema.test.ts index 06ad808..377b007 100644 --- a/src/adf-schema.test.ts +++ b/src/adf-schema.test.ts @@ -1,15 +1,15 @@ import assert from 'node:assert/strict' import { createHash } from 'node:crypto' -import { readFileSync } from 'node:fs' import { dirname, join } from 'node:path' -import test from 'node:test' import { fileURLToPath } from 'node:url' +import { readFileSync } from 'node:fs' +import test from 'node:test' import type { AttributeKind, AttributeVocabulary } from './adf/attribute-vocabulary.ts' +import { blockArgument } from './markdown/block-directive-arguments.ts' import { blockDirectives } from './adf/block-directives.ts' import { inlineDirectives } from './adf/inline-directives.ts' import { markAttributes } from './adf/mark-attributes.ts' -import { blockArgument } from './markdown/block-directive-arguments.ts' type Held = Map> type Properties = Map diff --git a/src/commonmark-spec.test.ts b/src/commonmark-spec.test.ts index 3bfc714..6026c62 100644 --- a/src/commonmark-spec.test.ts +++ b/src/commonmark-spec.test.ts @@ -1,9 +1,9 @@ import assert from 'node:assert/strict' import { createHash } from 'node:crypto' -import { readFileSync } from 'node:fs' import { dirname, join } from 'node:path' -import test from 'node:test' import { fileURLToPath } from 'node:url' +import { readFileSync } from 'node:fs' +import test from 'node:test' import type { AdfDocument, AdfNode } from './adf/document.ts' import { adfToMarkdown } from './markdown/emit/adf-to-markdown.ts' diff --git a/src/corpus.test.ts b/src/corpus.test.ts index e7577f2..6f0d122 100644 --- a/src/corpus.test.ts +++ b/src/corpus.test.ts @@ -1,8 +1,8 @@ import assert from 'node:assert/strict' -import { readFileSync, readdirSync } from 'node:fs' import { basename, dirname, join, sep } from 'node:path' -import test from 'node:test' import { fileURLToPath } from 'node:url' +import { readFileSync, readdirSync } from 'node:fs' +import test from 'node:test' import { adfToMarkdown } from './markdown/emit/adf-to-markdown.ts' import { isAdfDocument } from './adf/document.ts' diff --git a/src/flavour.test.ts b/src/flavour.test.ts index 9017051..bad497a 100644 --- a/src/flavour.test.ts +++ b/src/flavour.test.ts @@ -1,8 +1,8 @@ import assert from 'node:assert/strict' -import { readFileSync } from 'node:fs' import { dirname, join } from 'node:path' -import test from 'node:test' import { fileURLToPath } from 'node:url' +import { readFileSync } from 'node:fs' +import test from 'node:test' import type { AttributeKind, AttributeVocabulary } from './adf/attribute-vocabulary.ts' import { blockDirectives } from './adf/block-directives.ts' diff --git a/src/markdown-property.test.ts b/src/markdown-property.test.ts index 44af8cf..1cc7933 100644 --- a/src/markdown-property.test.ts +++ b/src/markdown-property.test.ts @@ -1,5 +1,5 @@ -import fc from 'fast-check' import assert from 'node:assert/strict' +import fc from 'fast-check' import test from 'node:test' import type { AdfDocument } from './adf/document.ts' diff --git a/src/markdown/commonmark/entity-references.test.ts b/src/markdown/commonmark/entity-references.test.ts index 6767876..fc0c65f 100644 --- a/src/markdown/commonmark/entity-references.test.ts +++ b/src/markdown/commonmark/entity-references.test.ts @@ -1,8 +1,8 @@ import assert from 'node:assert/strict' -import { readFileSync } from 'node:fs' import { dirname, join } from 'node:path' -import test from 'node:test' import { fileURLToPath } from 'node:url' +import { readFileSync } from 'node:fs' +import test from 'node:test' import { readEntityReference } from './entity-references.ts' diff --git a/src/markdown/emit/image.ts b/src/markdown/emit/image.ts index 3b318d9..be6828e 100644 --- a/src/markdown/emit/image.ts +++ b/src/markdown/emit/image.ts @@ -1,6 +1,6 @@ import type { AdfNode } from '../../adf/document.ts' -import { carriesOnly, nodeAttrs, nodeContent } from '../../adf/document.ts' import type { ConvertErrorPath } from '../../result.ts' +import { carriesOnly, nodeAttrs, nodeContent } from '../../adf/document.ts' import { serializeCanonicalJson } from '../../canonical-json.ts' import { tryImageLine } from './inline-line.ts' diff --git a/src/markdown/emit/line-escaping.ts b/src/markdown/emit/line-escaping.ts index 6011ccf..379f232 100644 --- a/src/markdown/emit/line-escaping.ts +++ b/src/markdown/emit/line-escaping.ts @@ -1,7 +1,7 @@ -import { backtickRun, closingBacktickRun } from '../commonmark/backtick-runs.ts' -import { delimiterFlags, isWordCharacter, matchEmphasis, runLength } from '../commonmark/emphasis-matching.ts' import { backslashEscape, escapesLineClaim, inlineHtmlConstruct, opensBracketedAutolink, opensEmailAutolink, type LinePosition } from '../commonmark/grammar.ts' +import { backtickRun, closingBacktickRun } from '../commonmark/backtick-runs.ts' import { claimsDirectivePrefix } from '../directive-syntax.ts' +import { delimiterFlags, isWordCharacter, matchEmphasis, runLength } from '../commonmark/emphasis-matching.ts' import { isBareDelimiterRow } from '../pipe-table-syntax.ts' import { opensLinkDefinition } from '../commonmark/link-reference-definitions.ts' import { readEntityReference } from '../commonmark/entity-references.ts' diff --git a/src/markdown/emit/pipe-table.ts b/src/markdown/emit/pipe-table.ts index c57e5fc..b3234fd 100644 --- a/src/markdown/emit/pipe-table.ts +++ b/src/markdown/emit/pipe-table.ts @@ -1,8 +1,8 @@ import type { AdfNode } from '../../adf/document.ts' +import type { ConvertErrorPath } from '../../result.ts' import { carriesOnly, nodeContent } from '../../adf/document.ts' import { spellPipeDelimiter, spellPipeRow } from '../pipe-table-syntax.ts' import { tryPipeCell } from './inline-line.ts' -import type { ConvertErrorPath } from '../../result.ts' export function tryPipeTable(node: AdfNode, path: ConvertErrorPath): string | undefined { const rows = pipeRows(node) diff --git a/src/markdown/opaque-carry.ts b/src/markdown/opaque-carry.ts index c79b4a9..0e03467 100644 --- a/src/markdown/opaque-carry.ts +++ b/src/markdown/opaque-carry.ts @@ -2,9 +2,9 @@ import type { AdfNode } from '../adf/document.ts' import type { DirectiveSpan, Read } from './directive-syntax.ts' import type { JsonSpelling } from '../canonical-json.ts' import { failure, success, type ConvertErrorPath, type Result } from '../result.ts' +import { fencedCodeBlock } from './commonmark/backtick-runs.ts' import { isAdfNode } from '../adf/document.ts' import { isJsonValue, nestingDepth, overNested } from '../json-value.ts' -import { fencedCodeBlock } from './commonmark/backtick-runs.ts' import { largestNesting } from '../nesting.ts' import { malformedDirective, readSoleStringAttribute, spellAttributes, spellInlineLeafDirective, spellStringAttribute, unsupportedNodeShape } from './directive-syntax.ts' import { serializeCanonicalJson } from '../canonical-json.ts' diff --git a/src/markdown/parse/blocks.ts b/src/markdown/parse/blocks.ts index a6a672e..4ff6c24 100644 --- a/src/markdown/parse/blocks.ts +++ b/src/markdown/parse/blocks.ts @@ -18,9 +18,9 @@ import { thematicBreakTail, type ThematicBreakTail, } from '../commonmark/grammar.ts' +import { barePipeCells, isDelimiterRow, isPipeAlignment, isPipeDelimiter, malformedPipeTable, pipeCells } from '../pipe-table-syntax.ts' import { blockDirectiveForm } from '../block-directive-forms.ts' import { directiveEscape, malformedDirective, readDirectiveLine, spellDirectiveCloser } from '../directive-syntax.ts' -import { barePipeCells, isDelimiterRow, isPipeAlignment, isPipeDelimiter, malformedPipeTable, pipeCells } from '../pipe-table-syntax.ts' import { readLinkDefinitions } from '../commonmark/link-reference-definitions.ts' export type Block = { position: SourcePosition } & ( diff --git a/src/markdown/parse/inline-content.ts b/src/markdown/parse/inline-content.ts index 8c7b281..f140edd 100644 --- a/src/markdown/parse/inline-content.ts +++ b/src/markdown/parse/inline-content.ts @@ -10,12 +10,12 @@ import { delimiterFlags, matchEmphasis, runLength } from '../commonmark/emphasis import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts' import { inlineDirective } from '../../adf/inline-directives.ts' import { mergeAdjacentText } from '../../adf/editor-normal.ts' +import { noSpans, readInlineDirective } from '../directive-syntax.ts' import { nodeAttrs, nodeMarks } from '../../adf/document.ts' import { normalizeLabel, readInlineTarget, readLabel } from '../commonmark/link-syntax.ts' import { openingLinkTakesDirective } from '../emit/inline-line.ts' import { readCarriedInline } from '../opaque-carry.ts' import { readDirectiveMark } from './directive-marks.ts' -import { noSpans, readInlineDirective } from '../directive-syntax.ts' import { readInlineDirectiveNode } from './directive-nodes.ts' import { readTextDirective } from '../text-directive.ts' diff --git a/src/property-harness.ts b/src/property-harness.ts index c3c81c0..5054700 100644 --- a/src/property-harness.ts +++ b/src/property-harness.ts @@ -1,6 +1,6 @@ -import fc from 'fast-check' import assert from 'node:assert/strict' import { env } from 'node:process' +import fc from 'fast-check' import type { AdfAttributes, AdfDocument, AdfMark, AdfNode } from './adf/document.ts' import type { Arbitrary } from 'fast-check' diff --git a/src/result.test.ts b/src/result.test.ts index f30ae80..d672ad0 100644 --- a/src/result.test.ts +++ b/src/result.test.ts @@ -1,8 +1,8 @@ import assert from 'node:assert/strict' -import { readFileSync, readdirSync } from 'node:fs' import { dirname, join } from 'node:path' -import test from 'node:test' import { fileURLToPath } from 'node:url' +import { readFileSync, readdirSync } from 'node:fs' +import test from 'node:test' const sourceRoot = dirname(fileURLToPath(import.meta.url)) const union = /export type ConvertErrorCode =\n((?:\s+\| '[a-z-]+'\n)+)/