@zgeoff/format-codemod 0.0.8 → 0.1.0

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.
@@ -3,9 +3,4 @@ export interface DiffOutput {
3
3
  readonly message: string | null;
4
4
  readonly stdout: string | null;
5
5
  }
6
- /**
7
- * Reached only when the file needs edits. Write mode saves the file here — the
8
- * one file-system effect below the entry; what to print is returned, never
9
- * printed, because the entry owns the output streams.
10
- */
11
6
  export declare function applyDiffMode(edit: FileEdit, mode: CLIMode): DiffOutput;
@@ -1,6 +1 @@
1
- /**
2
- * A real unified diff — @@ hunk headers with context — so --dry output can be
3
- * applied with patch(1). Inputs are expected to end with a newline, which
4
- * TypeScript sources do and the transform preserves.
5
- */
6
1
  export declare function buildUnifiedDiff(before: string, after: string, label: string): string;
@@ -1,7 +1 @@
1
- /**
2
- * Deduped: overlapping patterns (a `src/**` glob plus a file inside src/) must
3
- * not process — or report — the same file twice. Ignore globs filter the final
4
- * list uniformly, so a file is skipped whether it arrived via a directory,
5
- * a glob, or an explicit path argument.
6
- */
7
1
  export declare function expandInputs(patterns: readonly string[], ignore?: readonly string[]): Promise<string[]>;
@@ -1,8 +1 @@
1
- /**
2
- * Reads `.formatignore` from the given directory: one glob per line, blank
3
- * lines and `#`-prefixed comment lines skipped. Lines share --ignore's glob
4
- * semantics — this is not a gitignore dialect, so `!` negation and directory
5
- * anchoring don't apply. A missing file yields an empty list, so callers
6
- * merge unconditionally.
7
- */
8
1
  export declare function loadFormatIgnore(dir: string): readonly string[];
@@ -8,10 +8,4 @@ export interface CLIArgs {
8
8
  readonly ignore: readonly string[];
9
9
  readonly inputs: readonly string[];
10
10
  }
11
- /**
12
- * Strict parsing: an unknown flag is a usage error, not a silent no-op. That
13
- * matters because the default mode writes files — a typo'd --check must never
14
- * fall through to an in-place rewrite. CLIArgs is always an object, so the
15
- * string (error message) return is unambiguous.
16
- */
17
11
  export declare function parseCLIArgs(argv: readonly string[]): CLIArgs | string;
@@ -1,7 +1,2 @@
1
1
  import type { FileReport } from './types.ts';
2
- /**
3
- * Prints one file's outcome: the stdout payload (--dry diffs) to stdout,
4
- * messages and per-file progress to stderr. Quiet drops the OK/SKIP noise but
5
- * never the messages.
6
- */
7
2
  export declare function printReport(file: string, report: FileReport, quiet: boolean): void;
@@ -1,6 +1 @@
1
- /**
2
- * Reads the version field of the package manifest at the given path, throwing
3
- * when the file isn't a manifest. Callers own the path so it resolves against
4
- * their own location.
5
- */
6
1
  export declare function readPackageVersion(pkgPath: string): string;
@@ -1,7 +1,2 @@
1
1
  import type { CLIMode, FileReport } from './types.ts';
2
- /**
3
- * A failed file must fail the batch: --check would otherwise exit 0 having
4
- * validated nothing, and a throw would kill the process mid-batch with the
5
- * remaining files silently skipped.
6
- */
7
2
  export declare function tryCheckFile(file: string, mode: CLIMode): FileReport;
@@ -1,11 +1,6 @@
1
1
  import type { TransformResult } from '../types.ts';
2
2
  export type CLIMode = 'write' | 'check' | 'dry';
3
3
  export type FileOutcome = 'ok' | 'changed' | 'failed' | 'skipped';
4
- /**
5
- * Everything the entry needs to report one file: the outcome for exit-code
6
- * logic, sizes for --bench, and the text to print — modules below the entry
7
- * never write to stdout/stderr themselves.
8
- */
9
4
  export interface FileReport {
10
5
  readonly outcome: FileOutcome;
11
6
  readonly bytes: number;
@@ -1,7 +1,2 @@
1
1
  import type { Edit } from '../types.ts';
2
- /**
3
- * Callers must pass edits sorted last-to-first, so each splice's offsets stay
4
- * valid without adjustment. Segments are collected and joined once instead of
5
- * re-copying the whole string per edit.
6
- */
7
2
  export declare function applyEdits(src: string, edits: readonly Edit[]): string;
@@ -1,5 +1,2 @@
1
1
  import type { Edit, ParsedSource } from '../types.ts';
2
- /**
3
- * Sorted last-to-first so applying splices in order never shifts later offsets.
4
- */
5
2
  export declare function buildEditsFromAST(src: string, parsed: ParsedSource): Edit[];
@@ -1,6 +1,2 @@
1
1
  import type { ASTNode } from '../types.ts';
2
- /**
3
- * The AST nodes in a property value: the node itself, an array's node
4
- * elements, or nothing for non-node values.
5
- */
6
2
  export declare function collectASTNodes(value: unknown): ASTNode[];
@@ -1,6 +1,2 @@
1
1
  import type { ASTNode } from '../types.ts';
2
- /**
3
- * A node's direct child nodes across all properties, skipping the location
4
- * and parent back-references a traversal must not follow.
5
- */
6
2
  export declare function collectChildNodes(node: ASTNode): ASTNode[];
@@ -1,9 +1,2 @@
1
1
  import type { ASTNode } from '../types.ts';
2
- /**
3
- * The nodes on the walk from an expression to its head, outermost first and
4
- * ending at the head itself — `(await f()).prop` yields the member access,
5
- * the parenthesis, the await, the call, and finally `f`. Nodes outside the
6
- * walk (call arguments, ternary branches) never appear, so a scan of the
7
- * chain sees only what a reader meets before the expression's first token.
8
- */
9
2
  export declare function collectHeadChain(expression: ASTNode): ASTNode[];
@@ -1,14 +1,2 @@
1
1
  import type { ASTNode } from '../types.ts';
2
- /**
3
- * The "always" rules: a blank line between class members, after a var or
4
- * using block before a statement of any other kind, after a directive
5
- * prologue, after the last import of a block, before a return, after a
6
- * function/class declaration, on both sides of a type alias or interface
7
- * declaration, on both sides of a control-flow block — its closing brace
8
- * ends a visual unit just like its opening keyword starts one —
9
- * and at the boundary between statement kinds: bare call vs method call vs
10
- * expect assertion vs mutation, instantiation vs anything else, and awaited
11
- * vs non-awaited. Any
12
- * match means exactly one blank line; a pair matching no rule sits flush.
13
- */
14
2
  export declare function needsBlankLine(container: ASTNode, prev: ASTNode, next: ASTNode): boolean;
@@ -1,10 +1,2 @@
1
1
  import type { ParsedSource } from '../types.ts';
2
- /**
3
- * The filename picks the dialect — `.tsx` enables JSX, anything else parses as
4
- * plain TypeScript, so `.ts`-only syntax like `<string>value` assertions and
5
- * un-comma'd generic arrows parse correctly. oxc reports syntax errors as a
6
- * list instead of throwing; any error means node offsets can't be trusted for
7
- * splicing, so the first message is returned and the caller skips the file.
8
- * ParsedSource is always an object, so the string return is unambiguous.
9
- */
10
2
  export declare function parseSource(src: string, filename: string): ParsedSource | string;
@@ -1,20 +1,8 @@
1
1
  import type { ASTNode, Edit, SourceFile } from '../types.ts';
2
- /**
3
- * A pair of adjacent statements in a file and the gap shape they take: one
4
- * blank line between them when `pad` is set, none otherwise.
5
- */
6
2
  export interface GapEditInput {
7
3
  readonly file: SourceFile;
8
4
  readonly prev: ASTNode;
9
5
  readonly next: ASTNode;
10
6
  readonly pad: boolean;
11
7
  }
12
- /**
13
- * Plans the single whitespace splice that gives the gap between two statements
14
- * its target shape, or null when the gap is already compliant or unsafe to
15
- * touch. Collapsing never crosses a comment: prose between statements marks
16
- * grouping the padding rules can't see, so a comment-bearing gap only ever
17
- * grows. Comment positions come from the parser rather than lexical scanning,
18
- * so comment-lookalike text can't mislead the classification.
19
- */
20
8
  export declare function planGapEdit(input: GapEditInput): Edit | null;
@@ -1,13 +1,5 @@
1
1
  import type { TransformResult } from './types.ts';
2
2
  export interface TransformOptions {
3
- /**
4
- * Picks the parse dialect: `.tsx` enables JSX, anything else is plain
5
- * TypeScript. Defaults to 'source.ts' — JSX callers must say so.
6
- */
7
3
  readonly filename?: string;
8
4
  }
9
- /**
10
- * Pure transform: source string in, edited source string out, no I/O. On a
11
- * parse error the input is returned untouched alongside the error message.
12
- */
13
5
  export declare function transform(src: string, options?: TransformOptions): TransformResult;
package/dist/types.d.ts CHANGED
@@ -1,8 +1,3 @@
1
- /**
2
- * The fields of the oxc AST this transform reads; the index signature carries
3
- * every other node property so the generic child walk can recurse untyped. The
4
- * codemod never mutates the tree, so everything is readonly.
5
- */
6
1
  export interface ASTNode {
7
2
  readonly type: string;
8
3
  readonly kind?: string;
@@ -21,10 +16,6 @@ export interface ParsedSource {
21
16
  readonly program: ASTNode;
22
17
  readonly comments: readonly CommentSpan[];
23
18
  }
24
- /**
25
- * The raw text and its comment spans together — what gap planning needs to
26
- * classify inter-statement trivia without re-lexing.
27
- */
28
19
  export interface SourceFile {
29
20
  readonly src: string;
30
21
  readonly comments: readonly CommentSpan[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgeoff/format-codemod",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
4
4
  "description": "Enforce blank-line padding conventions in TypeScript via a fast text-splice codemod",
5
5
  "license": "MIT",
6
6
  "repository": {