Skip to content

Commit b74bdc2

Browse files
committed
refactor: wip
1 parent 4f01e32 commit b74bdc2

12 files changed

Lines changed: 25 additions & 44 deletions

packages/utils/mocks/omit-trace-json.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,6 @@ const parseJsonl = (input: string): TraceEvent[] =>
3030
.filter(Boolean)
3131
.map(line => JSON.parse(line) as TraceEvent);
3232

33-
/**
34-
* Normalizes encoded events and preserves encoded format.
35-
* Similar to normalizeEncoded but works directly on encoded events from JSONL.
36-
*/
37-
const normalizeEncodedJsonl = (
38-
events: TraceEvent[],
39-
options?: { baseTimestampUs: number },
40-
): TraceEvent[] => {
41-
// Decode temporarily to normalize (normalizeAndFormatEvents needs decoded format)
42-
const decodedEvents = events.map(decodeEvent);
43-
const normalizedDecoded = normalizeAndFormatEvents(decodedEvents, options);
44-
// Re-encode to preserve serialized format
45-
return normalizedDecoded.map(encodeEvent);
46-
};
47-
4833
/**
4934
* Loads and normalizes trace events from a JSONL file.
5035
* Parses the file, decodes all events, normalizes them for deterministic testing,

packages/utils/src/lib/process-id.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export function getUniqueInstanceIdAndUpdate(
105105
getCount: () => number,
106106
setCount: (value: number) => void,
107107
): string {
108+
// eslint-disable-next-line functional/no-let
108109
let value = getCount();
109110
const counter: Counter = {
110111
next() {

packages/utils/src/lib/profiler/profiler-node.int.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ describe('NodeJS Profiler Integration', () => {
185185
performance.clearMeasures();
186186
vi.stubEnv(PROFILER_ENABLED_ENV_VAR, undefined!);
187187
vi.stubEnv(PROFILER_DEBUG_ENV_VAR, undefined!);
188-
// eslint-disable-next-line functional/immutable-data
188+
// eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-dynamic-delete
189189
delete process.env[PROFILER_SHARDER_ID_ENV_VAR];
190190
});
191191

@@ -199,7 +199,7 @@ describe('NodeJS Profiler Integration', () => {
199199

200200
vi.stubEnv(PROFILER_ENABLED_ENV_VAR, undefined!);
201201
vi.stubEnv(PROFILER_DEBUG_ENV_VAR, undefined!);
202-
// eslint-disable-next-line functional/immutable-data
202+
// eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-dynamic-delete
203203
delete process.env[PROFILER_SHARDER_ID_ENV_VAR];
204204
});
205205

packages/utils/src/lib/profiler/profiler-node.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import {
77
import { objectToEntries } from '../transform.js';
88
import { errorToMarkerPayload } from '../user-timing-extensibility-api-utils.js';
99
import type {
10-
ActionColorPayload,
1110
ActionTrackEntryPayload,
12-
DevToolsActionColor,
1311
MarkerPayload,
1412
} from '../user-timing-extensibility-api.type.js';
1513
import { ShardedWal } from '../wal-sharded.js';

packages/utils/src/lib/profiler/profiler-node.unit.test.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import path from 'node:path';
21
import { performance } from 'node:perf_hooks';
32
import { beforeEach, describe, expect, it, vi } from 'vitest';
43
import { awaitObserverCallbackAndFlush } from '@code-pushup/test-utils';
@@ -40,7 +39,7 @@ const resetEnv = () => {
4039
delete process.env.DEBUG;
4140
// eslint-disable-next-line functional/immutable-data
4241
delete process.env.CP_PROFILING;
43-
// eslint-disable-next-line functional/immutable-data
42+
// eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-dynamic-delete
4443
delete process.env[PROFILER_SHARDER_ID_ENV_VAR];
4544
};
4645

@@ -197,6 +196,7 @@ describe('NodejsProfiler', () => {
197196
expect(profiler.stats.isSubscribed).toBe(true);
198197
});
199198

199+
// eslint-disable-next-line vitest/expect-expect
200200
it('should initialize with sink closed when enabled is false', () => {
201201
const profiler = createProfiler({
202202
measureName: 'init-disabled',
@@ -300,6 +300,7 @@ describe('NodejsProfiler', () => {
300300
expect(profiler.state).toBe('closed');
301301
});
302302

303+
// eslint-disable-next-line vitest/expect-expect
303304
it('should maintain state invariant: running ⇒ sink open + observer subscribed', () => {
304305
const profiler = createProfiler({
305306
measureName: 'state-invariant',
@@ -584,6 +585,7 @@ describe('NodejsProfiler', () => {
584585
expect(debugProfiler.debug).toBe(true);
585586
});
586587

588+
// eslint-disable-next-line vitest/expect-expect
587589
it('should create transition marker when debug is enabled and transitioning to running', () => {
588590
// eslint-disable-next-line functional/immutable-data
589591
process.env.DEBUG = 'true';
@@ -598,19 +600,7 @@ describe('NodejsProfiler', () => {
598600
expectTransitionMarker('debug:idle->running');
599601
});
600602

601-
it('should not create transition marker when transitioning from running to idle (profiler disabled)', () => {
602-
// eslint-disable-next-line functional/immutable-data
603-
process.env.DEBUG = 'true';
604-
const profiler = createProfiler({
605-
measureName: 'debug-no-transition-marker',
606-
});
607-
608-
performance.clearMarks();
609-
profiler.setEnabled(false);
610-
611-
expectNoTransitionMarker('running->idle');
612-
});
613-
603+
// eslint-disable-next-line vitest/expect-expect
614604
it('does not emit transition markers unless debug is enabled', () => {
615605
const profiler = createProfiler('no-transition-markers');
616606

packages/utils/src/lib/profiler/profiler.int.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { ActionTrackConfigs } from '../user-timing-extensibility-api-utils.js';
2-
import { PROFILER_ENABLED_ENV_VAR } from './constants.js';
32
import { Profiler, type ProfilerOptions } from './profiler.js';
43

54
describe('Profiler Integration', () => {
@@ -34,9 +33,6 @@ describe('Profiler Integration', () => {
3433
),
3534
),
3635
).toBe(499_500);
37-
38-
const marks = performance.getEntriesByType('mark');
39-
const measures = performance.getEntriesByType('measure');
4036
});
4137

4238
it('should create complete performance timeline for async operation', async () => {

packages/utils/src/lib/profiler/profiler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
} from '../user-timing-extensibility-api-utils.js';
1414
import type {
1515
ActionTrackEntryPayload,
16-
DevToolsActionColor,
1716
DevToolsColor,
1817
EntryMeta,
1918
} from '../user-timing-extensibility-api.type.js';

packages/utils/src/lib/profiler/trace-file-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const getInstantEventTracingStartedInBrowser = (
130130
},
131131
],
132132
persistentIds: true,
133-
} as Record<string, unknown>,
133+
} satisfies Record<string, unknown>,
134134
},
135135
};
136136
};

packages/utils/src/lib/wal-sharded.int.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'node:path';
33
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
44
import { PROFILER_SHARDER_ID_ENV_VAR } from './profiler/constants.js';
55
import { ShardedWal } from './wal-sharded.js';
6-
import { createTolerantCodec, stringCodec } from './wal.js';
6+
import { createTolerantCodec } from './wal.js';
77

88
describe('ShardedWal Integration', () => {
99
const testDir = path.join(

packages/utils/src/lib/wal-sharded.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { threadId } from 'node:worker_threads';
55
import {
66
type Counter,
77
getUniqueInstanceId,
8-
getUniqueProcessThreadId,
98
getUniqueTimeId,
109
} from './process-id.js';
1110
import {
@@ -131,6 +130,7 @@ export class ShardedWal<T extends object = object> {
131130
opt;
132131

133132
// Determine groupId: use provided, then env var, or generate
133+
// eslint-disable-next-line functional/no-let
134134
let resolvedGroupId: string;
135135
if (groupId) {
136136
// User explicitly provided groupId - use it

0 commit comments

Comments
 (0)