From 91d6fe97e92a0d875a481c2ac9108fd0a05da959 Mon Sep 17 00:00:00 2001 From: KingDarBoja Date: Sat, 6 Dec 2025 08:36:52 -0500 Subject: [PATCH 1/2] fix(glob): no longer need custom async adapter. Also bump its types to v9 --- package-lock.json | 22 +++++++++---------- package.json | 2 +- src/adapters/globAsync.ts | 11 ---------- src/api/dependencies.ts | 5 +++-- .../comments/extractGlobPaths.test.ts | 5 +++++ src/converters/comments/extractGlobPaths.ts | 6 ++--- 6 files changed, 23 insertions(+), 28 deletions(-) delete mode 100644 src/adapters/globAsync.ts diff --git a/package-lock.json b/package-lock.json index 640051cb2..6548aff57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "@swc/core": "1.3.104", "@swc/jest": "0.2.29", "@types/eslint-config-prettier": "6.11.3", - "@types/glob": "8.1.0", + "@types/glob": "9.0.0", "@types/json5": "2.2.0", "@types/lodash": "4.17.16", "@types/minimatch": "5.1.2", @@ -1517,13 +1517,14 @@ "dev": true }, "node_modules/@types/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-9.0.0.tgz", + "integrity": "sha512-00UxlRaIUvYm4R4W9WYkN8/J+kV8fmOQ7okeH6YFtGWFMt3odD45tpG5yA5wnL7HE6lLgjaTW5n14ju2hl2NNA==", + "deprecated": "This is a stub types definition. glob provides its own type definitions, so you do not need this installed.", "dev": true, + "license": "MIT", "dependencies": { - "@types/minimatch": "^5.1.2", - "@types/node": "*" + "glob": "*" } }, "node_modules/@types/graceful-fs": { @@ -8183,13 +8184,12 @@ "dev": true }, "@types/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-9.0.0.tgz", + "integrity": "sha512-00UxlRaIUvYm4R4W9WYkN8/J+kV8fmOQ7okeH6YFtGWFMt3odD45tpG5yA5wnL7HE6lLgjaTW5n14ju2hl2NNA==", "dev": true, "requires": { - "@types/minimatch": "^5.1.2", - "@types/node": "*" + "glob": "*" } }, "@types/graceful-fs": { diff --git a/package.json b/package.json index db325ce58..fb8cfafa9 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@swc/core": "1.3.104", "@swc/jest": "0.2.29", "@types/eslint-config-prettier": "6.11.3", - "@types/glob": "8.1.0", + "@types/glob": "9.0.0", "@types/json5": "2.2.0", "@types/lodash": "4.17.16", "@types/minimatch": "5.1.2", diff --git a/src/adapters/globAsync.ts b/src/adapters/globAsync.ts deleted file mode 100644 index 299f4db09..000000000 --- a/src/adapters/globAsync.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { glob } from "glob"; - -export const globAsync = async (pattern: string) => { - return new Promise((resolve) => { - glob(pattern, (error, matches) => { - resolve(error ?? matches); - }); - }); -}; - -export type GlobAsync = typeof globAsync; diff --git a/src/api/dependencies.ts b/src/api/dependencies.ts index a9fd55454..b74d8add2 100644 --- a/src/api/dependencies.ts +++ b/src/api/dependencies.ts @@ -1,6 +1,7 @@ +import { glob } from "glob"; + import { childProcessExec } from "../adapters/childProcessExec"; import { fsFileSystem } from "../adapters/fsFileSystem"; -import { globAsync } from "../adapters/globAsync"; import { nativeImporter } from "../adapters/nativeImporter"; import { processLogger } from "../adapters/processLogger"; import { bind } from "../binding"; @@ -125,7 +126,7 @@ export const collectCommentFileNamesDependencies: CollectCommentFileNamesDepende }; export const extractGlobPathsDependencies: ExtractGlobPathsDependencies = { - globAsync, + globAsync: glob, }; export const convertCommentsDependencies: ConvertCommentsDependencies = { diff --git a/src/converters/comments/extractGlobPaths.test.ts b/src/converters/comments/extractGlobPaths.test.ts index 400ff47f4..3304f93cd 100644 --- a/src/converters/comments/extractGlobPaths.test.ts +++ b/src/converters/comments/extractGlobPaths.test.ts @@ -6,6 +6,7 @@ import { extractGlobPaths, ExtractGlobPathsDependencies } from "./extractGlobPat const createStubDependencies = ( overrides: Partial = {}, ): ExtractGlobPathsDependencies => ({ + // @ts-expect-error Typings globAsync: async () => ["a.ts", "b.ts"], ...overrides, }); @@ -15,6 +16,7 @@ describe("extractGlobPaths", () => { // Arrange const globAsyncError = new Error(); const dependencies = createStubDependencies({ + // @ts-expect-error Typings globAsync: async () => globAsyncError, }); @@ -33,6 +35,7 @@ describe("extractGlobPaths", () => { it("returns an error when there are no resultant file paths", async () => { // Arrange const dependencies = createStubDependencies({ + // @ts-expect-error Typings globAsync: async () => [], }); @@ -51,6 +54,7 @@ describe("extractGlobPaths", () => { it("returns an error when all globbed file paths are excluded", async () => { // Arrange const dependencies = createStubDependencies({ + // @ts-expect-error Typings globAsync: async () => ["a.ts"], }); @@ -70,6 +74,7 @@ describe("extractGlobPaths", () => { it("returns the paths when unique file paths are not excluded", async () => { // Arrange const dependencies = createStubDependencies({ + // @ts-expect-error Typings globAsync: async () => ["a.ts"], }); diff --git a/src/converters/comments/extractGlobPaths.ts b/src/converters/comments/extractGlobPaths.ts index 99bb6fac8..6c85c8b43 100644 --- a/src/converters/comments/extractGlobPaths.ts +++ b/src/converters/comments/extractGlobPaths.ts @@ -1,12 +1,12 @@ +import { glob } from "glob"; import minimatch from "minimatch"; -import { GlobAsync } from "../../adapters/globAsync"; import { CommentFileNames } from "../../comments/collectCommentFileNames"; import { ResultStatus, ResultWithDataStatus } from "../../types"; import { separateErrors, uniqueFromSources } from "../../utils"; export type ExtractGlobPathsDependencies = { - globAsync: GlobAsync; + globAsync: typeof glob; }; export const extractGlobPaths = async ( @@ -14,7 +14,7 @@ export const extractGlobPaths = async ( { exclude, include }: CommentFileNames, ): Promise> => { const [fileGlobErrors, globbedFilePaths] = separateErrors( - await Promise.all(include.map(dependencies.globAsync)), + await Promise.all(include.map(async (pattern) => dependencies.globAsync(pattern))), ); if (fileGlobErrors.length !== 0) { From fdef7093bbaca8ed062ec03c843959923210a46a Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 9 Dec 2025 08:59:37 -0500 Subject: [PATCH 2/2] Correct types --- package-lock.json | 21 ------------------- package.json | 1 - .../comments/extractGlobPaths.test.ts | 5 ----- src/converters/comments/extractGlobPaths.ts | 3 +-- 4 files changed, 1 insertion(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6548aff57..8d2f8537d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,6 @@ "@swc/core": "1.3.104", "@swc/jest": "0.2.29", "@types/eslint-config-prettier": "6.11.3", - "@types/glob": "9.0.0", "@types/json5": "2.2.0", "@types/lodash": "4.17.16", "@types/minimatch": "5.1.2", @@ -1516,17 +1515,6 @@ "integrity": "sha512-3wXCiM8croUnhg9LdtZUJQwNcQYGWxxdOWDjPe1ykCqJFPVpzAKfs/2dgSoCtAvdPeaponcWPI7mPcGGp9dkKQ==", "dev": true }, - "node_modules/@types/glob": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-9.0.0.tgz", - "integrity": "sha512-00UxlRaIUvYm4R4W9WYkN8/J+kV8fmOQ7okeH6YFtGWFMt3odD45tpG5yA5wnL7HE6lLgjaTW5n14ju2hl2NNA==", - "deprecated": "This is a stub types definition. glob provides its own type definitions, so you do not need this installed.", - "dev": true, - "license": "MIT", - "dependencies": { - "glob": "*" - } - }, "node_modules/@types/graceful-fs": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", @@ -8183,15 +8171,6 @@ "integrity": "sha512-3wXCiM8croUnhg9LdtZUJQwNcQYGWxxdOWDjPe1ykCqJFPVpzAKfs/2dgSoCtAvdPeaponcWPI7mPcGGp9dkKQ==", "dev": true }, - "@types/glob": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-9.0.0.tgz", - "integrity": "sha512-00UxlRaIUvYm4R4W9WYkN8/J+kV8fmOQ7okeH6YFtGWFMt3odD45tpG5yA5wnL7HE6lLgjaTW5n14ju2hl2NNA==", - "dev": true, - "requires": { - "glob": "*" - } - }, "@types/graceful-fs": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", diff --git a/package.json b/package.json index fb8cfafa9..279df6d64 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "@swc/core": "1.3.104", "@swc/jest": "0.2.29", "@types/eslint-config-prettier": "6.11.3", - "@types/glob": "9.0.0", "@types/json5": "2.2.0", "@types/lodash": "4.17.16", "@types/minimatch": "5.1.2", diff --git a/src/converters/comments/extractGlobPaths.test.ts b/src/converters/comments/extractGlobPaths.test.ts index 3304f93cd..400ff47f4 100644 --- a/src/converters/comments/extractGlobPaths.test.ts +++ b/src/converters/comments/extractGlobPaths.test.ts @@ -6,7 +6,6 @@ import { extractGlobPaths, ExtractGlobPathsDependencies } from "./extractGlobPat const createStubDependencies = ( overrides: Partial = {}, ): ExtractGlobPathsDependencies => ({ - // @ts-expect-error Typings globAsync: async () => ["a.ts", "b.ts"], ...overrides, }); @@ -16,7 +15,6 @@ describe("extractGlobPaths", () => { // Arrange const globAsyncError = new Error(); const dependencies = createStubDependencies({ - // @ts-expect-error Typings globAsync: async () => globAsyncError, }); @@ -35,7 +33,6 @@ describe("extractGlobPaths", () => { it("returns an error when there are no resultant file paths", async () => { // Arrange const dependencies = createStubDependencies({ - // @ts-expect-error Typings globAsync: async () => [], }); @@ -54,7 +51,6 @@ describe("extractGlobPaths", () => { it("returns an error when all globbed file paths are excluded", async () => { // Arrange const dependencies = createStubDependencies({ - // @ts-expect-error Typings globAsync: async () => ["a.ts"], }); @@ -74,7 +70,6 @@ describe("extractGlobPaths", () => { it("returns the paths when unique file paths are not excluded", async () => { // Arrange const dependencies = createStubDependencies({ - // @ts-expect-error Typings globAsync: async () => ["a.ts"], }); diff --git a/src/converters/comments/extractGlobPaths.ts b/src/converters/comments/extractGlobPaths.ts index 6c85c8b43..b2d1bd08c 100644 --- a/src/converters/comments/extractGlobPaths.ts +++ b/src/converters/comments/extractGlobPaths.ts @@ -1,4 +1,3 @@ -import { glob } from "glob"; import minimatch from "minimatch"; import { CommentFileNames } from "../../comments/collectCommentFileNames"; @@ -6,7 +5,7 @@ import { ResultStatus, ResultWithDataStatus } from "../../types"; import { separateErrors, uniqueFromSources } from "../../utils"; export type ExtractGlobPathsDependencies = { - globAsync: typeof glob; + globAsync: (pattern: string) => Promise; }; export const extractGlobPaths = async (