Skip to content

Commit 8605bd7

Browse files
committed
Use import type for type-only imports
oxlint's consistent-type-imports autofix has matured since the disable was written; it correctly identifies the type-only import names and emits separate `import type` declarations. Followed up the autofix with a small merge pass to combine the new `import type { X }` and the remaining `import { Y }` from the same module into a single `import { type X, Y }` statement, which keeps the import block tidy and resolves the no-duplicate-imports complaint. Inline `import("module").Type` annotations were left alone: hoisting them would either create circular imports or expand the import block for a one-off reference. The rule is configured with `disallowTypeAnnotations: false` so it keeps the top-level form enforced while permitting the inline form. Drops the `typescript/consistent-type-imports` disable. Tests stayed green (server 2634, format 186, binary unit 557, client all).
1 parent ca0c513 commit 8605bd7

92 files changed

Lines changed: 213 additions & 192 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.oxlintrc.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@
120120
// impls are sync).
121121
"require-await": "off",
122122

123-
// Autofix rewrites `import { X }` to `import type { X }` based on
124-
// type-position usage, but misses runtime usages (class
125-
// constructors, static members) and breaks the build.
126-
"typescript/consistent-type-imports": "off",
123+
// Inline `import("module").Type` annotations are used in places where
124+
// hoisting to a top-level import would create a circular import or
125+
// expand the import block for a one-off type reference. Keep the
126+
// top-level `import { X }` -> `import type { X }` enforcement active
127+
// (controlled by `prefer: "type-imports"`) but allow the inline form.
128+
"typescript/consistent-type-imports": ["error", { "disallowTypeAnnotations": false }],
127129

128130
// `T[]` and `Array<T>` are both idiomatic; forcing one is churn.
129131
"typescript/array-type": "off",

binary/src/ie-common/canonical-reader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* one format could grow a snapshot field the others didn't get.
2020
*/
2121

22-
import { z } from "zod";
22+
import type { z } from "zod";
2323
import { parseWithSchemaValidation } from "../schema-validation";
2424
import type { ParseResult } from "../types";
2525

binary/src/ie-common/json-snapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* silently get an out-of-sync result.
1919
*/
2020

21-
import { z } from "zod";
21+
import type { z } from "zod";
2222
import { parseWithSchemaValidation } from "../schema-validation";
2323
import type { BinaryParser, ParseOptions, ParseResult } from "../types";
2424

binary/src/map/canonical-reader.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* from a parsed display tree (ParseResult).
44
*/
55

6-
import { z } from "zod";
6+
import type { z } from "zod";
77
import { clampNumericValue } from "../binary-format-contract";
88
import { parseWithSchemaValidation } from "../schema-validation";
99
import { walkGroup } from "../spec/walk-display";
@@ -31,17 +31,16 @@ import {
3131
timerSlotPresentation,
3232
} from "./specs/script-slot";
3333
import {
34+
type mapTileElevationSchema,
35+
type mapScriptSlotSchema,
36+
type mapScriptSectionSchema,
37+
type mapObjectSchema,
38+
type mapObjectsSchema,
3439
mapCanonicalDocumentSchema,
3540
mapCanonicalSnapshotSchema,
36-
mapTileElevationSchema,
37-
mapScriptSlotSchema,
38-
mapScriptSectionSchema,
39-
mapObjectSchema,
40-
mapObjectsSchema,
4141
type MapCanonicalDocument,
4242
type MapCanonicalSnapshot,
4343
} from "./canonical-schemas";
44-
4544
function isGroup(entry: ParsedField | ParsedGroup): entry is ParsedGroup {
4645
return "fields" in entry;
4746
}

binary/src/map/canonical-writer.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Writer helpers for serializing MapCanonicalDocument back to binary MAP format bytes.
33
*/
44

5-
import { z } from "zod";
5+
import type { z } from "zod";
66
import { BufferWriter } from "typed-binary";
77
import { decodeOpaqueRange } from "../opaque-range";
88
import { toTypedBinarySchema } from "../spec/derive-typed-binary";
@@ -22,19 +22,18 @@ import { objectBaseSpec, inventoryHeaderSpec, critterDataSpec, exitGridSpec } fr
2222
import { hasElevation } from "./types";
2323
import type { ParseOpaqueRange } from "../types";
2424
import {
25-
mapHeaderSchema,
26-
mapTileElevationSchema,
27-
mapScriptSectionSchema,
28-
mapScriptSlotSchema,
29-
mapObjectSchema,
30-
mapObjectsSchema,
25+
type mapHeaderSchema,
26+
type mapTileElevationSchema,
27+
type mapScriptSectionSchema,
28+
type mapScriptSlotSchema,
29+
type mapObjectSchema,
30+
type mapObjectsSchema,
3131
MAP_OBJECT_BASE_SIZE,
3232
MAP_OBJECT_DATA_HEADER_SIZE,
3333
PID_TYPE_CRITTER,
3434
PID_TYPE_MISC,
3535
type MapCanonicalDocument,
3636
} from "./canonical-schemas";
37-
3837
const headerCodec = toTypedBinarySchema(mapHeaderSpec);
3938
const varSectionCodec = toTypedBinarySchema<typeof varSectionSpec, VarSectionCtx>(varSectionSpec);
4039
const otherSlotCodec = toTypedBinarySchema(otherSlotSpec);

binary/src/schema-validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z } from "zod";
1+
import type { z } from "zod";
22

33
type PathSegment = PropertyKey;
44

binary/src/spec/codec-meta.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
type MaxValue,
23
u8,
34
u16,
45
u32,
@@ -7,13 +8,11 @@ import {
78
i32,
89
Schema,
910
Measurer,
10-
MaxValue,
1111
type ISchema,
1212
type ISerialInput,
1313
type ISerialOutput,
1414
type IMeasurer,
1515
} from "typed-binary";
16-
1716
type NumericTypeName = "uint8" | "uint16" | "uint24" | "uint32" | "int8" | "int16" | "int24" | "int32";
1817

1918
/**

client/src/dialog-tree/dialogTree-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* then parsed). Uses shared panel infrastructure from ./shared.ts.
55
*/
66

7-
import * as vscode from "vscode";
8-
import { LanguageClient } from "vscode-languageclient/node";
7+
import type * as vscode from "vscode";
8+
import type { LanguageClient } from "vscode-languageclient/node";
99
import { escapeHtml, registerDialogPanel, type DialogPreviewController } from "./shared";
1010
import type {
1111
DDialogData,

client/src/dialog-tree/dialogTree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Uses shared panel infrastructure from ./shared.ts.
44
*/
55

6-
import * as vscode from "vscode";
7-
import { LanguageClient } from "vscode-languageclient/node";
6+
import type * as vscode from "vscode";
7+
import type { LanguageClient } from "vscode-languageclient/node";
88
import type { SSLDialogData, SSLDialogNode, SSLDialogOption } from "../../../shared/dialog-types";
99
import { escapeHtml, registerDialogPanel, type DialogPreviewController } from "./shared";
1010

client/src/dialog-tree/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import * as vscode from "vscode";
1010
import * as path from "path";
1111
import { randomBytes } from "crypto";
12-
import { type ExecuteCommandParams, LanguageClient, ExecuteCommandRequest } from "vscode-languageclient/node";
12+
import { type LanguageClient, type ExecuteCommandParams, ExecuteCommandRequest } from "vscode-languageclient/node";
1313
import { conlog } from "../logging";
1414
import { escapeHtml } from "../utils";
1515
import { getCachedCssAsset, getCachedHtmlAsset, getCachedJsAsset } from "../webview-assets";

0 commit comments

Comments
 (0)