Skip to content

Commit 84d299e

Browse files
committed
fix: lint
1 parent eeab93f commit 84d299e

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

app-config-extensions/src/parse-directive.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ describe('$parseBool', () => {
4141
});
4242

4343
it('should parse numbers', async () => {
44-
await expect(
45-
new LiteralSource({ $parseBool: 1 }).readToJSON([parseDirective()]),
46-
).resolves.toBe(true);
44+
await expect(new LiteralSource({ $parseBool: 1 }).readToJSON([parseDirective()])).resolves.toBe(
45+
true,
46+
);
4747

48-
await expect(
49-
new LiteralSource({ $parseBool: 0 }).readToJSON([parseDirective()]),
50-
).resolves.toBe(false);
48+
await expect(new LiteralSource({ $parseBool: 0 }).readToJSON([parseDirective()])).resolves.toBe(
49+
false,
50+
);
5151
});
5252
});
5353

@@ -93,9 +93,9 @@ describe('$parseInt', () => {
9393
new LiteralSource({ $parseInt: 12.12 }).readToJSON([parseDirective()]),
9494
).resolves.toBe(12);
9595

96-
await expect(
97-
new LiteralSource({ $parseInt: 0 }).readToJSON([parseDirective()]),
98-
).resolves.toBe(0);
96+
await expect(new LiteralSource({ $parseInt: 0 }).readToJSON([parseDirective()])).resolves.toBe(
97+
0,
98+
);
9999
});
100100

101101
it('should parse string values', async () => {

app-config-extensions/src/parse-directive.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ParsingExtension } from '@app-config/core';
22
import { AppConfigError } from '@app-config/core';
3-
import { named, forKey, validateOptions, composeExtensions } from '@app-config/extension-utils';
3+
import { named, forKey, composeExtensions } from '@app-config/extension-utils';
44

55
/** Provides string parsing */
66
export function parseDirective(): ParsingExtension {
@@ -28,36 +28,41 @@ export function parseDirective(): ParsingExtension {
2828
}
2929

3030
if (typeof primitive === 'string') {
31-
const parsed = Number.parseFloat(primitive);
31+
const floatValue = Number.parseFloat(primitive);
3232

33-
if (Number.isNaN(parsed)) {
33+
if (Number.isNaN(floatValue)) {
3434
throw new AppConfigError(`Failed to $parseFloat(${primitive})`);
3535
}
3636

37-
return parse(parsed, { shouldFlatten: true });
37+
return parse(floatValue, { shouldFlatten: true });
3838
}
3939

40-
throw new AppConfigError(`Failed to $parseFloat(${parsed.toJSON()}) - invalid input type`);
40+
throw new AppConfigError(
41+
`Failed to $parseFloat(${parsed.toJSON() as string}) - invalid input type`,
42+
);
4143
}),
4244
forKey('$parseInt', (value) => async (parse) => {
4345
const parsed = await parse(value);
4446
const primitive = parsed.asPrimitive();
4547

4648
if (typeof primitive === 'number') {
49+
// eslint-disable-next-line no-bitwise
4750
return parse(primitive | 0, { shouldFlatten: true });
4851
}
4952

5053
if (typeof primitive === 'string') {
51-
const parsed = Number.parseInt(primitive, 10);
54+
const intValue = Number.parseInt(primitive, 10);
5255

53-
if (Number.isNaN(parsed)) {
56+
if (Number.isNaN(intValue)) {
5457
throw new AppConfigError(`Failed to $parseInt(${primitive})`);
5558
}
5659

57-
return parse(parsed, { shouldFlatten: true });
60+
return parse(intValue, { shouldFlatten: true });
5861
}
5962

60-
throw new AppConfigError(`Failed to $parseInt(${parsed.toJSON()}) - invalid input type`);
63+
throw new AppConfigError(
64+
`Failed to $parseInt(${parsed.toJSON() as string}) - invalid input type`,
65+
);
6166
}),
6267
]),
6368
);

0 commit comments

Comments
 (0)