Skip to content

Commit b679a94

Browse files
committed
style: 💄 fix linter issues
1 parent 645f92a commit b679a94

File tree

13 files changed

+98
-77
lines changed

13 files changed

+98
-77
lines changed

src/__tests__/fixtures.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,22 @@ export const schemaCategories = {
8686
} as const;
8787

8888
const primitivesModule = new ModuleType();
89-
export const primitiveTypes = Object.entries(primitiveSchemas).reduce((acc, [key, schema]) => {
90-
acc[key] = primitivesModule.t.import(schema);
91-
return acc;
92-
}, {} as Record<string, Type>);
89+
export const primitiveTypes = Object.entries(primitiveSchemas).reduce(
90+
(acc, [key, schema]) => {
91+
acc[key] = primitivesModule.t.import(schema);
92+
return acc;
93+
},
94+
{} as Record<string, Type>,
95+
);
9396

9497
const compositesModule = new ModuleType();
95-
export const compositeTypes = Object.entries(compositeSchemas).reduce((acc, [key, schema]) => {
96-
acc[key] = compositesModule.t.import(schema);
97-
return acc;
98-
}, {} as Record<string, Type>);
98+
export const compositeTypes = Object.entries(compositeSchemas).reduce(
99+
(acc, [key, schema]) => {
100+
acc[key] = compositesModule.t.import(schema);
101+
return acc;
102+
},
103+
{} as Record<string, Type>,
104+
);
99105

100106
/**
101107
* User profile schema with nested objects and optional fields
@@ -201,15 +207,17 @@ export const Configuration = t.Object(
201207
/**
202208
* Event data schema with tuples and coordinates
203209
*/
204-
export const Event = t.Object(
205-
t.Key('id', t.String({format: 'ascii'})),
206-
t.Key('type', t.enum('click', 'view', 'purchase', 'signup')),
207-
t.Key('timestamp', t.Number({format: 'u64'})),
208-
t.Key('userId', t.maybe(t.str)),
209-
t.Key('location', t.Tuple([t.Number({format: 'f64'}), t.Number({format: 'f64'})])),
210-
t.Key('metadata', t.Map(t.Or(t.str, t.num, t.bool))),
211-
t.KeyOpt('sessionId', t.str),
212-
).alias('Event').type;
210+
export const Event = t
211+
.Object(
212+
t.Key('id', t.String({format: 'ascii'})),
213+
t.Key('type', t.enum('click', 'view', 'purchase', 'signup')),
214+
t.Key('timestamp', t.Number({format: 'u64'})),
215+
t.Key('userId', t.maybe(t.str)),
216+
t.Key('location', t.Tuple([t.Number({format: 'f64'}), t.Number({format: 'f64'})])),
217+
t.Key('metadata', t.Map(t.Or(t.str, t.num, t.bool))),
218+
t.KeyOpt('sessionId', t.str),
219+
)
220+
.alias('Event').type;
213221

214222
/**
215223
* Contact information schema with formatted strings

src/codegen/binary/AbstractBinaryCodegen.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ var uint8 = writer.uint8, view = writer.view;`,
146146
}
147147

148148
protected onBool(path: SchemaPath, r: JsExpression, type: BoolType): void {
149-
this.codegen.if(`${r.use()}`,
149+
this.codegen.if(
150+
`${r.use()}`,
150151
() => {
151152
this.blob(
152153
this.gen((encoder) => {
@@ -160,7 +161,8 @@ var uint8 = writer.uint8, view = writer.view;`,
160161
encoder.writeBoolean(false);
161162
}),
162163
);
163-
});
164+
},
165+
);
164166
}
165167

166168
protected onNum(path: SchemaPath, r: JsExpression, type: NumType): void {

src/codegen/binary/__tests__/testBinaryCodegen.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,18 @@ export const testBinaryCodegen = (transcode: (system: ModuleType, type: Type, va
250250
test('can encode complex named tuple', () => {
251251
const system = new ModuleType();
252252
const t = system.t;
253-
const type = system.t.Tuple(
254-
[t.Key('header', t.str), t.Key('version', t.num)],
255-
t.Object(t.Key('data', t.str)),
256-
[t.Key('checksum', t.num), t.Key('timestamp', t.num)],
257-
);
253+
const type = system.t.Tuple([t.Key('header', t.str), t.Key('version', t.num)], t.Object(t.Key('data', t.str)), [
254+
t.Key('checksum', t.num),
255+
t.Key('timestamp', t.num),
256+
]);
258257
const value: any[] = ['v1', 2, {data: 'test1'}, {data: 'test2'}, 12345, 1234567890];
259258
expect(transcode(system, type, value)).toStrictEqual(value);
260259
});
261260

262261
test('can encode nested named tuple', () => {
263262
const system = new ModuleType();
264263
const t = system.t;
265-
const type = system.t.Tuple([
266-
t.Key('metadata', t.Tuple([t.Key('type', t.str), t.Key('size', t.num)])),
267-
], t.str);
264+
const type = system.t.Tuple([t.Key('metadata', t.Tuple([t.Key('type', t.str), t.Key('size', t.num)]))], t.str);
268265
const value: any[] = [['document', 1024], 'content1', 'content2'];
269266
expect(transcode(system, type, value)).toStrictEqual(value);
270267
});

src/codegen/binary/json/JsonCodegen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ export class JsonCodegen extends AbstractBinaryCodegen<JsonEncoder> {
157157
};
158158
const emitEnding = () => {
159159
const rewriteLastSeparator = () => {
160-
for (let i = 0; i < endBlob.length; i++) codegen.js(/* js */ `uint8[writer.x - ${endBlob.length - i}] = ${endBlob[i]};`);
160+
for (let i = 0; i < endBlob.length; i++)
161+
codegen.js(/* js */ `uint8[writer.x - ${endBlob.length - i}] = ${endBlob[i]};`);
161162
};
162163
if (requiredFields.length) {
163164
rewriteLastSeparator();

src/codegen/binary/json/__tests__/JsonCodegen.spec.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,26 @@ test('fuzzer 1: map in map', () => {
3434
'T`jb_LZ': null,
3535
'C)crlQL': null,
3636
'kw&p(^-': null,
37-
'oKkF,u8': null
38-
}
37+
'oKkF,u8': null,
38+
},
3939
};
4040
const value2 = {
4141
'YS9mc}Zb': {
4242
'V2*_9': null,
4343
'j9?_0': null,
4444
'@:ODe': null,
4545
'sS{Sx': null,
46-
'4EMz|': null
46+
'4EMz|': null,
4747
},
4848
"bF@64u'7": {
4949
'q<_b%}$Q': null,
50-
'RäXpXBLü': null,
50+
RäXpXBLü: null,
5151
'$uJx]{ft': null,
5252
'bX%jLhr{': null,
5353
'Lr1bY-fY': null,
5454
'D]ml,C)W': null,
5555
'eK=DszFO': null,
56-
'!RqC^GUz': null
56+
'!RqC^GUz': null,
5757
},
5858
'9SEDa*#|': {
5959
';COK{m%=': null,
@@ -63,35 +63,35 @@ test('fuzzer 1: map in map', () => {
6363
'k+$es!mO': null,
6464
'O1(&D_bt': null,
6565
'cidA#*BD': null,
66-
'!ZP5JBFq': null
66+
'!ZP5JBFq': null,
6767
},
6868
';6(7#5m:': {},
6969
'zhGX^&Y3': {
7070
'1Z>iC': null,
7171
'%вqL=': null,
7272
'5?5{)': null,
7373
'*2"H4': null,
74-
')&_O4': null
74+
')&_O4': null,
7575
},
7676
'?6a1a5Y\\': {
7777
'5,bCV': null,
7878
'z[x2s': null,
7979
'Ad/g9': null,
8080
'at#84': null,
81-
'{@?".': null
81+
'{@?".': null,
8282
},
83-
'uaaAwаHb': { VXy: null, 'I(<': null, 'W V': null },
83+
uaaAwаHb: {VXy: null, 'I(<': null, 'W V': null},
8484
'&sH?Bk2E': {
8585
'M[^ex': null,
8686
'-ZP$E': null,
8787
'c*@uR': null,
8888
'`sy3N': null,
89-
'g?DB ': null
90-
}
89+
'g?DB ': null,
90+
},
9191
};
9292
const value3 = {
93-
'/7': { '|;L': null, '@K<': null, '*x:': null },
94-
Zf: { N1: null, 't%': null }
93+
'/7': {'|;L': null, '@K<': null, '*x:': null},
94+
Zf: {N1: null, 't%': null},
9595
};
9696
for (let i = 0; i < 100; i++) {
9797
const decoded = transcode(system, type, value);

src/codegen/binary/msgpack/__tests__/automated.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {MsgPackCodegen} from '../MsgPackCodegen';
44
import {Random} from '../../../../random';
55
import {allSerializableTypes} from '../../../../__tests__/fixtures';
66

7-
const encoder = new MsgPackEncoder();
8-
const decoder = new MsgPackDecoder();
7+
const encoder = new MsgPackEncoder();
8+
const decoder = new MsgPackDecoder();
99

1010
for (const [name, type] of Object.entries(allSerializableTypes)) {
1111
test(`can encode and decode ${name}`, () => {

src/codegen/capacity/CapacityEstimatorCodegen.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,17 @@ export class CapacityEstimatorCodegen extends AbstractCodegen<CompiledCapacityEs
111111
}
112112
if (headLength > 0) {
113113
const rr = codegen.var(r.use());
114-
for (let i = 0; i < headLength; i++) this.onNode([...path, i], new JsExpression(() => /* js */ `${rr}[${i}]`), _head![i]);
114+
for (let i = 0; i < headLength; i++)
115+
this.onNode([...path, i], new JsExpression(() => /* js */ `${rr}[${i}]`), _head![i]);
115116
}
116117
if (tailLength > 0) {
117118
const rr = codegen.var(r.use());
118119
for (let i = 0; i < tailLength; i++)
119-
this.onNode([...path, {r: `${rLen} - ${(tailLength - i)}`}], new JsExpression(() => /* js */ `${rr}[${rLen} - ${(tailLength - i)}]`), _tail![i]);
120+
this.onNode(
121+
[...path, {r: `${rLen} - ${tailLength - i}`}],
122+
new JsExpression(() => /* js */ `${rr}[${rLen} - ${tailLength - i}]`),
123+
_tail![i],
124+
);
120125
}
121126
}
122127

src/codegen/capacity/__tests__/CapacityEstimatorCodegenContext.spec.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,20 @@ describe('"arr" type', () => {
163163
const system = new ModuleType();
164164
const type = system.t.Tuple([t.Const('start')], t.str).tail(t.Const('end'));
165165
const estimator = CapacityEstimatorCodegen.get(type);
166-
expect(estimator(['start', 'middle1', 'middle2', 'end'])).toBe(maxEncodingCapacity(['start', 'middle1', 'middle2', 'end']));
166+
expect(estimator(['start', 'middle1', 'middle2', 'end'])).toBe(
167+
maxEncodingCapacity(['start', 'middle1', 'middle2', 'end']),
168+
);
167169
});
168170

169171
test('complex named tail tuple', () => {
170172
const system = new ModuleType();
171-
const type = system.t.Array(t.num).tail(
172-
t.Key('status', t.str),
173-
t.Key('timestamp', t.num),
174-
t.Key('metadata', t.bool)
175-
);
173+
const type = system.t
174+
.Array(t.num)
175+
.tail(t.Key('status', t.str), t.Key('timestamp', t.num), t.Key('metadata', t.bool));
176176
const estimator = CapacityEstimatorCodegen.get(type);
177-
expect(estimator([1, 2, 3, 'success', 1234567890, true])).toBe(maxEncodingCapacity([1, 2, 3, 'success', 1234567890, true]));
177+
expect(estimator([1, 2, 3, 'success', 1234567890, true])).toBe(
178+
maxEncodingCapacity([1, 2, 3, 'success', 1234567890, true]),
179+
);
178180
});
179181

180182
test('empty array with head/tail definition', () => {
@@ -186,35 +188,32 @@ describe('"arr" type', () => {
186188

187189
test('head tuple with different types', () => {
188190
const system = new ModuleType();
189-
const type = system.t.Tuple([
190-
t.Key('id', t.num),
191-
t.Key('name', t.str),
192-
t.Key('active', t.bool)
193-
], t.str);
191+
const type = system.t.Tuple([t.Key('id', t.num), t.Key('name', t.str), t.Key('active', t.bool)], t.str);
194192
const estimator = CapacityEstimatorCodegen.get(type);
195-
expect(estimator([42, 'test', true, 'extra1', 'extra2'])).toBe(maxEncodingCapacity([42, 'test', true, 'extra1', 'extra2']));
193+
expect(estimator([42, 'test', true, 'extra1', 'extra2'])).toBe(
194+
maxEncodingCapacity([42, 'test', true, 'extra1', 'extra2']),
195+
);
196196
});
197197

198198
test('tail tuple with different types', () => {
199199
const system = new ModuleType();
200-
const type = system.t.Array(t.str).tail(
201-
t.Key('count', t.num),
202-
t.Key('valid', t.bool)
203-
);
200+
const type = system.t.Array(t.str).tail(t.Key('count', t.num), t.Key('valid', t.bool));
204201
const estimator = CapacityEstimatorCodegen.get(type);
205-
expect(estimator(['item1', 'item2', 'item3', 5, true])).toBe(maxEncodingCapacity(['item1', 'item2', 'item3', 5, true]));
202+
expect(estimator(['item1', 'item2', 'item3', 5, true])).toBe(
203+
maxEncodingCapacity(['item1', 'item2', 'item3', 5, true]),
204+
);
206205
});
207206

208207
test('nested objects in named tuples', () => {
209208
const system = new ModuleType();
210-
const type = system.t.Array(t.Object(t.Key('value', t.num))).tail(
211-
t.Key('summary', t.Object(t.Key('total', t.num), t.Key('average', t.num)))
212-
);
209+
const type = system.t
210+
.Array(t.Object(t.Key('value', t.num)))
211+
.tail(t.Key('summary', t.Object(t.Key('total', t.num), t.Key('average', t.num))));
213212
const estimator = CapacityEstimatorCodegen.get(type);
214213
const data = [
215214
{value: 10},
216215
{value: 20},
217-
{total: 30, average: 15} // summary
216+
{total: 30, average: 15}, // summary
218217
];
219218
expect(estimator(data)).toBe(maxEncodingCapacity(data));
220219
});

src/codegen/validator/ValidatorCodegen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
type RefType,
1818
type StrType,
1919
type Type,
20-
KeyType,
20+
type KeyType,
2121
} from '../../type';
2222
import {floats, ints, uints} from '../../util';
2323
import {isAscii, isUtf8} from '../../util/stringFormats';

src/schema/schema.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,17 @@ export type JsonSchema =
453453
| OptKeySchema
454454
| MapSchema;
455455

456-
export type Schema = JsonSchema | RefSchema | OrSchema | AnySchema | FnSchema | FnRxSchema | AliasSchema | ModuleSchema | KeySchema | OptKeySchema;
456+
export type Schema =
457+
| JsonSchema
458+
| RefSchema
459+
| OrSchema
460+
| AnySchema
461+
| FnSchema
462+
| FnRxSchema
463+
| AliasSchema
464+
| ModuleSchema
465+
| KeySchema
466+
| OptKeySchema;
457467

458468
export type NoT<T extends SchemaBase> = Omit<T, 'kind'>;
459469

0 commit comments

Comments
 (0)