diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-04-21 16:40:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-21 16:40:10 -0400 |
commit | 9dfebbc9496138efbeedc431068f41662c780f3e (patch) | |
tree | c3718c3dc132d11c08c8fc18933daebf886bf787 /js/console.ts | |
parent | 6cded14bdf313762956d4d5361cfe8115628b535 (diff) |
Fix eslint warnings (#2151)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Co-authored-by: LE GOFF Vincent <g_n_s@hotmail.fr>
Diffstat (limited to 'js/console.ts')
-rw-r--r-- | js/console.ts | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/js/console.ts b/js/console.ts index c16ea0302..b2f7e7cbb 100644 --- a/js/console.ts +++ b/js/console.ts @@ -171,7 +171,7 @@ function createArrayString( typeName: "Array", displayName: "", delims: ["[", "]"], - entryHandler: (el, ctx, level, maxLevel) => + entryHandler: (el, ctx, level, maxLevel): string => stringifyWithQuotes(el, ctx, level + 1, maxLevel) }; return createIterableString(value, ctx, level, maxLevel, printConfig); @@ -188,7 +188,7 @@ function createTypedArrayString( typeName: typedArrayName, displayName: typedArrayName, delims: ["[", "]"], - entryHandler: (el, ctx, level, maxLevel) => + entryHandler: (el, ctx, level, maxLevel): string => stringifyWithQuotes(el, ctx, level + 1, maxLevel) }; return createIterableString(value, ctx, level, maxLevel, printConfig); @@ -204,7 +204,7 @@ function createSetString( typeName: "Set", displayName: "Set", delims: ["{", "}"], - entryHandler: (el, ctx, level, maxLevel) => + entryHandler: (el, ctx, level, maxLevel): string => stringifyWithQuotes(el, ctx, level + 1, maxLevel) }; return createIterableString(value, ctx, level, maxLevel, printConfig); @@ -220,7 +220,7 @@ function createMapString( typeName: "Map", displayName: "Map", delims: ["{", "}"], - entryHandler: (el, ctx, level, maxLevel) => { + entryHandler: (el, ctx, level, maxLevel): string => { const [key, val] = el; return `${stringifyWithQuotes( key, @@ -288,18 +288,20 @@ function createRawObjectString( shouldShowClassName = true; } const keys = Object.keys(value); - const entries: string[] = keys.map(key => { - if (keys.length > OBJ_ABBREVIATE_SIZE) { - return key; - } else { - return `${key}: ${stringifyWithQuotes( - value[key], - ctx, - level + 1, - maxLevel - )}`; + const entries: string[] = keys.map( + (key): string => { + if (keys.length > OBJ_ABBREVIATE_SIZE) { + return key; + } else { + return `${key}: ${stringifyWithQuotes( + value[key], + ctx, + level + 1, + maxLevel + )}`; + } } - }); + ); ctx.delete(value); @@ -514,7 +516,7 @@ export class Console { info = this.log; /** Writes the properties of the supplied `obj` to stdout */ - dir = (obj: unknown, options: ConsoleOptions = {}) => { + dir = (obj: unknown, options: ConsoleOptions = {}): void => { this.log(stringifyArgs([obj], options)); }; @@ -601,7 +603,7 @@ export class Console { const toTable = (header: string[], body: string[][]): void => this.log(cliTable(header, body)); const createColumn = (value: unknown, shift?: number): string[] => [ - ...(shift ? [...new Array(shift)].map(() => "") : []), + ...(shift ? [...new Array(shift)].map((): string => "") : []), stringifyValue(value) ]; @@ -617,39 +619,43 @@ export class Console { let idx = 0; resultData = {}; - data.forEach((v: unknown, k: unknown) => { - resultData[idx] = { Key: k, Values: v }; - idx++; - }); + data.forEach( + (v: unknown, k: unknown): void => { + resultData[idx] = { Key: k, Values: v }; + idx++; + } + ); } else { resultData = data!; } - Object.keys(resultData).forEach((k, idx) => { - const value: unknown = resultData[k]!; + Object.keys(resultData).forEach( + (k, idx): void => { + const value: unknown = resultData[k]!; - if (value !== null && typeof value === "object") { - Object.entries(value as { [key: string]: unknown }).forEach( - ([k, v]) => { - if (properties && !properties.includes(k)) { - return; - } + if (value !== null && typeof value === "object") { + Object.entries(value as { [key: string]: unknown }).forEach( + ([k, v]): void => { + if (properties && !properties.includes(k)) { + return; + } - if (objectValues[k]) { - objectValues[k].push(stringifyValue(v)); - } else { - objectValues[k] = createColumn(v, idx); + if (objectValues[k]) { + objectValues[k].push(stringifyValue(v)); + } else { + objectValues[k] = createColumn(v, idx); + } } - } - ); + ); - values.push(""); - } else { - values.push(stringifyValue(value)); - } + values.push(""); + } else { + values.push(stringifyValue(value)); + } - indexKeys.push(k); - }); + indexKeys.push(k); + } + ); const headerKeys = Object.keys(objectValues); const bodyValues = Object.values(objectValues); |