Skip to content

Commit 2c8f3e4

Browse files
Adam Simonadams85
authored andcommitted
Lint fix
Signed-off-by: Adam Simon <[email protected]>
1 parent 944137f commit 2c8f3e4

File tree

6 files changed

+35
-27
lines changed

6 files changed

+35
-27
lines changed

libs/providers/config-cat-web/src/lib/config-cat-web-provider.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
LogLevel,
88
OverrideBehaviour,
99
prepareConfig,
10-
SettingType
10+
SettingType,
1111
} from '@configcat/sdk';
1212
import type { EventEmitter } from 'events';
1313
import { ProviderEvents, ParseError, FlagNotFoundError, TypeMismatchError } from '@openfeature/web-sdk';
@@ -73,7 +73,7 @@ describe('ConfigCatWebProvider', () => {
7373
describe('events', () => {
7474
it('should emit PROVIDER_CONFIGURATION_CHANGED event', () => {
7575
const handler = jest.fn();
76-
const eventData = prepareConfig({ f: { 'myFlag': { t: SettingType.Boolean, v: { b: true }, i: "" } } });
76+
const eventData = prepareConfig({ f: { myFlag: { t: SettingType.Boolean, v: { b: true }, i: '' } } });
7777

7878
provider.events.addHandler(ProviderEvents.ConfigurationChanged, handler);
7979
configCatEmitter.emit('configChanged', eventData);
@@ -84,13 +84,13 @@ describe('ConfigCatWebProvider', () => {
8484
});
8585

8686
it("should emit PROVIDER_READY event when underlying client is initialized after provider's initialize", async () => {
87-
let currentFetch = () => new FetchResponse(503, "Service Unavailable", []);
87+
let currentFetch = () => new FetchResponse(503, 'Service Unavailable', []);
8888

89-
const fakeConfigFetcher = new class implements IConfigCatConfigFetcher {
89+
const fakeConfigFetcher = new (class implements IConfigCatConfigFetcher {
9090
fetchAsync(): Promise<FetchResponse> {
9191
return Promise.resolve(currentFetch());
9292
}
93-
}();
93+
})();
9494

9595
const provider = ConfigCatWebProvider.create('configcat-sdk-1/1234567890123456789012/1234567890123456789012', {
9696
configFetcher: fakeConfigFetcher,
@@ -105,7 +105,7 @@ describe('ConfigCatWebProvider', () => {
105105

106106
expect(readyHandler).toHaveBeenCalledTimes(0);
107107

108-
currentFetch = () => new FetchResponse(200, "OK", [], '{"f":{"booleanTrue":{"t":0,"v":{"b":true}}}}');
108+
currentFetch = () => new FetchResponse(200, 'OK', [], '{"f":{"booleanTrue":{"t":0,"v":{"b":true}}}}');
109109

110110
// Make sure that the internal cache is refreshed.
111111
await provider.configCatClient?.forceRefreshAsync();

libs/providers/config-cat/src/lib/config-cat-provider.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
OverrideBehaviour,
1010
PollingMode,
1111
prepareConfig,
12-
SettingType
12+
SettingType,
1313
} from '@configcat/sdk';
1414
import type { EventEmitter } from 'events';
1515

@@ -74,7 +74,7 @@ describe('ConfigCatProvider', () => {
7474
describe('events', () => {
7575
it('should emit PROVIDER_CONFIGURATION_CHANGED event', () => {
7676
const handler = jest.fn();
77-
const eventData = prepareConfig({ f: { 'myFlag': { t: SettingType.Boolean, v: { b: true }, i: "" } } });
77+
const eventData = prepareConfig({ f: { myFlag: { t: SettingType.Boolean, v: { b: true }, i: '' } } });
7878

7979
provider.events.addHandler(ProviderEvents.ConfigurationChanged, handler);
8080
configCatEmitter.emit('configChanged', eventData);
@@ -85,13 +85,13 @@ describe('ConfigCatProvider', () => {
8585
});
8686

8787
it("should emit PROVIDER_READY event when underlying client is initialized after provider's initialize", async () => {
88-
let currentFetch = () => new FetchResponse(503, "Service Unavailable", []);
88+
let currentFetch = () => new FetchResponse(503, 'Service Unavailable', []);
8989

90-
const fakeConfigFetcher = new class implements IConfigCatConfigFetcher {
90+
const fakeConfigFetcher = new (class implements IConfigCatConfigFetcher {
9191
fetchAsync(): Promise<FetchResponse> {
9292
return Promise.resolve(currentFetch());
9393
}
94-
}();
94+
})();
9595

9696
const provider = ConfigCatProvider.create(
9797
'configcat-sdk-1/1234567890123456789012/1234567890123456789012',
@@ -110,7 +110,7 @@ describe('ConfigCatProvider', () => {
110110

111111
expect(readyHandler).toHaveBeenCalledTimes(0);
112112

113-
currentFetch = () => new FetchResponse(200, "OK", [], '{"f":{"booleanTrue":{"t":0,"v":{"b":true}}}}');
113+
currentFetch = () => new FetchResponse(200, 'OK', [], '{"f":{"booleanTrue":{"t":0,"v":{"b":true}}}}');
114114

115115
// Make sure that the internal cache is refreshed.
116116
await provider.configCatClient?.forceRefreshAsync();

libs/providers/config-cat/src/lib/config-cat-provider.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,25 @@ import {
88
} from '@openfeature/server-sdk';
99
import type { PrimitiveType, PrimitiveTypeName } from '@openfeature/config-cat-core';
1010
import { isType, toResolutionDetails, transformContext, translateError } from '@openfeature/config-cat-core';
11-
import type { Config, IConfigCatClient, INodeAutoPollOptions, INodeLazyLoadingOptions, INodeManualPollOptions, SettingValue } from '@configcat/sdk';
11+
import type {
12+
Config,
13+
IConfigCatClient,
14+
INodeAutoPollOptions,
15+
INodeLazyLoadingOptions,
16+
INodeManualPollOptions,
17+
SettingValue,
18+
} from '@configcat/sdk';
1219
import { ClientCacheState, EvaluationErrorCode, getClient, PollingMode } from '@configcat/sdk';
1320

14-
type OptionsForPollingMode<TMode extends PollingMode | undefined> =
15-
TMode extends PollingMode.AutoPoll ? INodeAutoPollOptions :
16-
TMode extends PollingMode.ManualPoll ? INodeManualPollOptions :
17-
TMode extends PollingMode.LazyLoad ? INodeLazyLoadingOptions :
18-
TMode extends undefined ? INodeAutoPollOptions :
19-
never;
21+
type OptionsForPollingMode<TMode extends PollingMode | undefined> = TMode extends PollingMode.AutoPoll
22+
? INodeAutoPollOptions
23+
: TMode extends PollingMode.ManualPoll
24+
? INodeManualPollOptions
25+
: TMode extends PollingMode.LazyLoad
26+
? INodeLazyLoadingOptions
27+
: TMode extends undefined
28+
? INodeAutoPollOptions
29+
: never;
2030

2131
export class ConfigCatProvider implements Provider {
2232
public readonly events = new OpenFeatureEventEmitter();

libs/shared/config-cat-core/src/lib/context-transformer.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('context-transformer', () => {
1313
email: undefined,
1414
country: undefined,
1515
custom: {
16-
targetingKey: context['targetingKey']
16+
targetingKey: context['targetingKey'],
1717
},
1818
};
1919

libs/shared/config-cat-core/src/lib/context-transformer.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ import type { IUser as ConfigCatUser, UserAttributeValue } from '@configcat/sdk'
44
function toUserAttributeValue(value: EvaluationContextValue): UserAttributeValue {
55
// NOTE: The ConfigCat SDK doesn't support objects and non-string arrays as user attribute values
66
// but we special-case these for backward compatibility.
7-
if (typeof value === "object"
8-
&& (!Array.isArray(value) || !value.every((item) => typeof item === 'string'))) {
7+
if (typeof value === 'object' && (!Array.isArray(value) || !value.every((item) => typeof item === 'string'))) {
98
return JSON.stringify(value);
109
}
1110

1211
// NOTE: No need to check for unsupported attribute values as the ConfigCat SDK handles those internally.
1312
return value as UserAttributeValue;
1413
}
1514

16-
function transformCustomContextValues(values: Record<string, EvaluationContextValue>): ConfigCatUser["custom"] {
17-
let attributes: ConfigCatUser["custom"];
15+
function transformCustomContextValues(values: Record<string, EvaluationContextValue>): ConfigCatUser['custom'] {
16+
let attributes: ConfigCatUser['custom'];
1817
for (const [key, value] of Object.entries(values)) {
1918
if (value != null) {
2019
const transformedValue = toUserAttributeValue(value);
@@ -39,7 +38,7 @@ export function transformContext(context: EvaluationContext): ConfigCatUser | un
3938

4039
return {
4140
// NOTE: The ConfigCat SDK handles missing or unsupported identifier values.
42-
identifier: targetingKey ?? context["identifier"] as string,
41+
identifier: targetingKey ?? (context['identifier'] as string),
4342
email: stringOrUndefined(email),
4443
country: stringOrUndefined(country),
4544
custom: transformCustomContextValues(context),

libs/shared/config-cat-core/src/lib/result-mapping.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export function toResolutionDetails<T>(
3030
}
3131

3232
export function translateError(errorCode: Exclude<EvaluationErrorCode, EvaluationErrorCode.None>): OpenFeatureError {
33-
switch (errorCode)
34-
{
33+
switch (errorCode) {
3534
case EvaluationErrorCode.InvalidConfigModel:
3635
return new ParseError();
3736
case EvaluationErrorCode.SettingValueTypeMismatch:

0 commit comments

Comments
 (0)