Skip to content

Commit 9647e30

Browse files
committed
refactor: cleanup/prettier
1 parent 311364d commit 9647e30

22 files changed

+254
-208
lines changed

src/application-logger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import pino from 'pino';
22

3+
/** @internal */
34
export const loggerPrefix = '[Eppo SDK]';
45

5-
// Create a Pino logger instance
6+
/** @internal */
67
export const logger = pino({
78
// eslint-disable-next-line no-restricted-globals
89
level: process.env.LOG_LEVEL ?? (process.env.NODE_ENV === 'production' ? 'warn' : 'info'),

src/broadcast.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export type Listener<T extends unknown[]> = (...args: T) => void;
22

33
/**
44
* A broadcast channel for dispatching events to multiple listeners.
5-
*
5+
*
66
* @internal
77
*/
88
export class BroadcastChannel<T extends unknown[]> {
@@ -29,4 +29,4 @@ export class BroadcastChannel<T extends unknown[]> {
2929
}
3030
}
3131
}
32-
}
32+
}

src/cache/tlru-cache.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import { LRUCache } from './lru-cache';
88
**/
99
export class TLRUCache extends LRUCache {
1010
private readonly cacheEntriesTTLRegistry = new Map<string, Date>();
11-
constructor(
12-
readonly maxSize: number,
13-
readonly ttl: number,
14-
) {
11+
constructor(readonly maxSize: number, readonly ttl: number) {
1512
super(maxSize);
1613
}
1714

src/client/eppo-client-assignment-details.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import * as fs from 'fs';
22

3-
import {
4-
IAssignmentTestCase,
5-
readMockUfcConfiguration,
6-
} from '../../test/testHelpers';
3+
import { IAssignmentTestCase, readMockUfcConfiguration } from '../../test/testHelpers';
74
import { AllocationEvaluationCode } from '../flag-evaluation-details-builder';
85
import { Variation, VariationType } from '../interfaces';
96
import { OperatorType } from '../rules';

src/client/eppo-client-experiment-container.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('getExperimentContainerEntry', () => {
1717
let loggerWarnSpy: jest.SpyInstance;
1818

1919
beforeEach(async () => {
20-
client = new EppoClient({
20+
client = new EppoClient({
2121
configuration: {
2222
initializationStrategy: 'none',
2323
initialConfiguration: readMockUfcConfiguration(),

src/client/eppo-client-with-bandits.spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ describe('EppoClient Bandits E2E test', () => {
517517
unmatchedAllocations: [],
518518
unevaluatedAllocations: [],
519519
};
520-
520+
521521
return {
522522
assignmentDetails: {
523523
flagKey,
@@ -549,7 +549,7 @@ describe('EppoClient Bandits E2E test', () => {
549549
},
550550
evaluationDetails,
551551
entityId: null,
552-
}
552+
},
553553
};
554554
});
555555

@@ -681,11 +681,7 @@ describe('EppoClient Bandits E2E test', () => {
681681
subjectAttributes: ContextAttributes,
682682
banditActions: Record<string, BanditActions>,
683683
): Configuration {
684-
return client.getPrecomputedConfiguration(
685-
subjectKey,
686-
subjectAttributes,
687-
banditActions,
688-
);
684+
return client.getPrecomputedConfiguration(subjectKey, subjectAttributes, banditActions);
689685
}
690686

691687
describe('obfuscated results', () => {

src/client/eppo-client-with-overrides.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import * as overrideValidatorModule from '../override-validator';
55
import EppoClient from './eppo-client';
66

77
describe('EppoClient', () => {
8-
function setUnobfuscatedFlagEntries(
9-
entries: Record<string, Flag>,
10-
): EppoClient {
8+
function setUnobfuscatedFlagEntries(entries: Record<string, Flag>): EppoClient {
119
return new EppoClient({
1210
sdkKey: 'dummy',
1311
sdkName: 'js-client-sdk-common',
@@ -26,8 +24,8 @@ describe('EppoClient', () => {
2624
},
2725
banditReferences: {},
2826
},
29-
}
30-
})
27+
},
28+
}),
3129
},
3230
});
3331
}

src/client/eppo-client.precomputed.spec.ts

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import EppoClient from './eppo-client';
1111

1212
describe('EppoClient Precomputed Mode', () => {
1313
// Read both configurations for test reference
14-
const precomputedConfigurationWire = readMockConfigurationWireResponse(MOCK_PRECOMPUTED_WIRE_FILE);
14+
const precomputedConfigurationWire = readMockConfigurationWireResponse(
15+
MOCK_PRECOMPUTED_WIRE_FILE,
16+
);
1517
const initialConfiguration = Configuration.fromString(precomputedConfigurationWire);
1618

1719
let client: EppoClient;
@@ -21,7 +23,7 @@ describe('EppoClient Precomputed Mode', () => {
2123
beforeEach(() => {
2224
mockAssignmentLogger = { logAssignment: jest.fn() } as jest.Mocked<IAssignmentLogger>;
2325
mockBanditLogger = { logBanditAction: jest.fn() } as jest.Mocked<IBanditLogger>;
24-
26+
2527
// Create EppoClient with precomputed configuration
2628
client = new EppoClient({
2729
sdkKey: 'test-key',
@@ -33,7 +35,7 @@ describe('EppoClient Precomputed Mode', () => {
3335
enablePolling: false,
3436
},
3537
});
36-
38+
3739
client.setAssignmentLogger(mockAssignmentLogger);
3840
client.setBanditLogger(mockBanditLogger);
3941
});
@@ -67,29 +69,40 @@ describe('EppoClient Precomputed Mode', () => {
6769
expect(result).toEqual({ key: 'value', number: 123 });
6870
expect(mockAssignmentLogger.logAssignment).toHaveBeenCalledTimes(1);
6971
});
70-
72+
7173
it('correctly evaluates flag with extra logging', () => {
72-
const result = client.getStringAssignment('string-flag-with-extra-logging', 'test-subject-key', {}, 'default');
74+
const result = client.getStringAssignment(
75+
'string-flag-with-extra-logging',
76+
'test-subject-key',
77+
{},
78+
'default',
79+
);
7380
expect(result).toBe('red');
7481
expect(mockAssignmentLogger.logAssignment).toHaveBeenCalledTimes(1);
7582
});
7683

7784
it('logs bandit evaluation for flag with bandit data', () => {
7885
const banditActions = {
79-
'show_red_button': {
86+
show_red_button: {
8087
expectedConversion: 0.23,
8188
expectedRevenue: 15.75,
8289
category: 'promotion',
83-
placement: 'home_screen'
84-
}
90+
placement: 'home_screen',
91+
},
8592
};
86-
87-
const result = client.getBanditAction('string-flag', 'test-subject-key', {}, banditActions, 'default');
88-
93+
94+
const result = client.getBanditAction(
95+
'string-flag',
96+
'test-subject-key',
97+
{},
98+
banditActions,
99+
'default',
100+
);
101+
89102
expect(result.variation).toBe('red');
90103
expect(result.action).toBe('show_red_button');
91104
expect(mockBanditLogger.logBanditAction).toHaveBeenCalledTimes(1);
92-
105+
93106
const call = mockBanditLogger.logBanditAction.mock.calls[0][0];
94107
expect(call.bandit).toBe('recommendation-model-v1');
95108
expect(call.action).toBe('show_red_button');
@@ -99,27 +112,42 @@ describe('EppoClient Precomputed Mode', () => {
99112
});
100113

101114
it('returns default values for nonexistent flags', () => {
102-
const stringResult = client.getStringAssignment('nonexistent-flag', 'test-subject-key', {}, 'default-string');
115+
const stringResult = client.getStringAssignment(
116+
'nonexistent-flag',
117+
'test-subject-key',
118+
{},
119+
'default-string',
120+
);
103121
expect(stringResult).toBe('default-string');
104-
105-
const boolResult = client.getBooleanAssignment('nonexistent-flag', 'test-subject-key', {}, true);
122+
123+
const boolResult = client.getBooleanAssignment(
124+
'nonexistent-flag',
125+
'test-subject-key',
126+
{},
127+
true,
128+
);
106129
expect(boolResult).toBe(true);
107-
130+
108131
const intResult = client.getIntegerAssignment('nonexistent-flag', 'test-subject-key', {}, 100);
109132
expect(intResult).toBe(100);
110133
});
111134

112135
it('correctly handles assignment details', () => {
113-
const details = client.getStringAssignmentDetails('string-flag', 'test-subject-key', {}, 'default');
114-
136+
const details = client.getStringAssignmentDetails(
137+
'string-flag',
138+
'test-subject-key',
139+
{},
140+
'default',
141+
);
142+
115143
expect(details.variation).toBe('red');
116144
expect(details.evaluationDetails.variationKey).toBe('variation-123');
117-
145+
118146
// Assignment should be logged
119147
expect(mockAssignmentLogger.logAssignment).toHaveBeenCalledTimes(1);
120148
const call = mockAssignmentLogger.logAssignment.mock.calls[0][0];
121149
expect(call.allocation).toBe('allocation-123');
122150
expect(call.featureFlag).toBe('string-flag');
123151
expect(call.subject).toBe('test-subject-key');
124152
});
125-
});
153+
});

src/client/eppo-client.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import * as base64 from 'js-base64';
22
import { times } from 'lodash';
33
import * as td from 'testdouble';
44

5-
import {
6-
MOCK_UFC_RESPONSE_FILE,
7-
readMockUFCResponse,
8-
} from '../../test/testHelpers';
5+
import { MOCK_UFC_RESPONSE_FILE, readMockUFCResponse } from '../../test/testHelpers';
96
import { IAssignmentLogger } from '../assignment-logger';
107
import { AssignmentCache } from '../cache/abstract-assignment-cache';
118
import {
@@ -28,7 +25,6 @@ jest.mock('../salt', () => ({
2825
}));
2926

3027
describe('EppoClient E2E test', () => {
31-
3228
// Configure fetch mock for tests that still need it
3329
global.fetch = jest.fn(() => {
3430
const ufc = readMockUFCResponse(MOCK_UFC_RESPONSE_FILE);

0 commit comments

Comments
 (0)