From 719f109a0ef8a1a85356282c3650af1cedbbb268 Mon Sep 17 00:00:00 2001 From: roboin <50550561+Robot-Inventor@users.noreply.github.com> Date: Thu, 7 Nov 2024 23:58:42 +0900 Subject: [PATCH] chore: add `./script/**/*.ts` to ESLint targets (#227) --- package.json | 2 +- script/addUserScriptComment.ts | 4 ++-- script/copyManifest.ts | 8 +++++--- script/package.ts | 4 ++++ tsconfig.json | 3 ++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 09ea8d1..82c192f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "watch": "cross-env NODE_OPTIONS=--experimental-transform-types NODE_ENV=development rspack build --watch", "format": "prettier --write ./src/**/*", "format:check": "prettier --check ./src/**/*", - "lint": "eslint ./src/**/*.ts ./rspack.config.ts", + "lint": "eslint ./src/**/*.ts ./rspack.config.ts ./script/**/*.ts", "package": "tsx ./script/package.ts", "version": "npm run build && git add ." }, diff --git a/script/addUserScriptComment.ts b/script/addUserScriptComment.ts index 1e260d8..d6216f4 100644 --- a/script/addUserScriptComment.ts +++ b/script/addUserScriptComment.ts @@ -2,7 +2,7 @@ import fs from "fs"; import packageJson from "../package.json"; const userScript = fs.readFileSync("./index.user.js", "utf8"); -const user_script_metadata = `// ==UserScript== +const userScriptMetadata = `// ==UserScript== // @name Hide View Count // @namespace https://github.com/Robot-Inventor/hide-view-count // @version ${packageJson.version} @@ -20,5 +20,5 @@ const user_script_metadata = `// ==UserScript== // @grant none // ==/UserScript== `; -const userScriptEdited = user_script_metadata + userScript; +const userScriptEdited = userScriptMetadata + userScript; fs.writeFileSync("./index.user.js", userScriptEdited); diff --git a/script/copyManifest.ts b/script/copyManifest.ts index 0b83194..452709f 100644 --- a/script/copyManifest.ts +++ b/script/copyManifest.ts @@ -1,13 +1,15 @@ +import fs from "fs"; import manifestV2 from "../src/manifest/v2.json"; import manifestV3 from "../src/manifest/v3.json"; import packageJson from "../package.json"; -import fs from "fs"; + +const JSON_INDENT = 4; manifestV2.version = packageJson.version; manifestV3.version = packageJson.version; -const manifestV2Text = JSON.stringify(manifestV2, null, 4); -const manifestV3Text = JSON.stringify(manifestV3, null, 4); +const manifestV2Text = JSON.stringify(manifestV2, null, JSON_INDENT); +const manifestV3Text = JSON.stringify(manifestV3, null, JSON_INDENT); fs.writeFileSync("./dist/firefox/manifest.json", manifestV2Text); fs.writeFileSync("./dist/chrome/manifest.json", manifestV3Text); diff --git a/script/package.ts b/script/package.ts index ea2cbaf..0a52fce 100644 --- a/script/package.ts +++ b/script/package.ts @@ -1,15 +1,19 @@ import { execSync } from "child_process"; +// eslint-disable-next-line no-console console.log("Building..."); execSync("npm run build"); +// eslint-disable-next-line no-console console.log("Packaging for Chrome..."); execSync( `npx web-ext build --source-dir "./dist/chrome/" --artifacts-dir "./web-ext-artifacts/manifestV3" --filename "{name}-{version}-manifestV3.zip"` ); +// eslint-disable-next-line no-console console.log("Packaging for Firefox..."); execSync( `npx web-ext build --source-dir "./dist/firefox/" --artifacts-dir "./web-ext-artifacts/manifestV2" --filename "{name}-{version}-manifestV2.zip"` ); +// eslint-disable-next-line no-console console.log("Done."); diff --git a/tsconfig.json b/tsconfig.json index ffc2b17..845027d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ }, "include": [ "./src/**/*.ts", - "./rspack.config.ts" + "./rspack.config.ts", + "./script/**/*.ts" ] } \ No newline at end of file