Skip to content

refactor: use node: specifier imports and full relative paths imports, update tests for new type errors #653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@types/node": "^20.0.0",
"@types/once": "^1.4.0",
"esbuild": "^0.19.0",
"fetch-mock": "^9.3.1",
"fetch-mock": "npm:@gr2m/fetch-mock@^9.11.0-pull-request-644.1",
"glob": "^10.2.4",
"jest": "^29.0.0",
"lolex": "^6.0.0",
Expand Down Expand Up @@ -65,7 +65,10 @@
},
"modulePathIgnorePatterns": [
"<rootDir>/pkg"
]
],
"moduleNameMapper": {
"^(.+)\\.jsx?$": "$1"
}
},
"release": {
"branches": [
Expand Down
4 changes: 2 additions & 2 deletions src/fetch-wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isPlainObject } from "./is-plain-object";
import { isPlainObject } from "./is-plain-object.js";
import { RequestError } from "@octokit/request-error";
import type { EndpointInterface } from "@octokit/types";

import getBuffer from "./get-buffer-response";
import getBuffer from "./get-buffer-response.js";

export default function fetchWrapper(
requestOptions: ReturnType<EndpointInterface>,
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { endpoint } from "@octokit/endpoint";
import { getUserAgent } from "universal-user-agent";

import { VERSION } from "./version";
import withDefaults from "./with-defaults";
import { VERSION } from "./version.js";
import withDefaults from "./with-defaults.js";

export const request = withDefaults(endpoint, {
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/with-defaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetchWrapper from "./fetch-wrapper";
import fetchWrapper from "./fetch-wrapper.js";
import type {
EndpointOptions,
EndpointInterface,
Expand Down
2 changes: 1 addition & 1 deletion test/defaults.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";

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

describe("endpoint.defaults()", () => {
it("is a function", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/is-plain-object.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isPlainObject } from "../src/is-plain-object";
import { isPlainObject } from "../src/is-plain-object.ts";

describe("isPlainObject", () => {
function Foo() {
Expand Down
9 changes: 5 additions & 4 deletions test/request.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "fs";
import stream, { Stream } from "stream";
import fs from "node:fs";
import stream from "node:stream";
import { ReadableStream } from "node:stream/web";

import { getUserAgent } from "universal-user-agent";
import fetchMock from "fetch-mock";
Expand All @@ -11,7 +12,7 @@ import type {
ResponseHeaders,
} from "@octokit/types";

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

const userAgent = `octokit-request.js/0.0.0-development ${getUserAgent()}`;
const stringToArrayBuffer = require("string-to-arraybuffer");
Expand Down Expand Up @@ -1117,7 +1118,7 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
}).then((response) => {
expect(response.status).toEqual(200);
expect(response.headers["content-type"]).toEqual("application/x-gzip");
expect(response.data).toBeInstanceOf(Stream);
expect(response.data).toBeInstanceOf(ReadableStream);
expect(mock.done()).toBe(true);
});
});
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/**/*"]
}