Skip to content

Commit 3be24c1

Browse files
committed
refactor: fix unicorn/import-style lint warnings for node:path imports
1 parent 7ec5253 commit 3be24c1

File tree

106 files changed

+679
-589
lines changed

Some content is hidden

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

106 files changed

+679
-589
lines changed

docs/e2e.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ export default defineConfig({
144144

145145
// to avoid port conflicts ever E2E targets has a unique port
146146
const uniquePort = 6000 + Math.round(Math.random() * 1000);
147-
const e2eDir = join('tmp', 'e2e');
147+
const e2eDir = path.join('tmp', 'e2e');
148148

149149
export async function setup() {
150150
// start local verdaccio registry
151151
const { registry } = await startLocalRegistry({
152152
localRegistryTarget: '@code-pushup/cli-source:start-verdaccio',
153153
// to avoid file system conflicts ever E2E targets has a unique storage folder
154-
storage: join(join(e2eDir, `registry-${uniquePort}`), 'storage'),
154+
storage: path.join(path.join(e2eDir, `registry-${uniquePort}`), 'storage'),
155155
port: uniquePort,
156156
});
157157

e2e/ci-e2e/tests/ci.e2e.test.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cp, readFile, rename } from 'node:fs/promises';
2-
import { dirname, join } from 'node:path';
2+
import path from 'node:path';
33
import { fileURLToPath } from 'node:url';
44
import {
55
type DiffResult,
@@ -26,21 +26,21 @@ import {
2626
} from '@code-pushup/test-utils';
2727

2828
describe('CI package', () => {
29-
const fixturesDir = join(
30-
fileURLToPath(dirname(import.meta.url)),
29+
const fixturesDir = path.join(
30+
fileURLToPath(path.dirname(import.meta.url)),
3131
'..',
3232
'mocks',
3333
'fixtures',
3434
'ci-test-repo',
3535
);
36-
const ciSetupRepoDir = join(
36+
const ciSetupRepoDir = path.join(
3737
process.cwd(),
3838
E2E_ENVIRONMENTS_DIR,
3939
nxTargetProject(),
4040
TEST_OUTPUT_DIR,
4141
'ci-test-repo',
4242
);
43-
const outputDir = join(ciSetupRepoDir, '.code-pushup');
43+
const outputDir = path.join(ciSetupRepoDir, '.code-pushup');
4444

4545
const options = {
4646
directory: ciSetupRepoDir,
@@ -91,14 +91,14 @@ describe('CI package', () => {
9191
report: {
9292
rootDir: outputDir,
9393
files: [
94-
join(outputDir, 'report.json'),
95-
join(outputDir, 'report.md'),
94+
path.join(outputDir, 'report.json'),
95+
path.join(outputDir, 'report.md'),
9696
],
9797
},
9898
},
9999
} satisfies RunResult);
100100

101-
const jsonPromise = readFile(join(outputDir, 'report.json'), 'utf8');
101+
const jsonPromise = readFile(path.join(outputDir, 'report.json'), 'utf8');
102102
await expect(jsonPromise).resolves.toBeTruthy();
103103
const report = JSON.parse(await jsonPromise) as Report;
104104
expect(report).toEqual(
@@ -138,8 +138,8 @@ describe('CI package', () => {
138138
await git.checkoutLocalBranch('feature-1');
139139

140140
await rename(
141-
join(ciSetupRepoDir, 'index.js'),
142-
join(ciSetupRepoDir, 'index.ts'),
141+
path.join(ciSetupRepoDir, 'index.js'),
142+
path.join(ciSetupRepoDir, 'index.ts'),
143143
);
144144

145145
await git.add('index.ts');
@@ -160,26 +160,29 @@ describe('CI package', () => {
160160
report: {
161161
rootDir: outputDir,
162162
files: [
163-
join(outputDir, 'report.json'),
164-
join(outputDir, 'report.md'),
163+
path.join(outputDir, 'report.json'),
164+
path.join(outputDir, 'report.md'),
165165
],
166166
},
167167
diff: {
168168
rootDir: outputDir,
169169
files: [
170-
join(outputDir, 'report-diff.json'),
171-
join(outputDir, 'report-diff.md'),
170+
path.join(outputDir, 'report-diff.json'),
171+
path.join(outputDir, 'report-diff.md'),
172172
],
173173
},
174174
},
175175
} satisfies RunResult);
176176

177-
const mdPromise = readFile(join(outputDir, 'report-diff.md'), 'utf8');
177+
const mdPromise = readFile(
178+
path.join(outputDir, 'report-diff.md'),
179+
'utf8',
180+
);
178181
await expect(mdPromise).resolves.toBeTruthy();
179182
const md = await mdPromise;
180183
await expect(
181184
md.replace(/[\da-f]{40}/g, '`<commit-sha>`'),
182-
).toMatchFileSnapshot(join(TEST_SNAPSHOTS_DIR, 'report-diff.md'));
185+
).toMatchFileSnapshot(path.join(TEST_SNAPSHOTS_DIR, 'report-diff.md'));
183186
});
184187
});
185188
});

e2e/cli-e2e/mocks/fixtures/dummy-setup/dummy.plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { readFile } from 'node:fs/promises';
2-
import { join } from 'node:path';
2+
import path from 'node:path';
33
import type { PluginConfig } from '@code-pushup/models';
44

55
export const dummyPluginSlug = 'dummy-plugin';
@@ -32,7 +32,7 @@ export function create(): PluginConfig {
3232
description: 'A dummy plugin to test the cli.',
3333
runner: async () => {
3434
const itemCount = JSON.parse(
35-
await readFile(join('src', 'items.json'), 'utf-8'),
35+
await readFile(path.join('src', 'items.json'), 'utf-8'),
3636
).length;
3737
return [
3838
{

e2e/cli-e2e/mocks/fixtures/existing-reports/dummy.plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { readFile } from 'node:fs/promises';
2-
import { join } from 'node:path';
2+
import path from 'node:path';
33
import type { PluginConfig } from '@code-pushup/models';
44

55
export const dummyPluginSlug = 'dummy-plugin';
@@ -32,7 +32,7 @@ export function create(): PluginConfig {
3232
description: 'A dummy plugin to test the cli.',
3333
runner: async () => {
3434
const itemCount = JSON.parse(
35-
await readFile(join('src', 'items.json'), 'utf-8'),
35+
await readFile(path.join('src', 'items.json'), 'utf-8'),
3636
).length;
3737
return [
3838
{

e2e/cli-e2e/tests/collect.e2e.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cp } from 'node:fs/promises';
2-
import { join } from 'node:path';
2+
import path from 'node:path';
33
import { afterEach, beforeAll, describe, expect, it } from 'vitest';
44
import { nxTargetProject } from '@code-pushup/test-nx-utils';
55
import { teardownTestFolder } from '@code-pushup/test-setup';
@@ -9,21 +9,21 @@ import { executeProcess, readTextFile } from '@code-pushup/utils';
99
describe('CLI collect', () => {
1010
const dummyPluginTitle = 'Dummy Plugin';
1111
const dummyAuditTitle = 'Dummy Audit';
12-
const fixtureDummyDir = join(
12+
const fixtureDummyDir = path.join(
1313
'e2e',
1414
nxTargetProject(),
1515
'mocks',
1616
'fixtures',
1717
'dummy-setup',
1818
);
19-
const testFileDir = join(
19+
const testFileDir = path.join(
2020
E2E_ENVIRONMENTS_DIR,
2121
nxTargetProject(),
2222
TEST_OUTPUT_DIR,
2323
'collect',
2424
);
25-
const dummyDir = join(testFileDir, 'dummy-setup');
26-
const dummyOutputDir = join(dummyDir, '.code-pushup');
25+
const dummyDir = path.join(testFileDir, 'dummy-setup');
26+
const dummyOutputDir = path.join(dummyDir, '.code-pushup');
2727

2828
beforeAll(async () => {
2929
await cp(fixtureDummyDir, dummyDir, { recursive: true });
@@ -52,7 +52,7 @@ describe('CLI collect', () => {
5252
expect(code).toBe(0);
5353
expect(stderr).toBe('');
5454

55-
const md = await readTextFile(join(dummyOutputDir, 'report.md'));
55+
const md = await readTextFile(path.join(dummyOutputDir, 'report.md'));
5656

5757
expect(md).toContain('# Code PushUp Report');
5858
expect(md).toContain(dummyPluginTitle);

e2e/cli-e2e/tests/compare.e2e.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cp } from 'node:fs/promises';
2-
import { join } from 'node:path';
2+
import path from 'node:path';
33
import { beforeAll } from 'vitest';
44
import type { ReportsDiff } from '@code-pushup/models';
55
import { nxTargetProject } from '@code-pushup/test-nx-utils';
@@ -8,22 +8,22 @@ import { E2E_ENVIRONMENTS_DIR, TEST_OUTPUT_DIR } from '@code-pushup/test-utils';
88
import { executeProcess, readJsonFile, readTextFile } from '@code-pushup/utils';
99

1010
describe('CLI compare', () => {
11-
const fixtureDummyDir = join(
11+
const fixtureDummyDir = path.join(
1212
'e2e',
1313
nxTargetProject(),
1414
'mocks',
1515
'fixtures',
1616
'existing-reports',
1717
);
1818

19-
const testFileDir = join(
19+
const testFileDir = path.join(
2020
E2E_ENVIRONMENTS_DIR,
2121
nxTargetProject(),
2222
TEST_OUTPUT_DIR,
2323
'compare',
2424
);
25-
const existingDir = join(testFileDir, 'existing-reports');
26-
const existingOutputDir = join(existingDir, '.code-pushup');
25+
const existingDir = path.join(testFileDir, 'existing-reports');
26+
const existingOutputDir = path.join(existingDir, '.code-pushup');
2727

2828
beforeAll(async () => {
2929
await cp(fixtureDummyDir, existingDir, { recursive: true });
@@ -39,14 +39,14 @@ describe('CLI compare', () => {
3939
args: [
4040
'@code-pushup/cli',
4141
'compare',
42-
`--before=${join('.code-pushup', 'source-report.json')}`,
43-
`--after=${join('.code-pushup', 'target-report.json')}`,
42+
`--before=${path.join('.code-pushup', 'source-report.json')}`,
43+
`--after=${path.join('.code-pushup', 'target-report.json')}`,
4444
],
4545
cwd: existingDir,
4646
});
4747

4848
const reportsDiff = await readJsonFile<ReportsDiff>(
49-
join(existingOutputDir, 'report-diff.json'),
49+
path.join(existingOutputDir, 'report-diff.json'),
5050
);
5151
expect(reportsDiff).toMatchSnapshot({
5252
commits: expect.any(Object),
@@ -56,7 +56,7 @@ describe('CLI compare', () => {
5656
});
5757

5858
const reportsDiffMd = await readTextFile(
59-
join(existingOutputDir, 'report-diff.md'),
59+
path.join(existingOutputDir, 'report-diff.md'),
6060
);
6161
// commits are variable, replace SHAs with placeholders
6262
const sanitizedMd = reportsDiffMd.replace(/[\da-f]{40}/g, '`<commit-sha>`');

e2e/cli-e2e/tests/help.e2e.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { join } from 'node:path';
1+
import path from 'node:path';
22
import { nxTargetProject } from '@code-pushup/test-nx-utils';
33
import {
44
E2E_ENVIRONMENTS_DIR,
@@ -7,7 +7,7 @@ import {
77
import { executeProcess } from '@code-pushup/utils';
88

99
describe('CLI help', () => {
10-
const envRoot = join(E2E_ENVIRONMENTS_DIR, nxTargetProject());
10+
const envRoot = path.join(E2E_ENVIRONMENTS_DIR, nxTargetProject());
1111

1212
it('should print help with help command', async () => {
1313
const { code, stdout, stderr } = await executeProcess({

e2e/cli-e2e/tests/print-config.e2e.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cp } from 'node:fs/promises';
2-
import { join } from 'node:path';
2+
import path from 'node:path';
33
import { beforeAll, expect } from 'vitest';
44
import { nxTargetProject } from '@code-pushup/test-nx-utils';
55
import { teardownTestFolder } from '@code-pushup/test-setup';
@@ -8,23 +8,23 @@ import { executeProcess } from '@code-pushup/utils';
88

99
describe('CLI print-config', () => {
1010
const extensions = ['js', 'mjs', 'ts'] as const;
11-
const fixtureDummyDir = join(
11+
const fixtureDummyDir = path.join(
1212
'e2e',
1313
nxTargetProject(),
1414
'mocks',
1515
'fixtures',
1616
'dummy-setup',
1717
);
1818

19-
const testFileDir = join(
19+
const testFileDir = path.join(
2020
E2E_ENVIRONMENTS_DIR,
2121
nxTargetProject(),
2222
TEST_OUTPUT_DIR,
2323
'print-config',
2424
);
25-
const testFileDummySetup = join(testFileDir, 'dummy-setup');
25+
const testFileDummySetup = path.join(testFileDir, 'dummy-setup');
2626
const configFilePath = (ext: (typeof extensions)[number]) =>
27-
join(process.cwd(), testFileDummySetup, `code-pushup.config.${ext}`);
27+
path.join(process.cwd(), testFileDummySetup, `code-pushup.config.${ext}`);
2828

2929
beforeAll(async () => {
3030
await cp(fixtureDummyDir, testFileDummySetup, { recursive: true });

e2e/create-cli-e2e/tests/init.e2e.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { join } from 'node:path';
1+
import path from 'node:path';
22
import { afterEach, expect } from 'vitest';
33
import { nxTargetProject } from '@code-pushup/test-nx-utils';
44
import { teardownTestFolder } from '@code-pushup/test-setup';
@@ -14,15 +14,15 @@ const fakeCacheFolderName = () =>
1414
`fake-cache-${new Date().toISOString().replace(/[:.]/g, '-')}`;
1515

1616
describe('create-cli-init', () => {
17-
const workspaceRoot = join(E2E_ENVIRONMENTS_DIR, nxTargetProject());
18-
const testFileDir = join(workspaceRoot, TEST_OUTPUT_DIR, 'init');
17+
const workspaceRoot = path.join(E2E_ENVIRONMENTS_DIR, nxTargetProject());
18+
const testFileDir = path.join(workspaceRoot, TEST_OUTPUT_DIR, 'init');
1919

2020
afterEach(async () => {
2121
await teardownTestFolder(testFileDir);
2222
});
2323

2424
it('should execute package correctly over npm exec', async () => {
25-
const cwd = join(testFileDir, 'npm-exec');
25+
const cwd = path.join(testFileDir, 'npm-exec');
2626
await createNpmWorkspace(cwd);
2727
const { code, stdout } = await executeProcess({
2828
command: 'npm',
@@ -42,7 +42,7 @@ describe('create-cli-init', () => {
4242
);
4343

4444
await expect(
45-
readJsonFile(join(cwd, 'package.json')),
45+
readJsonFile(path.join(cwd, 'package.json')),
4646
).resolves.toStrictEqual(
4747
expect.objectContaining({
4848
devDependencies: {
@@ -54,14 +54,14 @@ describe('create-cli-init', () => {
5454
}),
5555
);
5656
await expect(
57-
readTextFile(join(cwd, 'code-pushup.config.ts')),
57+
readTextFile(path.join(cwd, 'code-pushup.config.ts')),
5858
).resolves.toContain(
5959
"import type { CoreConfig } from '@code-pushup/models';",
6060
);
6161
});
6262

6363
it('should execute package correctly over npm init', async () => {
64-
const cwd = join(testFileDir, 'npm-init-setup');
64+
const cwd = path.join(testFileDir, 'npm-init-setup');
6565
await createNpmWorkspace(cwd);
6666

6767
const { code, stdout } = await executeProcess({
@@ -82,7 +82,7 @@ describe('create-cli-init', () => {
8282
);
8383

8484
await expect(
85-
readJsonFile(join(cwd, 'package.json')),
85+
readJsonFile(path.join(cwd, 'package.json')),
8686
).resolves.toStrictEqual(
8787
expect.objectContaining({
8888
devDependencies: {
@@ -94,14 +94,14 @@ describe('create-cli-init', () => {
9494
}),
9595
);
9696
await expect(
97-
readTextFile(join(cwd, 'code-pushup.config.ts')),
97+
readTextFile(path.join(cwd, 'code-pushup.config.ts')),
9898
).resolves.toContain(
9999
"import type { CoreConfig } from '@code-pushup/models';",
100100
);
101101
});
102102

103103
it('should produce an executable setup when running npm exec', async () => {
104-
const cwd = join(testFileDir, 'npm-executable');
104+
const cwd = path.join(testFileDir, 'npm-executable');
105105
await createNpmWorkspace(cwd);
106106

107107
await executeProcess({

0 commit comments

Comments
 (0)