CODEBASE: Expand lint rules, and Aliases are stored as maps (#501)

This commit is contained in:
Snarling
2023-05-05 03:55:59 -04:00
committed by GitHub
parent d25254caf1
commit ebae35b1fb
202 changed files with 905 additions and 1110 deletions
+27
View File
@@ -0,0 +1,27 @@
import { Truthy } from "lodash";
/**
* Returns the input array as a comma separated string.
*
* Does several things that Array.toString() doesn't do
* - Adds brackets around the array
* - Adds quotation marks around strings
*/
export function arrayToString(a: unknown[]): string {
const vals: unknown[] = [];
for (let i = 0; i < a.length; ++i) {
let elem: unknown = a[i];
if (Array.isArray(elem)) {
elem = arrayToString(elem);
} else if (typeof elem === "string") {
elem = `"${elem}"`;
}
vals.push(elem);
}
return `[${vals.join(", ")}]`;
}
export function FilterTruthy<T>(input: T[]): Truthy<T>[] {
return input.filter(Boolean) as Truthy<T>[];
}