Skip to content

Commit 3f3d646

Browse files
committed
refactor(linter/plugins): imports use .ts extension (#16390)
Pure refactor. Use `.ts` extension when importing `.ts` files.
1 parent f29e7a5 commit 3f3d646

28 files changed

+83
-82
lines changed

apps/oxlint/src-js/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { lint } from "./bindings.js";
2-
import { debugAssertIsNonNull } from "./utils/asserts.js";
2+
import { debugAssertIsNonNull } from "./utils/asserts.ts";
33

44
// Lazy-loaded JS plugin-related functions.
55
// Using `typeof wrapper` here makes TS check that the function signatures of `loadPlugin` and `loadPluginWrapper`
@@ -21,7 +21,7 @@ function loadPluginWrapper(path: string, packageName: string | null): Promise<st
2121
if (loadPlugin === null) {
2222
// Use promises here instead of making `loadPluginWrapper` an async function,
2323
// to avoid a micro-tick and extra wrapper `Promise` in all later calls to `loadPluginWrapper`
24-
return import("./plugins/index.js").then((mod) => {
24+
return import("./plugins/index.ts").then((mod) => {
2525
({ loadPlugin, lintFile, setupConfigs } = mod);
2626
return loadPlugin(path, packageName);
2727
});

apps/oxlint/src-js/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Functions and classes
2-
export { definePlugin, defineRule } from "./package/define.js";
3-
export { RuleTester } from "./package/rule_tester.js";
2+
export { definePlugin, defineRule } from "./package/define.ts";
3+
export { RuleTester } from "./package/rule_tester.ts";
44

55
// ESTree types
66
export type * as ESTree from "./generated/types.d.ts";

apps/oxlint/src-js/package/define.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* `definePlugin` and `defineRule` functions.
33
*/
44

5-
import { debugAssertIsNonNull } from "../utils/asserts.js";
5+
import { debugAssertIsNonNull } from "../utils/asserts.ts";
66

77
import type { Context, FileContext, LanguageOptions } from "../plugins/context.ts";
88
import type { CreateOnceRule, Plugin, Rule } from "../plugins/load.ts";

apps/oxlint/src-js/package/parse.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import {
33
rawTransferSupported as rawTransferSupportedBinding,
44
parseRawSync,
55
} from "../bindings.js";
6-
import { debugAssert, debugAssertIsNonNull } from "../utils/asserts.js";
7-
import { buffers } from "../plugins/lint.js";
8-
import { BUFFER_SIZE, BUFFER_ALIGN, DATA_POINTER_POS_32 } from "../generated/constants.js";
6+
import { debugAssert, debugAssertIsNonNull } from "../utils/asserts.ts";
7+
import { buffers } from "../plugins/lint.ts";
8+
import { BUFFER_SIZE, BUFFER_ALIGN, DATA_POINTER_POS_32 } from "../generated/constants.ts";
99

10-
import type { BufferWithArrays } from "../plugins/types.js";
10+
import type { BufferWithArrays } from "../plugins/types.ts";
1111

1212
// Size array buffer for raw transfer
1313
const ARRAY_BUFFER_SIZE = BUFFER_SIZE + BUFFER_ALIGN;

apps/oxlint/src-js/package/rule_tester.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
import { default as assert, AssertionError } from "node:assert";
1111
import util from "node:util";
1212
import stringify from "json-stable-stringify-without-jsonify";
13-
import { registerPlugin, registeredRules } from "../plugins/load.js";
14-
import { lintFileImpl, resetFile } from "../plugins/lint.js";
15-
import { getLineColumnFromOffset, getNodeByRangeIndex } from "../plugins/location.js";
13+
import { registerPlugin, registeredRules } from "../plugins/load.ts";
14+
import { lintFileImpl, resetFile } from "../plugins/lint.ts";
15+
import { getLineColumnFromOffset, getNodeByRangeIndex } from "../plugins/location.ts";
1616
import {
1717
allOptions,
1818
initAllOptions,
1919
mergeOptions,
2020
DEFAULT_OPTIONS_ID,
21-
} from "../plugins/options.js";
22-
import { diagnostics, replacePlaceholders, PLACEHOLDER_REGEX } from "../plugins/report.js";
23-
import { parse } from "./parse.js";
24-
import { debugAssert, debugAssertIsNonNull } from "../utils/asserts.js";
21+
} from "../plugins/options.ts";
22+
import { diagnostics, replacePlaceholders, PLACEHOLDER_REGEX } from "../plugins/report.ts";
23+
import { parse } from "./parse.ts";
24+
import { debugAssert, debugAssertIsNonNull } from "../utils/asserts.ts";
2525

2626
import type { RequireAtLeastOne } from "type-fest";
2727
import type { Plugin, Rule } from "../plugins/load.ts";

apps/oxlint/src-js/plugins/comments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* `SourceCode` methods related to comments.
33
*/
44

5-
import { ast, initAst, sourceText } from "./source_code.js";
6-
import { debugAssertIsNonNull } from "../utils/asserts.js";
5+
import { ast, initAst, sourceText } from "./source_code.ts";
6+
import { debugAssertIsNonNull } from "../utils/asserts.ts";
77

88
import type { Comment, Node, NodeOrToken } from "./types.ts";
99

apps/oxlint/src-js/plugins/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { setOptions } from "./options.js";
1+
import { setOptions } from "./options.ts";
22

33
/**
44
* Populates Rust-resolved configuration options on the JS side.

apps/oxlint/src-js/plugins/context.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
* and global variables (`filePath`, `settings`, `cwd`).
2727
*/
2828

29-
import { ast, initAst, SOURCE_CODE } from "./source_code.js";
30-
import { report } from "./report.js";
31-
import { settings, initSettings } from "./settings.js";
32-
import visitorKeys from "../generated/keys.js";
33-
import { debugAssertIsNonNull } from "../utils/asserts.js";
29+
import { ast, initAst, SOURCE_CODE } from "./source_code.ts";
30+
import { report } from "./report.ts";
31+
import { settings, initSettings } from "./settings.ts";
32+
import visitorKeys from "../generated/keys.ts";
33+
import { debugAssertIsNonNull } from "../utils/asserts.ts";
3434

3535
import type { RuleDetails } from "./load.ts";
3636
import type { Options } from "./options.ts";

apps/oxlint/src-js/plugins/fix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { typeAssertIs } from "../utils/asserts.js";
1+
import { typeAssertIs } from "../utils/asserts.ts";
22

33
import type { RuleDetails } from "./load.ts";
44
import type { Range, Ranged } from "./location.ts";
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { lintFile } from "./lint.js";
2-
export { loadPlugin } from "./load.js";
3-
export { setupConfigs } from "./config.js";
1+
export { lintFile } from "./lint.ts";
2+
export { loadPlugin } from "./load.ts";
3+
export { setupConfigs } from "./config.ts";

0 commit comments

Comments
 (0)