Skip to content

Commit bbd9aee

Browse files
authored
chore: address lint issues (#642)
Signed-off-by: Michael Beemer <[email protected]>
1 parent 2213946 commit bbd9aee

Some content is hidden

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

50 files changed

+822
-870
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export * from './lib/traces';
2-
export * from './lib/metrics';
2+
export * from './lib/metrics';
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// see: https://opentelemetry.io/docs/specs/otel/logs/semantic_conventions/feature-flags/
22
export const FEATURE_FLAG = 'feature_flag';
3-
export const EXCEPTION_ATTR = 'exception'
3+
export const EXCEPTION_ATTR = 'exception';
44

55
export const ACTIVE_COUNT_NAME = `${FEATURE_FLAG}.evaluation_active_count`;
66
export const REQUESTS_TOTAL_NAME = `${FEATURE_FLAG}.evaluation_requests_total`;
77
export const SUCCESS_TOTAL_NAME = `${FEATURE_FLAG}.evaluation_success_total`;
88
export const ERROR_TOTAL_NAME = `${FEATURE_FLAG}.evaluation_error_total`;
99

10-
export type EvaluationAttributes = {[key: `${typeof FEATURE_FLAG}.${string}`]: string | undefined };
10+
export type EvaluationAttributes = { [key: `${typeof FEATURE_FLAG}.${string}`]: string | undefined };
1111
export type ExceptionAttributes = { [EXCEPTION_ATTR]: string };
1212

1313
export const KEY_ATTR: keyof EvaluationAttributes = `${FEATURE_FLAG}.key`;
1414
export const PROVIDER_NAME_ATTR: keyof EvaluationAttributes = `${FEATURE_FLAG}.provider_name`;
1515
export const VARIANT_ATTR: keyof EvaluationAttributes = `${FEATURE_FLAG}.variant`;
16-
export const REASON_ATTR: keyof EvaluationAttributes = `${FEATURE_FLAG}.reason`;
16+
export const REASON_ATTR: keyof EvaluationAttributes = `${FEATURE_FLAG}.reason`;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './metrics-hook';
1+
export * from './metrics-hook';

libs/hooks/open-telemetry/src/lib/metrics/metrics-hook.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
type EvaluationDetails,
66
type FlagValue,
77
type Hook,
8-
type HookContext
8+
type HookContext,
99
} from '@openfeature/server-sdk';
1010
import { Attributes, Counter, UpDownCounter, ValueType, metrics } from '@opentelemetry/api';
1111
import {
@@ -19,7 +19,7 @@ import {
1919
REASON_ATTR,
2020
REQUESTS_TOTAL_NAME,
2121
SUCCESS_TOTAL_NAME,
22-
VARIANT_ATTR
22+
VARIANT_ATTR,
2323
} from '../conventions';
2424
import { OpenTelemetryHook, OpenTelemetryHookOptions } from '../otel-hook';
2525

@@ -36,7 +36,7 @@ const ERROR_DESCRIPTION = 'feature flag evaluation error counter';
3636

3737
/**
3838
* A hook that adds conventionally-compliant metrics to feature flag evaluations.
39-
*
39+
*
4040
* See {@link https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/feature-flags/}
4141
*/
4242
export class MetricsHook extends OpenTelemetryHook implements Hook {
@@ -46,7 +46,10 @@ export class MetricsHook extends OpenTelemetryHook implements Hook {
4646
private readonly evaluationSuccessCounter: Counter<EvaluationAttributes | Attributes>;
4747
private readonly evaluationErrorCounter: Counter<ErrorEvaluationAttributes>;
4848

49-
constructor(options?: MetricsHookOptions, private readonly logger?: Logger) {
49+
constructor(
50+
options?: MetricsHookOptions,
51+
private readonly logger?: Logger,
52+
) {
5053
super(options, logger);
5154
const meter = metrics.getMeter(METER_NAME);
5255
this.evaluationActiveUpDownCounter = meter.createUpDownCounter(ACTIVE_COUNT_NAME, {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './tracing-hook';
1+
export * from './tracing-hook';

libs/hooks/open-telemetry/src/lib/traces/tracing-hook.spec.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,47 +51,47 @@ describe('OpenTelemetry Hooks', () => {
5151
variant: 'enabled',
5252
flagMetadata: {},
5353
};
54-
54+
5555
tracingHook.after(hookContext, evaluationDetails);
56-
56+
5757
expect(addEvent).toBeCalledWith('feature_flag', {
5858
'feature_flag.key': 'testFlagKey',
5959
'feature_flag.provider_name': 'testProvider',
6060
'feature_flag.variant': 'enabled',
6161
});
6262
});
63-
63+
6464
it('should use a stringified value as the variant value on the span event', () => {
6565
const evaluationDetails: EvaluationDetails<boolean> = {
6666
flagKey: hookContext.flagKey,
6767
value: true,
6868
flagMetadata: {},
6969
};
70-
70+
7171
tracingHook.after(hookContext, evaluationDetails);
72-
72+
7373
expect(addEvent).toBeCalledWith('feature_flag', {
7474
'feature_flag.key': 'testFlagKey',
7575
'feature_flag.provider_name': 'testProvider',
7676
'feature_flag.variant': 'true',
7777
});
7878
});
79-
79+
8080
it('should set the value without extra quotes if value is already a string', () => {
8181
const evaluationDetails: EvaluationDetails<string> = {
8282
flagKey: hookContext.flagKey,
8383
value: 'already-string',
8484
flagMetadata: {},
8585
};
8686
tracingHook.after(hookContext, evaluationDetails);
87-
87+
8888
expect(addEvent).toBeCalledWith('feature_flag', {
8989
'feature_flag.key': 'testFlagKey',
9090
'feature_flag.provider_name': 'testProvider',
9191
'feature_flag.variant': 'already-string',
9292
});
9393
});
94-
94+
9595
it('should not call addEvent because there is no active span', () => {
9696
getActiveSpan.mockReturnValueOnce(undefined);
9797
const evaluationDetails: EvaluationDetails<boolean> = {
@@ -100,15 +100,14 @@ describe('OpenTelemetry Hooks', () => {
100100
variant: 'enabled',
101101
flagMetadata: {},
102102
};
103-
103+
104104
tracingHook.after(hookContext, evaluationDetails);
105105
expect(addEvent).not.toBeCalled();
106106
});
107107
});
108108

109109
describe('attribute mapper configured', () => {
110110
describe('no error in mapper', () => {
111-
112111
beforeEach(() => {
113112
tracingHook = new TracingHook({
114113
attributeMapper: (flagMetadata) => {
@@ -132,9 +131,9 @@ describe('OpenTelemetry Hooks', () => {
132131
metadata3: true,
133132
},
134133
};
135-
134+
136135
tracingHook.after(hookContext, evaluationDetails);
137-
136+
138137
expect(addEvent).toBeCalledWith('feature_flag', {
139138
'feature_flag.key': 'testFlagKey',
140139
'feature_flag.provider_name': 'testProvider',
@@ -147,7 +146,6 @@ describe('OpenTelemetry Hooks', () => {
147146
});
148147

149148
describe('error in mapper', () => {
150-
151149
beforeEach(() => {
152150
tracingHook = new TracingHook({
153151
attributeMapper: (_) => {
@@ -167,9 +165,9 @@ describe('OpenTelemetry Hooks', () => {
167165
metadata3: true,
168166
},
169167
};
170-
168+
171169
tracingHook.after(hookContext, evaluationDetails);
172-
170+
173171
expect(addEvent).toBeCalledWith('feature_flag', {
174172
'feature_flag.key': 'testFlagKey',
175173
'feature_flag.provider_name': 'testProvider',

libs/hooks/open-telemetry/src/lib/traces/tracing-hook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type TracingHookOptions = OpenTelemetryHookOptions;
77

88
/**
99
* A hook that adds conventionally-compliant span events to feature flag evaluations.
10-
*
10+
*
1111
* See {@link https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/feature-flags/}
1212
*/
1313
export class TracingHook extends OpenTelemetryHook implements Hook {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ describe('ConfigCatProvider', () => {
165165

166166
it('should throw TypeMismatchError if type is different than expected', async () => {
167167
await expect(provider.resolveBooleanEvaluation('number1', false, { targetingKey })).rejects.toThrow(
168-
TypeMismatchError
168+
TypeMismatchError,
169169
);
170170
});
171171
});
@@ -183,7 +183,7 @@ describe('ConfigCatProvider', () => {
183183

184184
it('should throw TypeMismatchError if type is different than expected', async () => {
185185
await expect(provider.resolveStringEvaluation('number1', 'default', { targetingKey })).rejects.toThrow(
186-
TypeMismatchError
186+
TypeMismatchError,
187187
);
188188
});
189189
});
@@ -201,7 +201,7 @@ describe('ConfigCatProvider', () => {
201201

202202
it('should throw TypeMismatchError if type is different than expected', async () => {
203203
await expect(provider.resolveNumberEvaluation('stringTest', 0, { targetingKey })).rejects.toThrow(
204-
TypeMismatchError
204+
TypeMismatchError,
205205
);
206206
});
207207
});
@@ -223,7 +223,7 @@ describe('ConfigCatProvider', () => {
223223

224224
it('should throw TypeMismatchError if string is only a JSON primitive', async () => {
225225
await expect(provider.resolveObjectEvaluation('jsonPrimitive', {}, { targetingKey })).rejects.toThrow(
226-
TypeMismatchError
226+
TypeMismatchError,
227227
);
228228
});
229229
});

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class ConfigCatProvider implements Provider {
6363
hooks.on('configChanged', (projectConfig: IConfig | undefined) =>
6464
this.events.emit(ProviderEvents.ConfigurationChanged, {
6565
flagsChanged: projectConfig ? Object.keys(projectConfig.settings) : undefined,
66-
})
66+
}),
6767
);
6868

6969
hooks.on('clientError', (message: string, error) => {
@@ -90,7 +90,7 @@ export class ConfigCatProvider implements Provider {
9090
async resolveBooleanEvaluation(
9191
flagKey: string,
9292
defaultValue: boolean,
93-
context: EvaluationContext
93+
context: EvaluationContext,
9494
): Promise<ResolutionDetails<boolean>> {
9595
if (!this._client) {
9696
throw new GeneralError('Provider is not initialized');
@@ -99,7 +99,7 @@ export class ConfigCatProvider implements Provider {
9999
const { value, ...evaluationData } = await this._client.getValueDetailsAsync<SettingValue>(
100100
flagKey,
101101
undefined,
102-
transformContext(context)
102+
transformContext(context),
103103
);
104104

105105
const validatedValue = validateFlagType('boolean', value);
@@ -112,7 +112,7 @@ export class ConfigCatProvider implements Provider {
112112
public async resolveStringEvaluation(
113113
flagKey: string,
114114
defaultValue: string,
115-
context: EvaluationContext
115+
context: EvaluationContext,
116116
): Promise<ResolutionDetails<string>> {
117117
if (!this._client) {
118118
throw new GeneralError('Provider is not initialized');
@@ -121,7 +121,7 @@ export class ConfigCatProvider implements Provider {
121121
const { value, ...evaluationData } = await this._client.getValueDetailsAsync<SettingValue>(
122122
flagKey,
123123
undefined,
124-
transformContext(context)
124+
transformContext(context),
125125
);
126126

127127
const validatedValue = validateFlagType('string', value);
@@ -134,7 +134,7 @@ export class ConfigCatProvider implements Provider {
134134
public async resolveNumberEvaluation(
135135
flagKey: string,
136136
defaultValue: number,
137-
context: EvaluationContext
137+
context: EvaluationContext,
138138
): Promise<ResolutionDetails<number>> {
139139
if (!this._client) {
140140
throw new GeneralError('Provider is not initialized');
@@ -143,7 +143,7 @@ export class ConfigCatProvider implements Provider {
143143
const { value, ...evaluationData } = await this._client.getValueDetailsAsync<SettingValue>(
144144
flagKey,
145145
undefined,
146-
transformContext(context)
146+
transformContext(context),
147147
);
148148

149149
const validatedValue = validateFlagType('number', value);
@@ -156,7 +156,7 @@ export class ConfigCatProvider implements Provider {
156156
public async resolveObjectEvaluation<U extends JsonValue>(
157157
flagKey: string,
158158
defaultValue: U,
159-
context: EvaluationContext
159+
context: EvaluationContext,
160160
): Promise<ResolutionDetails<U>> {
161161
if (!this._client) {
162162
throw new GeneralError('Provider is not initialized');
@@ -165,7 +165,7 @@ export class ConfigCatProvider implements Provider {
165165
const { value, ...evaluationData } = await this._client.getValueDetailsAsync(
166166
flagKey,
167167
undefined,
168-
transformContext(context)
168+
transformContext(context),
169169
);
170170

171171
if (typeof value === 'undefined') {
@@ -197,7 +197,7 @@ export class ConfigCatProvider implements Provider {
197197
function toResolutionDetails<U extends JsonValue>(
198198
value: U,
199199
data: Omit<IEvaluationDetails, 'value'>,
200-
reason?: ResolutionReason
200+
reason?: ResolutionReason,
201201
): ResolutionDetails<U> {
202202
const matchedRule = Boolean(data.matchedEvaluationRule || data.matchedEvaluationPercentageRule);
203203
const evaluatedReason = matchedRule ? StandardResolutionReasons.TARGETING_MATCH : StandardResolutionReasons.STATIC;

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ describe('context-transformer', () => {
1111
expect(() => transformContext(context)).toThrow(TargetingKeyMissingError);
1212
});
1313

14-
1514
it('map targeting key to identifier', () => {
1615
const context: EvaluationContext = {
1716
targetingKey: 'test',
@@ -126,8 +125,8 @@ describe('context-transformer', () => {
126125
it('map several custom properties correctly', () => {
127126
const context: EvaluationContext = {
128127
targetingKey: 'test',
129-
email: "email",
130-
country: "country",
128+
email: 'email',
129+
country: 'country',
131130
customString: 'customString',
132131
customNumber: 1,
133132
customBoolean: true,
@@ -140,8 +139,8 @@ describe('context-transformer', () => {
140139

141140
const user = {
142141
identifier: 'test',
143-
email: "email",
144-
country: "country",
142+
email: 'email',
143+
country: 'country',
145144
custom: {
146145
customString: 'customString',
147146
customBoolean: 'true',

0 commit comments

Comments
 (0)