## Changes Implements suggestions from https://typescript-eslint.io/blog/consistent-type-imports-and-exports-why-and-how/ and https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful, along with a couple more auto-fixable consistency rules. Of note: - Functions that return a promise are marked as async - Suggestions now appear for where to simplify boolean checks, non-nullish assertions, and optional chaining
25 lines
636 B
TypeScript
25 lines
636 B
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unnecessary-condition */
|
|
// cSpell:disable
|
|
/**
|
|
* Object.entriesFrom() polyfill
|
|
* @author Chris Ferdinandi
|
|
* @license MIT
|
|
*/
|
|
|
|
if (!Object.fromEntries) {
|
|
Object.fromEntries = function <T = any>(
|
|
entries: Iterable<readonly [PropertyKey, T]>,
|
|
): { [k: string]: T } {
|
|
if (!entries?.[Symbol.iterator]) {
|
|
throw new Error(
|
|
"Object.fromEntries() requires a single iterable argument",
|
|
);
|
|
}
|
|
const obj: { [k: PropertyKey]: T } = {};
|
|
for (const [key, value] of entries) {
|
|
obj[key] = value;
|
|
}
|
|
return obj;
|
|
};
|
|
}
|