From ed17eaf539602830182ce9326a9eeb93474532fd Mon Sep 17 00:00:00 2001 From: haykam821 <24855774+haykam821@users.noreply.github.com> Date: Mon, 6 Mar 2023 20:21:08 -0500 Subject: [PATCH] Update eslint-config-haykam to version 1.19.0 --- package.json | 17 +++++------------ src/start.ts | 14 ++++++++------ src/util/dump-scripts.ts | 2 +- src/util/get-hash-objects.ts | 2 +- src/util/get-hashes.ts | 30 ++++++++++++++++-------------- 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index 9711f43..f4baaa6 100644 --- a/package.json +++ b/package.json @@ -21,20 +21,13 @@ "@types/estree": "^0.0.46", "@types/fs-extra": "^9.0.8", "@types/js-beautify": "^1.13.1", - "@types/node": "^13.9.3", + "@types/node": "^18.14.6", "@types/puppeteer": "^5.4.3", "@types/string-format": "^2.0.0", - "@typescript-eslint/eslint-plugin": "^4.18.0", - "@typescript-eslint/parser": "^4.18.0", - "eslint": "^7.21.0", - "eslint-config-haykam": "^1.10.0", - "eslint-plugin-extra-rules": "^0.0.0-development", - "eslint-plugin-html": "^6.1.1", - "eslint-plugin-jsdoc": "^32.2.0", - "eslint-plugin-json": "^2.1.2", - "eslint-plugin-markdown": "^2.0.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-unicorn": "^28.0.2", + "@typescript-eslint/eslint-plugin": "^5.54.1", + "@typescript-eslint/parser": "^5.54.1", + "eslint": "^8.35.0", + "eslint-config-haykam": "^1.19.0", "ts-node-dev": "^1.1.6", "typescript": "^4.2.3" }, diff --git a/src/start.ts b/src/start.ts index 06efa0a..fda58e3 100644 --- a/src/start.ts +++ b/src/start.ts @@ -80,12 +80,14 @@ export default async function start(args: RedditDataminerOptions): Promise { - hashesLog("saved new hashes to %s", args.hashes); - return written; - }).catch(() => { - hashesLog("failed to save new hashes"); - }); + await fse.writeJSON(args.hashes, hashes) + .then(written => { + hashesLog("saved new hashes to %s", args.hashes); + return written; + }) + .catch(() => { + hashesLog("failed to save new hashes"); + }); } // Clean up diff --git a/src/util/dump-scripts.ts b/src/util/dump-scripts.ts index ee8955f..546ff29 100644 --- a/src/util/dump-scripts.ts +++ b/src/util/dump-scripts.ts @@ -4,7 +4,7 @@ import { filter } from "./filter"; import format from "string-format"; import fse from "fs-extra"; import { dumping as log } from "./log"; -import path from "path"; +import path from "node:path"; import { uaGot } from "./got"; /** diff --git a/src/util/get-hash-objects.ts b/src/util/get-hash-objects.ts index a91b7fb..5e8854c 100644 --- a/src/util/get-hash-objects.ts +++ b/src/util/get-hash-objects.ts @@ -58,7 +58,7 @@ export default function getHashObjects(program: string, beforeJs = false): Recor objects.push(convertObjectExpressionToObject(node)); } else if (beforeJs && isJsLiteral(node) && objects.length > 0) { return [ - objects[objects.length - 1], + objects.at(-1), ]; } } diff --git a/src/util/get-hashes.ts b/src/util/get-hashes.ts index 8e1bbc6..eec2fe2 100644 --- a/src/util/get-hashes.ts +++ b/src/util/get-hashes.ts @@ -7,19 +7,21 @@ import { hashes as hashesLog } from "./log"; * @returns The loaded hashes for previously-saved scripts. */ export default function getHashes(path: string): Promise> { - return fse.readJSON(path).then(json => { - hashesLog("loaded hashes from %s", path); - return json; - }).catch(async error => { - if (path) { - if (error.code === "ENOENT") { - await fse.writeJSON(path, {}); - hashesLog("created hashes"); - return {}; - } + return fse.readJSON(path) + .then(json => { + hashesLog("loaded hashes from %s", path); + return json; + }) + .catch(async error => { + if (path) { + if (error.code === "ENOENT") { + await fse.writeJSON(path, {}); + hashesLog("created hashes"); + return {}; + } - hashesLog("failed to load hashes"); - } - return {}; - }); + hashesLog("failed to load hashes"); + } + return {}; + }); }