Skip to content

Commit

Permalink
refactor: use node: specifier imports and full relative import paths (
Browse files Browse the repository at this point in the history
#460)

* refactor: replace NodeJS internal module imports with `node:` specifier imports

* refactor: use full relative paths in imports
  • Loading branch information
wolfy1339 authored Nov 28, 2023
1 parent d6089a4 commit daa042b
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 33 deletions.
24 changes: 17 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"devDependencies": {
"@octokit/tsconfig": "^2.0.0",
"@types/jest": "^29.0.0",
"@types/node": "^20.10.0",
"esbuild": "^0.19.0",
"glob": "^10.2.7",
"jest": "^29.0.0",
Expand Down Expand Up @@ -85,6 +86,9 @@
"functions": 100,
"lines": 100
}
},
"moduleNameMapper": {
"^(.+)\\.jsx?$": "$1"
}
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getUserAgent } from "universal-user-agent";
import type { EndpointDefaults } from "@octokit/types";

import { VERSION } from "./version";
import { VERSION } from "./version.js";

const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;

Expand Down
6 changes: 3 additions & 3 deletions src/endpoint-with-defaults.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { EndpointOptions, RequestParameters, Route } from "@octokit/types";

import { DEFAULTS } from "./defaults";
import { merge } from "./merge";
import { parse } from "./parse";
import { DEFAULTS } from "./defaults.js";
import { merge } from "./merge.js";
import { parse } from "./parse.js";

export function endpointWithDefaults(
defaults: typeof DEFAULTS,
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { withDefaults } from "./with-defaults";
import { DEFAULTS } from "./defaults";
import { withDefaults } from "./with-defaults.js";
import { DEFAULTS } from "./defaults.js";

export const endpoint = withDefaults(null, DEFAULTS);
6 changes: 3 additions & 3 deletions src/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type {
Route,
} from "@octokit/types";

import { lowercaseKeys } from "./util/lowercase-keys";
import { mergeDeep } from "./util/merge-deep";
import { removeUndefinedProperties } from "./util/remove-undefined-properties";
import { lowercaseKeys } from "./util/lowercase-keys.js";
import { mergeDeep } from "./util/merge-deep.js";
import { removeUndefinedProperties } from "./util/remove-undefined-properties.js";

export function merge(
defaults: EndpointDefaults | null,
Expand Down
8 changes: 4 additions & 4 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import type {
RequestOptions,
} from "@octokit/types";

import { addQueryParameters } from "./util/add-query-parameters";
import { extractUrlVariableNames } from "./util/extract-url-variable-names";
import { omit } from "./util/omit";
import { parseUrl } from "./util/url-template";
import { addQueryParameters } from "./util/add-query-parameters.js";
import { extractUrlVariableNames } from "./util/extract-url-variable-names.js";
import { omit } from "./util/omit.js";
import { parseUrl } from "./util/url-template.js";

export function parse(options: EndpointDefaults): RequestOptions {
// https://fetch.spec.whatwg.org/#methods
Expand Down
2 changes: 1 addition & 1 deletion src/util/merge-deep.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isPlainObject } from "./is-plain-object";
import { isPlainObject } from "./is-plain-object.js";

export function mergeDeep(defaults: any, options: any): object {
const result = Object.assign({}, defaults);
Expand Down
6 changes: 3 additions & 3 deletions src/with-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type {
EndpointDefaults,
} from "@octokit/types";

import { endpointWithDefaults } from "./endpoint-with-defaults";
import { merge } from "./merge";
import { parse } from "./parse";
import { endpointWithDefaults } from "./endpoint-with-defaults.js";
import { merge } from "./merge.js";
import { parse } from "./parse.js";

export function withDefaults(
oldDefaults: EndpointDefaults | null,
Expand Down
2 changes: 1 addition & 1 deletion test/defaults.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { endpoint } from "../src";
import { endpoint } from "../src/index.js";

describe("endpoint.defaults()", () => {
it("is a function", () => {
Expand Down
6 changes: 3 additions & 3 deletions test/endpoint.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Agent } from "http";
import { Agent } from "node:http";

import { getUserAgent } from "universal-user-agent";

import { endpoint } from "../src";
import { VERSION } from "../src/version";
import { endpoint } from "../src/index.ts";
import { VERSION } from "../src/version.ts";

const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;

Expand Down
2 changes: 1 addition & 1 deletion test/is-plaint-object.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isPlainObject } from "../src/util/is-plain-object";
import { isPlainObject } from "../src/util/is-plain-object.ts";

describe("isPlainObject", () => {
function Foo() {
Expand Down
4 changes: 2 additions & 2 deletions test/merge.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getUserAgent } from "universal-user-agent";

import { endpoint } from "../src";
import { VERSION } from "../src/version";
import { endpoint } from "../src/index.ts";
import { VERSION } from "../src/version.ts";
const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;

describe("endpoint.merge()", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/parse.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { EndpointOptions, EndpointDefaults } from "@octokit/types";

import { endpoint } from "../src";
import { endpoint } from "../src/index.ts";

describe("endpoint.parse()", () => {
it("is a function", () => {
Expand Down
3 changes: 2 additions & 1 deletion test/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"emitDeclarationOnly": false,
"noEmit": true,
"verbatimModuleSyntax": false
"verbatimModuleSyntax": false,
"allowImportingTsExtensions": true
},
"include": ["src/**/*"]
}

0 comments on commit daa042b

Please sign in to comment.