Skip to content

chore: address linter failures on master branch #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 3 additions & 48 deletions src/decimal128.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,14 @@ const MAX_DIGITS = 34;

// Nan value bits as 32 bit values (due to lack of longs)
const NAN_BUFFER = [
0x7c,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00
0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
].reverse();
// Infinity value bits 32 bit values (due to lack of longs)
const INF_NEGATIVE_BUFFER = [
0xf8,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
].reverse();
const INF_POSITIVE_BUFFER = [
0x78,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00
0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
].reverse();

const EXPONENT_REGEX = /^([-+])?(\d+)?$/;
Expand Down
4 changes: 2 additions & 2 deletions src/long.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ let wasm: LongWASMHelpers | undefined = undefined;
declare const WebAssembly: any;

try {
wasm = (new WebAssembly.Instance(
wasm = new WebAssembly.Instance(
new WebAssembly.Module(
// prettier-ignore
new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])
),
{}
).exports as unknown) as LongWASMHelpers;
).exports as unknown as LongWASMHelpers;
} catch {
// no wasm support
}
Expand Down
4 changes: 2 additions & 2 deletions src/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (Object.prototype.hasOwnProperty.call(bsonGlobal, 'Map')) {
bsonMap = bsonGlobal.Map;
} else {
// We will return a polyfill
bsonMap = (class Map {
bsonMap = class Map {
private _keys: string[];
private _values: Record<string, any>;
constructor(array: [string, any][] = []) {
Expand Down Expand Up @@ -133,7 +133,7 @@ if (Object.prototype.hasOwnProperty.call(bsonGlobal, 'Map')) {
get size() {
return this._keys.length;
}
} as unknown) as MapConstructor;
} as unknown as MapConstructor;
}

export { bsonMap as Map };
8 changes: 5 additions & 3 deletions src/parser/deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,11 @@ function deserializeObject(
if (fieldsAsRaw && fieldsAsRaw[name]) {
arrayOptions = {};
for (const n in options) {
(arrayOptions as {
[key: string]: DeserializeOptions[keyof DeserializeOptions];
})[n] = options[n as keyof DeserializeOptions];
(
arrayOptions as {
[key: string]: DeserializeOptions[keyof DeserializeOptions];
}
)[n] = options[n as keyof DeserializeOptions];
}
arrayOptions['raw'] = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ export function deprecate<T extends Function>(fn: T, message: string): T {
}
return fn.apply(this, args);
}
return (deprecated as unknown) as T;
return deprecated as unknown as T;
}
2 changes: 1 addition & 1 deletion src/regexp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class BSONRegExp {
if (typeof doc.$regex !== 'string') {
// This is for $regex query operators that have extended json values.
if (doc.$regex._bsontype === 'BSONRegExp') {
return (doc as unknown) as BSONRegExp;
return doc as unknown as BSONRegExp;
}
} else {
return new BSONRegExp(doc.$regex, BSONRegExp.parseOptions(doc.$options));
Expand Down
3 changes: 2 additions & 1 deletion src/timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export type LongWithoutOverrides = new (low: number | Long, high?: number, unsig
[P in Exclude<keyof Long, TimestampOverrides>]: Long[P];
};
/** @public */
export const LongWithoutOverridesClass: LongWithoutOverrides = (Long as unknown) as LongWithoutOverrides;
export const LongWithoutOverridesClass: LongWithoutOverrides =
Long as unknown as LongWithoutOverrides;

/** @public */
export interface TimestampExtended {
Expand Down
3 changes: 2 additions & 1 deletion src/uuid_utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Buffer } from 'buffer';

// Validation regex for v4 uuid (validates with or without dashes)
const VALIDATION_REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i;
const VALIDATION_REGEX =
/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i;

export const uuidValidateString = (str: string): boolean =>
typeof str === 'string' && VALIDATION_REGEX.test(str);
Expand Down
Loading