Skip to content

Commit 7355fcf

Browse files
authored
refactor: use node: specifier imports and full relative paths in imports (#699)
* refactor: replace NodeJS internal module imports with `node:` specifier imports * refactor: use full relative paths in imports
1 parent 03da512 commit 7355fcf

File tree

15 files changed

+33
-26
lines changed

15 files changed

+33
-26
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
"functions": 100,
7171
"lines": 100
7272
}
73+
},
74+
"moduleNameMapper": {
75+
"^(.+)\\.jsx?$": "$1"
7376
}
7477
},
7578
"release": {

scripts/update-endpoints/code.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { readFileSync, writeFileSync } from "fs";
2-
import { join } from "path";
3-
import { fileURLToPath } from "url";
1+
import { readFileSync, writeFileSync } from "node:fs";
2+
import { join } from "node:path";
3+
import { fileURLToPath } from "node:url";
44

55
import { format } from "prettier";
66
import sortKeys from "sort-keys";
@@ -123,7 +123,7 @@ async function generateRoutes() {
123123
writeFileSync(
124124
ROUTES_PATH,
125125
await format(
126-
`import type { EndpointsDefaultsAndDecorations } from "../types";
126+
`import type { EndpointsDefaultsAndDecorations } from "../types.js";
127127
const Endpoints: EndpointsDefaultsAndDecorations = ${JSON.stringify(
128128
sortKeys(newRoutes, { deep: true }),
129129
)}

scripts/update-endpoints/docs.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { format } from "prettier";
22

33
import { isDeprecated } from "./util.mjs";
4-
import { readFileSync, mkdirSync, writeFileSync } from "fs";
4+
import { readFileSync, mkdirSync, writeFileSync } from "node:fs";
55

66
const ENDPOINTS = JSON.parse(
77
readFileSync(

scripts/update-endpoints/fetch-json.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { writeFileSync } from "fs";
2-
import { resolve } from "path";
3-
import { fileURLToPath } from "url";
1+
import { writeFileSync } from "node:fs";
2+
import { resolve } from "node:path";
3+
import { fileURLToPath } from "node:url";
44

55
import graphql from "github-openapi-graphql-query";
66
import { format } from "prettier";

scripts/update-endpoints/types.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { writeFileSync, readFileSync } from "fs";
2-
import { join as pathJoin } from "path";
1+
import { writeFileSync, readFileSync } from "node:fs";
2+
import { join as pathJoin } from "node:path";
33

44
import camelCase from "lodash.camelcase";
55
import { format } from "prettier";

src/endpoints-to-methods.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Octokit } from "@octokit/core";
22
import type { EndpointOptions, RequestParameters, Route } from "@octokit/types";
3-
import ENDPOINTS from "./generated/endpoints";
4-
import type { RestEndpointMethods } from "./generated/method-types";
5-
import type { EndpointDecorations } from "./types";
3+
import ENDPOINTS from "./generated/endpoints.js";
4+
import type { RestEndpointMethods } from "./generated/method-types.js";
5+
import type { EndpointDecorations } from "./types.js";
66

77
// The following code was refactored in: https://github.com/octokit/plugin-rest-endpoint-methods.js/pull/622
88
// to optimise the runtime performance of Octokit initialization.

src/generated/endpoints.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EndpointsDefaultsAndDecorations } from "../types";
1+
import type { EndpointsDefaultsAndDecorations } from "../types.js";
22
const Endpoints: EndpointsDefaultsAndDecorations = {
33
actions: {
44
addCustomLabelsToSelfHostedRunnerForOrg: [

src/generated/method-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { EndpointInterface, RequestInterface } from "@octokit/types";
2-
import type { RestEndpointMethodTypes } from "./parameters-and-response-types";
2+
import type { RestEndpointMethodTypes } from "./parameters-and-response-types.js";
33

44
export type RestEndpointMethods = {
55
actions: {

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Octokit } from "@octokit/core";
22

3-
export type { RestEndpointMethodTypes } from "./generated/parameters-and-response-types";
4-
import { VERSION } from "./version";
5-
import type { Api } from "./types";
6-
import { endpointsToMethods } from "./endpoints-to-methods";
3+
export type { RestEndpointMethodTypes } from "./generated/parameters-and-response-types.js";
4+
import { VERSION } from "./version.js";
5+
import type { Api } from "./types.js";
6+
import { endpointsToMethods } from "./endpoints-to-methods.js";
77

88
export function restEndpointMethods(octokit: Octokit): Api {
99
const api = endpointsToMethods(octokit);

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Route, RequestParameters } from "@octokit/types";
22

3-
import type { RestEndpointMethods } from "./generated/method-types";
3+
import type { RestEndpointMethods } from "./generated/method-types.js";
44

55
export type Api = { rest: RestEndpointMethods };
66

0 commit comments

Comments
 (0)