Skip to content
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

refactor: update eslint to flat config for all projects #892

Merged
merged 14 commits into from
Dec 17, 2024
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
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

123 changes: 0 additions & 123 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.0
22.10.0
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 20.11.0
nodejs 22.10.0
File renamed without changes.
4 changes: 2 additions & 2 deletions docs/e2e.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ export default defineConfig({

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

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

Expand Down
12 changes: 0 additions & 12 deletions e2e/ci-e2e/.eslintrc.json

This file was deleted.

12 changes: 12 additions & 0 deletions e2e/ci-e2e/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tseslint from 'typescript-eslint';
import baseConfig from '../../eslint.config.js';

export default tseslint.config(...baseConfig, {
files: ['**/*.ts'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
});
8 changes: 4 additions & 4 deletions e2e/ci-e2e/mocks/setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cp } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { simpleGit } from 'simple-git';
import { nxTargetProject } from '@code-pushup/test-nx-utils';
Expand All @@ -14,12 +14,12 @@ import {
export type TestRepo = Awaited<ReturnType<typeof setupTestRepo>>;

export async function setupTestRepo(folder: string) {
const fixturesDir = join(
fileURLToPath(dirname(import.meta.url)),
const fixturesDir = path.join(
fileURLToPath(path.dirname(import.meta.url)),
'fixtures',
folder,
);
const baseDir = join(
const baseDir = path.join(
process.cwd(),
E2E_ENVIRONMENTS_DIR,
nxTargetProject(),
Expand Down
26 changes: 14 additions & 12 deletions e2e/ci-e2e/tests/basic.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile, rename } from 'node:fs/promises';
import { join } from 'node:path';
import path from 'node:path';
import type { SimpleGit } from 'simple-git';
import { afterEach } from 'vitest';
import {
Expand Down Expand Up @@ -47,14 +47,14 @@ describe('CI - standalone mode', () => {
mode: 'standalone',
files: {
report: {
json: join(repo.baseDir, '.code-pushup/report.json'),
md: join(repo.baseDir, '.code-pushup/report.md'),
json: path.join(repo.baseDir, '.code-pushup/report.json'),
md: path.join(repo.baseDir, '.code-pushup/report.md'),
},
},
} satisfies RunResult);

const jsonPromise = readFile(
join(repo.baseDir, '.code-pushup/report.json'),
path.join(repo.baseDir, '.code-pushup/report.json'),
'utf8',
);
await expect(jsonPromise).resolves.toBeTruthy();
Expand Down Expand Up @@ -84,8 +84,8 @@ describe('CI - standalone mode', () => {
await git.checkoutLocalBranch('feature-1');

await rename(
join(repo.baseDir, 'index.js'),
join(repo.baseDir, 'index.ts'),
path.join(repo.baseDir, 'index.js'),
path.join(repo.baseDir, 'index.ts'),
);

await git.add('index.ts');
Expand All @@ -104,25 +104,27 @@ describe('CI - standalone mode', () => {
newIssues: [],
files: {
report: {
json: join(repo.baseDir, '.code-pushup/report.json'),
md: join(repo.baseDir, '.code-pushup/report.md'),
json: path.join(repo.baseDir, '.code-pushup/report.json'),
md: path.join(repo.baseDir, '.code-pushup/report.md'),
},
diff: {
json: join(repo.baseDir, '.code-pushup/report-diff.json'),
md: join(repo.baseDir, '.code-pushup/report-diff.md'),
json: path.join(repo.baseDir, '.code-pushup/report-diff.json'),
md: path.join(repo.baseDir, '.code-pushup/report-diff.md'),
},
},
} satisfies RunResult);

const mdPromise = readFile(
join(repo.baseDir, '.code-pushup/report-diff.md'),
path.join(repo.baseDir, '.code-pushup/report-diff.md'),
'utf8',
);
await expect(mdPromise).resolves.toBeTruthy();
const md = await mdPromise;
await expect(
md.replace(/[\da-f]{40}/g, '`<commit-sha>`'),
).toMatchFileSnapshot(join(TEST_SNAPSHOTS_DIR, 'basic-report-diff.md'));
).toMatchFileSnapshot(
path.join(TEST_SNAPSHOTS_DIR, 'basic-report-diff.md'),
);
});
});
});
40 changes: 23 additions & 17 deletions e2e/ci-e2e/tests/npm-workspaces.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile, rename } from 'node:fs/promises';
import { join } from 'node:path';
import path from 'node:path';
import type { SimpleGit } from 'simple-git';
import { afterEach } from 'vitest';
import {
Expand Down Expand Up @@ -53,11 +53,14 @@ describe('CI - monorepo mode (npm workspaces)', () => {
name: '@example/cli',
files: {
report: {
json: join(
json: path.join(
repo.baseDir,
'packages/cli/.code-pushup/report.json',
),
md: join(repo.baseDir, 'packages/cli/.code-pushup/report.md'),
md: path.join(
repo.baseDir,
'packages/cli/.code-pushup/report.md',
),
},
},
},
Expand All @@ -66,7 +69,7 @@ describe('CI - monorepo mode (npm workspaces)', () => {

await expect(
readJsonFile(
join(repo.baseDir, 'packages/cli/.code-pushup/report.json'),
path.join(repo.baseDir, 'packages/cli/.code-pushup/report.json'),
),
).resolves.toEqual(
expect.objectContaining({
Expand All @@ -92,16 +95,16 @@ describe('CI - monorepo mode (npm workspaces)', () => {
await git.checkoutLocalBranch('feature-1');

await rename(
join(repo.baseDir, 'packages/cli/src/bin.js'),
join(repo.baseDir, 'packages/cli/src/bin.ts'),
path.join(repo.baseDir, 'packages/cli/src/bin.js'),
path.join(repo.baseDir, 'packages/cli/src/bin.ts'),
);
await rename(
join(repo.baseDir, 'packages/core/src/index.js'),
join(repo.baseDir, 'packages/core/src/index.ts'),
path.join(repo.baseDir, 'packages/core/src/index.js'),
path.join(repo.baseDir, 'packages/core/src/index.ts'),
);
await rename(
join(repo.baseDir, 'packages/core/code-pushup.config.js'),
join(repo.baseDir, 'packages/core/code-pushup.config.ts'),
path.join(repo.baseDir, 'packages/core/code-pushup.config.js'),
path.join(repo.baseDir, 'packages/core/code-pushup.config.ts'),
);

await git.add('.');
Expand All @@ -117,24 +120,27 @@ describe('CI - monorepo mode (npm workspaces)', () => {
await expect(runInCI(refs, MOCK_API, options, git)).resolves.toEqual({
mode: 'monorepo',
commentId: MOCK_COMMENT.id,
diffPath: join(repo.baseDir, '.code-pushup/merged-report-diff.md'),
diffPath: path.join(repo.baseDir, '.code-pushup/merged-report-diff.md'),
projects: expect.arrayContaining<ProjectRunResult>([
{
name: '@example/core',
files: {
report: {
json: join(
json: path.join(
repo.baseDir,
'packages/core/.code-pushup/report.json',
),
md: join(repo.baseDir, 'packages/core/.code-pushup/report.md'),
md: path.join(
repo.baseDir,
'packages/core/.code-pushup/report.md',
),
},
diff: {
json: join(
json: path.join(
repo.baseDir,
'packages/core/.code-pushup/report-diff.json',
),
md: join(
md: path.join(
repo.baseDir,
'packages/core/.code-pushup/report-diff.md',
),
Expand All @@ -146,15 +152,15 @@ describe('CI - monorepo mode (npm workspaces)', () => {
} satisfies RunResult);

const mdPromise = readFile(
join(repo.baseDir, '.code-pushup/merged-report-diff.md'),
path.join(repo.baseDir, '.code-pushup/merged-report-diff.md'),
'utf8',
);
await expect(mdPromise).resolves.toBeTruthy();
const md = await mdPromise;
await expect(
md.replace(/[\da-f]{40}/g, '`<commit-sha>`'),
).toMatchFileSnapshot(
join(TEST_SNAPSHOTS_DIR, 'npm-workspaces-report-diff.md'),
path.join(TEST_SNAPSHOTS_DIR, 'npm-workspaces-report-diff.md'),
);
});
});
Expand Down
Loading
Loading