Skip to content

Commit d425b43

Browse files
committed
chore: update import syntax to native subpath
Replace the `~src/` with node’s native subpath alias `#src/`
1 parent 3382674 commit d425b43

File tree

221 files changed

+973
-999
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+973
-999
lines changed

biome.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.7/schema.json",
33
"vcs": {
44
"enabled": false,
55
"clientKind": "git",
66
"useIgnoreFile": false
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"ignore": ["vendor/*", "dist/*"],
11-
"include": ["src/**/*"]
10+
"includes": ["**/src/**/*", "!**/vendor/**/*", "!**/dist/**/*"]
1211
},
1312
"formatter": {
1413
"enabled": true,
1514
"indentStyle": "tab"
1615
},
17-
"organizeImports": {
18-
"enabled": true
19-
},
16+
"assist": { "actions": { "source": { "organizeImports": "on" } } },
2017
"linter": {
2118
"enabled": true,
2219
"rules": {
2320
"recommended": true,
2421
"complexity": {
2522
"noForEach": "off"
2623
},
24+
"correctness": {
25+
"noUnusedFunctionParameters": "off",
26+
"noUnusedImports": "error",
27+
"noUnusedVariables": "warn",
28+
"useImportExtensions": "error"
29+
},
2730
"style": {
2831
"noNonNullAssertion": "off",
2932
"noParameterAssign": "off"
3033
},
3134
"suspicious": {
32-
"noConsoleLog": "error",
3335
"noImplicitAnyLet": "off",
3436
"noExplicitAny": "off",
35-
"noExportsInTest": "off"
37+
"noExportsInTest": "off",
38+
"noConsole": { "level": "error", "options": { "allow": ["log"] } }
3639
}
3740
}
3841
},

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"exports": {
88
".": "./dist/index.js"
99
},
10+
"imports": {
11+
"#src/*": "./src/*",
12+
"#vendor/*": "./vendor/*"
13+
},
1014
"main": "dist/index.js",
1115
"module": "dist/index.js",
1216
"typings": "dist/index.d.ts",
@@ -40,7 +44,7 @@
4044
"zod-validation-error": "3.4.0"
4145
},
4246
"devDependencies": {
43-
"@biomejs/biome": "1.9.4",
47+
"@biomejs/biome": "2.3.7",
4448
"@changesets/changelog-github": "0.5.2",
4549
"@changesets/cli": "2.29.7",
4650
"@commercetools/platform-sdk": "8.16.0",

pnpm-lock.yaml

Lines changed: 37 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AbstractStorage } from "./storage";
1+
import type { AbstractStorage } from "./storage/index.ts";
22

33
export type Config = {
44
strict: boolean;

src/ctMock.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { test } from "vitest";
2-
import { CommercetoolsMock } from "./index";
2+
import { CommercetoolsMock } from "./index.ts";
33

44
test("ctMock.authServer", async () => {
55
const ctMock = new CommercetoolsMock({

src/ctMock.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ import type { NextFunction, Request, Response } from "express";
22
import express from "express";
33
import inject from "light-my-request";
44
import morgan from "morgan";
5-
import { http, HttpResponse } from "msw";
5+
import { HttpResponse, http } from "msw";
66
import type { SetupServer, SetupServerApi } from "msw/node";
77
import { setupServer } from "msw/node";
8-
import type { Config } from "./config";
9-
import { DEFAULT_API_HOSTNAME, DEFAULT_AUTH_HOSTNAME } from "./constants";
10-
import { CommercetoolsError } from "./exceptions";
11-
import { mapHeaderType } from "./helpers";
12-
import { copyHeaders } from "./lib/proxy";
13-
import { OAuth2Server } from "./oauth/server";
14-
import { ProjectAPI } from "./projectAPI";
15-
import type { RepositoryMap } from "./repositories";
16-
import { createRepositories } from "./repositories";
17-
import type { ProjectRepository } from "./repositories/project";
18-
import { createServices } from "./services";
19-
import { ProjectService } from "./services/project";
20-
import type { AbstractStorage } from "./storage";
21-
import { InMemoryStorage } from "./storage";
8+
import type { Config } from "./config.ts";
9+
import { DEFAULT_API_HOSTNAME, DEFAULT_AUTH_HOSTNAME } from "./constants.ts";
10+
import { CommercetoolsError } from "./exceptions.ts";
11+
import { mapHeaderType } from "./helpers.ts";
12+
import { copyHeaders } from "./lib/proxy.ts";
13+
import { OAuth2Server } from "./oauth/server.ts";
14+
import { ProjectAPI } from "./projectAPI.ts";
15+
import type { RepositoryMap } from "./repositories/index.ts";
16+
import { createRepositories } from "./repositories/index.ts";
17+
import type { ProjectRepository } from "./repositories/project.ts";
18+
import { createServices } from "./services/index.ts";
19+
import { ProjectService } from "./services/project.ts";
20+
import type { AbstractStorage } from "./storage/index.ts";
21+
import { InMemoryStorage } from "./storage/index.ts";
2222

2323
export type CommercetoolsMockOptions = {
2424
validateCredentials: boolean;
@@ -57,7 +57,7 @@ export class CommercetoolsMock {
5757

5858
private _repositories: RepositoryMap | null;
5959

60-
private _projectService?: ProjectService;
60+
private _projectService: ProjectService | undefined;
6161

6262
constructor(options: Partial<CommercetoolsMockOptions> = {}) {
6363
this.options = { ...DEFAULT_OPTIONS, ...options };
@@ -123,9 +123,7 @@ export class CommercetoolsMock {
123123
}
124124

125125
runServer(port = 3000, options?: AppOptions) {
126-
const server = this.app.listen(port, () => {
127-
console.info(`Mock server listening at http://localhost:${port}`);
128-
});
126+
const server = this.app.listen(port, () => {});
129127
server.keepAliveTimeout = 60 * 1000;
130128
}
131129

@@ -186,7 +184,6 @@ export class CommercetoolsMock {
186184
});
187185
return;
188186
}
189-
console.error(err);
190187
resp.status(500).send({
191188
error: err.message,
192189
});
@@ -312,7 +309,10 @@ export class CommercetoolsMock {
312309
throw new Error("Server already started");
313310
}
314311
process.emitWarning("Server wasn't stopped properly, clearing");
315-
_globalListeners.forEach((listener) => listener.close());
312+
for (const listener of _globalListeners) {
313+
listener.close();
314+
}
315+
_globalListeners.length = 0;
316316
}
317317

318318
const server = setupServer();

src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { InvalidTokenError } from "@commercetools/platform-sdk";
22
import { setupServer } from "msw/node";
33
import { afterEach, beforeAll, expect, test } from "vitest";
4-
import { CommercetoolsMock } from "./index";
4+
import { CommercetoolsMock } from "./index.ts";
55

66
const mswServer = setupServer();
77

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { CommercetoolsMockOptions } from "./ctMock";
2-
import { CommercetoolsMock } from "./ctMock";
3-
import { getBaseResourceProperties } from "./helpers";
1+
import type { CommercetoolsMockOptions } from "./ctMock.ts";
2+
import { CommercetoolsMock } from "./ctMock.ts";
3+
import { getBaseResourceProperties } from "./helpers.ts";
44

55
export {
66
CommercetoolsMock,

src/lib/haversine.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, test } from "vitest";
2-
import type { Location } from "./haversine";
3-
import { haversineDistance } from "./haversine";
2+
import type { Location } from "./haversine.ts";
3+
import { haversineDistance } from "./haversine.ts";
44

55
test("haversine", () => {
66
// Lab Digital

src/lib/masking.ts

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

33
export const maskSecretValue = <T>(resource: T, path: string): T => {
44
const parts = path.split(".");

0 commit comments

Comments
 (0)