Skip to content

Commit ba891cb

Browse files
committed
build: fix lint errors
1 parent 7a428ea commit ba891cb

File tree

2 files changed

+104
-49
lines changed

2 files changed

+104
-49
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"scripts": {
1212
"clean": "pnpm -r -F !. run clean && rm -rf node_modules",
1313
"fix": "prettier --write 'packages/**/{src,test}/**/*.{ts,tsx}' && pnpm run lint --fix",
14-
"lint": "eslint 'packages/**/{src,test}/**/*.{ts,tsx}'",
14+
"lint": "eslint --no-error-on-unmatched-pattern 'packages/**/{src,test}/**/*.{ts,tsx}'",
1515
"test": "pnpm -r run test run --coverage"
1616
},
1717
"devDependencies": {

packages/avsc/types/index.d.ts

Lines changed: 103 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,34 @@
88

99
import * as stream from 'stream';
1010

11-
//"virtual" namespace (no JS, just types) for Avro Schema
11+
// "virtual" namespace (no JS, just types) for Avro Schema
1212
declare namespace schema {
1313
export type AvroSchema = DefinedType | DefinedType[];
1414
type DefinedType = PrimitiveType | ComplexType | LogicalType | Type | string;
15-
type PrimitiveType = 'null' | 'boolean' | 'int' | 'long' | 'float' | 'double' | 'bytes' | 'string';
16-
type ComplexType = NamedType | RecordType | EnumType | MapType | ArrayType | FixedType;
15+
type PrimitiveType =
16+
| 'null'
17+
| 'boolean'
18+
| 'int'
19+
| 'long'
20+
| 'float'
21+
| 'double'
22+
| 'bytes'
23+
| 'string';
24+
type ComplexType =
25+
| NamedType
26+
| RecordType
27+
| EnumType
28+
| MapType
29+
| ArrayType
30+
| FixedType;
1731
type LogicalType = ComplexType & LogicalTypeExtension;
1832

1933
interface NamedType {
20-
type: PrimitiveType
34+
type: PrimitiveType;
2135
}
2236

2337
interface RecordType {
24-
type: "record" | "error";
38+
type: 'record' | 'error';
2539
name: string;
2640
namespace?: string;
2741
doc?: string;
@@ -31,12 +45,12 @@ declare namespace schema {
3145
doc?: string;
3246
type: Schema;
3347
default?: any;
34-
order?: "ascending" | "descending" | "ignore";
48+
order?: 'ascending' | 'descending' | 'ignore';
3549
}[];
3650
}
3751

3852
interface EnumType {
39-
type: "enum";
53+
type: 'enum';
4054
name: string;
4155
namespace?: string;
4256
aliases?: string[];
@@ -46,17 +60,17 @@ declare namespace schema {
4660
}
4761

4862
interface ArrayType {
49-
type: "array";
63+
type: 'array';
5064
items: Schema;
5165
}
5266

5367
interface MapType {
54-
type: "map";
68+
type: 'map';
5569
values: Schema;
5670
}
5771

5872
interface FixedType {
59-
type: "fixed";
73+
type: 'fixed';
6074
name: string;
6175
aliases?: string[];
6276
size: number;
@@ -73,7 +87,6 @@ type Schema = schema.AvroSchema;
7387

7488
type Callback<V, Err = any> = (err: Err | null, value?: V) => void;
7589

76-
7790
type Codec = (buffer: Uint8Array, callback: Callback<Uint8Array>) => void;
7891

7992
interface CodecOptions {
@@ -84,7 +97,7 @@ interface DecoderOptions {
8497
noDecode: boolean;
8598
readerSchema: string | object | Type;
8699
codecs: CodecOptions;
87-
parseHook: (schema: Schema) => Type
100+
parseHook: (schema: Schema) => Type;
88101
}
89102

90103
interface EncoderOptions {
@@ -97,27 +110,32 @@ interface EncoderOptions {
97110

98111
/**
99112
* A projection function that is used when unwrapping unions.
100-
* This function is called at schema parsing time on each union with its branches'
101-
* types.
113+
* This function is called at schema parsing time on each union with its
114+
* branches' types.
102115
* If it returns a non-null (function) value, that function will be called each
103116
* time a value's branch needs to be inferred and should return the branch's
104117
* index.
105118
* The index muss be a number between 0 and length-1 of the passed types.
106119
* In this case (a branch index) the union will use an unwrapped representation.
107120
* Otherwise (undefined), the union will be wrapped.
108121
*/
109-
type BranchProjection = (types: ReadonlyArray<Type>) =>
110-
| ((val: unknown) => number)
111-
| undefined;
122+
type BranchProjection = (
123+
types: ReadonlyArray<Type>
124+
) => ((val: unknown) => number) | undefined;
112125

113126
interface ForSchemaOptions {
114127
assertLogicalTypes: boolean;
115-
logicalTypes: { [type: string]: new (schema: Schema, opts?: any) => types.LogicalType; };
128+
logicalTypes: {
129+
[type: string]: new (schema: Schema, opts?: any) => types.LogicalType;
130+
};
116131
namespace: string;
117132
noAnonymousTypes: boolean;
118133
omitRecordMethods: boolean;
119-
registry: { [name: string]: Type };
120-
typeHook: (schema: Schema | string, opts: ForSchemaOptions) => Type | undefined;
134+
registry: {[name: string]: Type};
135+
typeHook: (
136+
schema: Schema | string,
137+
opts: ForSchemaOptions
138+
) => Type | undefined;
121139
wrapUnions: BranchProjection | boolean | 'auto' | 'always' | 'never';
122140
}
123141

@@ -139,15 +157,18 @@ interface CloneOptions {
139157
}
140158
interface IsValidOptions {
141159
noUndeclaredFields: boolean;
142-
errorHook: (path: string[], val: any, type: Type) => void
160+
errorHook: (path: string[], val: any, type: Type) => void;
143161
}
144162

145163
interface ImportHookPayload {
146164
path: string;
147165
type: 'idl' | 'protocol' | 'schema';
148166
}
149167

150-
type ImportHookCallback = (err: any, params?: {contents: string, path: string}) => void;
168+
type ImportHookCallback = (
169+
err: any,
170+
params?: {contents: string; path: string}
171+
) => void;
151172

152173
type ImportHook = (payload: ImportHookPayload, cb: ImportHookCallback) => void;
153174

@@ -160,31 +181,61 @@ interface SchemaOptions {
160181
noDeref: boolean;
161182
}
162183

163-
declare class Resolver {
164-
//no public methods
165-
}
184+
interface Resolver {}
166185

167186
//exported functions
168187

169-
export function assembleProtocol(filePath: string, opts: Partial<AssembleOptions>, callback: Callback<object>): void;
170-
export function assembleProtocol(filePath: string, callback: Callback<object>): void;
171-
export function createFileDecoder(fileName: string, opts?: Partial<DecoderOptions>): streams.BlockDecoder;
172-
export function createFileEncoder(filePath: string, schema: Schema, opts?: Partial<EncoderOptions>): streams.BlockEncoder;
173-
export function createBlobEncoder(schema: Schema, opts?: Partial<EncoderOptions>): stream.Duplex;
174-
export function createBlobDecoder(blob: Blob, opts?: Partial<DecoderOptions>): streams.BlockDecoder;
188+
export function assembleProtocol(
189+
filePath: string,
190+
opts: Partial<AssembleOptions>,
191+
callback: Callback<object>
192+
): void;
193+
export function assembleProtocol(
194+
filePath: string,
195+
callback: Callback<object>
196+
): void;
197+
export function createFileDecoder(
198+
fileName: string,
199+
opts?: Partial<DecoderOptions>
200+
): streams.BlockDecoder;
201+
export function createFileEncoder(
202+
filePath: string,
203+
schema: Schema,
204+
opts?: Partial<EncoderOptions>
205+
): streams.BlockEncoder;
206+
export function createBlobEncoder(
207+
schema: Schema,
208+
opts?: Partial<EncoderOptions>
209+
): stream.Duplex;
210+
export function createBlobDecoder(
211+
blob: Blob,
212+
opts?: Partial<DecoderOptions>
213+
): streams.BlockDecoder;
175214
export function extractFileHeader(filePath: string, options?: any): any;
176215
export function parse(schemaOrProtocolIdl: string, options?: any): any; // TODO protocol literal or Type
177-
export function readProtocol(protocolIdl: string, options?: Partial<DecoderOptions>): any;
178-
export function readSchema(schemaIdl: string, options?: Partial<DecoderOptions>): Schema;
179-
216+
export function readProtocol(
217+
protocolIdl: string,
218+
options?: Partial<DecoderOptions>
219+
): any;
220+
export function readSchema(
221+
schemaIdl: string,
222+
options?: Partial<DecoderOptions>
223+
): Schema;
180224

181225
// TODO more specific types than `any`
182226
export class Type {
183227
clone(val: any, opts?: Partial<CloneOptions>): any;
184228
compare(val1: any, val2: any): number;
185229
compareBuffers(buf1: Uint8Array, buf2: Uint8Array): number;
186230
createResolver(type: Type): Resolver;
187-
decode(buf: Uint8Array, pos?: number, resolver?: Resolver): { value: any, offset: number};
231+
decode(
232+
buf: Uint8Array,
233+
pos?: number,
234+
resolver?: Resolver
235+
): {
236+
value: any;
237+
offset: number;
238+
};
188239
encode(val: any, buf: Uint8Array, pos?: number): number;
189240
equals(type: Type): boolean;
190241
fingerprint(algorithm?: string): Uint8Array;
@@ -209,16 +260,15 @@ export class Type {
209260
static isType(arg: any, ...prefix: string[]): boolean;
210261
}
211262

212-
213263
export namespace streams {
214-
215264
class BlockDecoder extends stream.Duplex {
216265
constructor(opts?: Partial<DecoderOptions>);
217266
static defaultCodecs(): CodecOptions;
218267

219-
//should add meta-data listener, but regrettably that requires all other events to be repeated
220-
//here, or else they won't show up in code-completion. To avoid clutter, the meta-data event
221-
//is therefore omitted from this stream.
268+
// Should add meta-data listener, but regrettably that requires all other
269+
// events to be repeated here, or else they won't show up in
270+
// code-completion. To avoid clutter, the meta-data event is therefore
271+
// omitted from this stream.
222272
}
223273

224274
class BlockEncoder extends stream.Duplex {
@@ -227,11 +277,11 @@ export namespace streams {
227277
}
228278

229279
class RawDecoder extends stream.Duplex {
230-
constructor(schema: Schema, opts?: { decode?: boolean });
280+
constructor(schema: Schema, opts?: {decode?: boolean});
231281
}
232282

233283
class RawEncoder extends stream.Duplex {
234-
constructor(schema: Schema, opts?: { batchSize?: number });
284+
constructor(schema: Schema, opts?: {batchSize?: number});
235285
}
236286
}
237287

@@ -242,17 +292,20 @@ export namespace types {
242292
random(): unknown[];
243293
}
244294

245-
class BooleanType extends Type { // TODO: Document this on the wiki
295+
class BooleanType extends Type {
296+
// TODO: Document this on the wiki
246297
constructor();
247298
random(): boolean;
248299
}
249300

250-
class BytesType extends Type { // TODO: Document this on the wiki
301+
class BytesType extends Type {
302+
// TODO: Document this on the wiki
251303
constructor();
252304
random(): Uint8Array;
253305
}
254306

255-
class DoubleType extends Type { // TODO: Document this on the wiki
307+
class DoubleType extends Type {
308+
// TODO: Document this on the wiki
256309
constructor();
257310
random(): number;
258311
}
@@ -301,15 +354,16 @@ export namespace types {
301354
random(): Record<string, unknown>;
302355
}
303356

304-
class NullType extends Type { // TODO: Document this on the wiki
357+
class NullType extends Type {
358+
// TODO: Document this on the wiki
305359
constructor();
306360
random(): null;
307361
}
308362

309363
class RecordType extends Type {
310364
constructor(schema: Schema, opts?: any);
311365
readonly fields: Field[];
312-
readonly recordConstructor: any; // TODO: typeof Record once Record interface/class exists
366+
readonly recordConstructor: any; // TODO: typeof Record once Record interface/class exists
313367
field(name: string): Field;
314368
random(): object;
315369
}
@@ -322,7 +376,8 @@ export namespace types {
322376
type: Type;
323377
}
324378

325-
class StringType extends Type { // TODO: Document this on the wiki
379+
class StringType extends Type {
380+
// TODO: Document this on the wiki
326381
constructor();
327382
random(): string;
328383
}

0 commit comments

Comments
 (0)