From cbba61b40112b41c43285a1a279969e68df1a2e9 Mon Sep 17 00:00:00 2001 From: MCMXC <16797721+mcmxcdev@users.noreply.github.com> Date: Mon, 15 Apr 2024 07:16:37 -0600 Subject: refactor: project maintenance (#1682) - remove redundant `@adonisjs/auth`, `@adonisjs/session` and `@emotion/react` dependencies - remove `.vscode` folder - clean up some TS and ESLint issues - migrate from deprecated "husky install" to "husky" --- .vscode/extensions.json | 31 ----------- .vscode/launch.json | 87 ------------------------------- .vscode/settings.json | 47 ----------------- .vscode/tasks.json | 18 ------- package.json | 6 +-- pnpm-lock.yaml | 104 +++---------------------------------- src/api/server/ServerApi.ts | 5 +- src/models/Recipe.ts | 16 +++--- src/stores/SettingsStore.ts | 6 ++- src/webview/contextMenuBuilder.ts | 12 ++--- test/helpers/array-helpers.test.ts | 5 +- 11 files changed, 28 insertions(+), 309 deletions(-) delete mode 100644 .vscode/extensions.json delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json delete mode 100644 .vscode/tasks.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 9f26c98d1..000000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "recommendations": [ - "esbenp.prettier-vscode", - "dbaeumer.vscode-eslint", - "codezombiech.gitignore", - "editorconfig.editorconfig", - "steoates.autoimport", - "formulahendry.auto-rename-tag", - "streetsidesoftware.code-spell-checker", - "naumovs.color-highlight", - "mkhl.direnv", - "ms-azuretools.vscode-docker", - "usernamehw.errorlens", - "dsznajder.es7-react-js-snippets", - "mhutchie.git-graph", - "vincaslt.highlight-matching-tag", - "eamodio.gitlens", - "jbockle.jbockle-format-files", - "wix.vscode-import-cost", - "visualstudioexptteam.intellicode-api-usage-examples", - "visualstudioexptteam.vscodeintellicode", - "orta.vscode-jest", - "pkief.material-icon-theme", - "techer.open-in-browser", - "christian-kohler.path-intellisense", - "ofhumanbondage.react-proptypes-intellisense", - "jingkaizhao.vscode-redux-devtools", - "planbcoding.vscode-react-refactor", - "redhat.vscode-yaml" - ] -} diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 24002a53b..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": "PowerShell Launch Current File", - "type": "PowerShell", - "request": "launch", - "script": "${file}", - "cwd": "${workspaceFolder}" - }, - { - "type": "node", - "request": "launch", - "name": "Ferdium - Test API", - "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", - "program": "${workspaceFolder}/build/index.js", - "protocol": "inspector", - "env": { - "NODE_ENV": "development", - "DEBUG": "*,-engine.io*,-socket.io*" - } - }, - { - "type": "node", - "request": "launch", - "name": "Ferdium – Live API", - "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", - "program": "${workspaceFolder}/build/index.js", - "protocol": "inspector", - "env": { - "USE_LIVE_API": "1", - "DEBUG": "*,-engine.io*,-socket.io*" - } - }, - { - "type": "node", - "request": "launch", - "name": "Ferdium – Local API", - "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", - "program": "${workspaceFolder}/build/index.js", - "protocol": "inspector", - "env": { - "USE_LOCAL_API": "1", - "DEBUG": "*,-engine.io*,-socket.io*" - } - }, - { - "type": "node", - "request": "launch", - "name": "(Win Sim) Ferdium - Test API", - "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", - "program": "${workspaceFolder}/build/index.js", - "protocol": "inspector", - "env": { - "NODE_ENV": "development", - "OS_PLATFORM": "win32", - "DEBUG": "*,-engine.io*,-socket.io*" - } - }, - { - "type": "node", - "request": "launch", - "name": "(Win Sim) Ferdium – Live API", - "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", - "program": "${workspaceFolder}/build/index.js", - "protocol": "inspector", - "env": { - "USE_LIVE_API": "1", - "OS_PLATFORM": "win32", - "DEBUG": "*,-engine.io*,-socket.io*" - } - }, - { - "type": "node", - "request": "launch", - "name": "(Win Sim) Ferdium – Local API", - "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", - "program": "${workspaceFolder}/build/index.js", - "protocol": "inspector", - "env": { - "USE_LOCAL_API": "1", - "OS_PLATFORM": "win32", - "DEBUG": "*,-engine.io*,-socket.io*" - } - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 42a06efe9..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "prettier.singleQuote": true, - "js/ts.implicitProjectConfig.experimentalDecorators": true, - "yaml.schemas": { - "https://json.schemastore.org/github-issue-config.json": ".github/ISSUE_TEMPLATE/config.yml" - }, - - // "editor.fontFamily": "Fira Code", - // "editor.fontLigatures": true, - "editor.detectIndentation": false, - "editor.guides.bracketPairs": "active", - "editor.codeActionsOnSave": { - "source.fixAll": "explicit", - "source.fixAll.eslint": "explicit" - }, - - // "explorer.confirmDelete": false, - // "explorer.confirmDragAndDrop": false, - - // "eslint.runtime": "node", - "eslint.format.enable": true, - "eslint.workingDirectories": [{ "mode": "auto" }], - // "eslint.packageManager": "npm", - "eslint.validate": [ - "javascript", - "javascriptreact", - "typescript", - "typescriptreact" - ], - "editor.defaultFormatter": "esbenp.prettier-vscode", - - // "workbench.colorTheme": "Visual Studio Dark", - // "workbench.iconTheme": "material-icon-theme", - - "terminal.integrated.sendKeybindingsToShell": true, - // "terminal.integrated.copyOnSelection": true, - "terminal.integrated.defaultProfile.osx": "zsh", - "terminal.integrated.cursorBlinking": true, - - "git.enableSmartCommit": true, - "diffEditor.ignoreTrimWhitespace": false, - - // "formatFiles.runOrganizeImports": true, - - "javascript.preferences.importModuleSpecifier": "relative", - "typescript.preferences.importModuleSpecifier": "relative" -} diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 1cc1b79e7..000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "type": "pnpm", - "script": "dev", - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "pnpm", - "script": "lint", - "group": "test" - } - ] -} diff --git a/package.json b/package.json index be3f7ade7..3122236ae 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "packageManager": "pnpm@8.15.5", "scripts": { - "prepare": "is-ci || husky install", + "prepare": "is-ci || husky", "start": "electron ./build", "start:local": "cross-env USE_LOCAL_API=1 pnpm start", "start:live": "cross-env USE_LIVE_API=1 pnpm start", @@ -49,10 +49,8 @@ "add-crowdin-contributors": "ts-node scripts/add-crowdin-contributors.ts", "debug": "cross-env-shell DEBUG_COLORS=1 DEBUG=Ferdium:* pnpm start:all-dev" }, - "keywords": [], "dependencies": { "@adonisjs/ace": "5.1.0", - "@adonisjs/auth": "3.2.0", "@adonisjs/bodyparser": "2.3.0", "@adonisjs/cors": "1.0.7", "@adonisjs/drive": "1.0.4", @@ -60,11 +58,9 @@ "@adonisjs/framework": "5.0.13", "@adonisjs/ignitor": "2.0.8", "@adonisjs/lucid": "6.3.0", - "@adonisjs/session": "1.1.0", "@adonisjs/shield": "1.1.0", "@adonisjs/validator": "5.1.0", "@electron/remote": "2.1.2", - "@emotion/react": "11.11.4", "@emotion/styled": "11.11.5", "@mdi/js": "7.4.47", "@mdi/react": "1.6.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 37b15ce36..69f6a5eb0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,6 @@ dependencies: '@adonisjs/ace': specifier: 5.1.0 version: 5.1.0 - '@adonisjs/auth': - specifier: 3.2.0 - version: 3.2.0 '@adonisjs/bodyparser': specifier: 2.3.0 version: 2.3.0 @@ -35,9 +32,6 @@ dependencies: '@adonisjs/lucid': specifier: 6.3.0 version: 6.3.0(sqlite3@5.1.6) - '@adonisjs/session': - specifier: 1.1.0 - version: 1.1.0 '@adonisjs/shield': specifier: 1.1.0 version: 1.1.0 @@ -47,9 +41,6 @@ dependencies: '@electron/remote': specifier: 2.1.2 version: 2.1.2(electron@29.3.0) - '@emotion/react': - specifier: 11.11.4 - version: 11.11.4(@types/react@18.2.77)(react@18.2.0) '@emotion/styled': specifier: 11.11.5 version: 11.11.5(@emotion/react@11.11.4)(@types/react@18.2.77)(react@18.2.0) @@ -478,21 +469,6 @@ packages: - supports-color dev: false - /@adonisjs/auth@3.2.0: - resolution: {integrity: sha512-Bawnpg8BaPrVmG1QhX3egw2SfYOtrOcMpn2q/ck58J9A4WUJAk1LZWXIeu2AF0jrASZuXlmdy4HIMFpl8NKVZg==} - dependencies: - '@adonisjs/generic-exceptions': 2.0.1 - basic-auth: 2.0.1 - debug: 4.3.4(supports-color@5.5.0) - jsonwebtoken: 8.5.1 - lodash: 4.17.21 - ms: 2.1.3 - resetable: 1.0.3 - uuid: 8.3.2 - transitivePeerDependencies: - - supports-color - dev: false - /@adonisjs/bodyparser@2.3.0: resolution: {integrity: sha512-VIC8klEZsz2Zpw1YvqDhtcZS4qut01Mj/fOJCIjZDYIh5yIYgo535aW5NlCQ2bAPs4nzokNIKJUKcnkTAOTZQQ==} dependencies: @@ -618,21 +594,6 @@ packages: - supports-color dev: false - /@adonisjs/session@1.1.0: - resolution: {integrity: sha512-phbTPevvmVcWgq1BXj5VM7MR5+MzXlQgl6Dc0zr8jfftYBscxoiirSaISJYWCwNO6HrPQon54a1/gx9Jr6ebGQ==} - dependencies: - '@adonisjs/generic-exceptions': 2.0.1 - bson: 1.1.6 - debug: 4.3.4(supports-color@5.5.0) - fs-extra: 9.1.0 - lodash: 4.17.21 - ms: 2.1.3 - type-of-is: 3.5.1 - uuid: 8.3.2 - transitivePeerDependencies: - - supports-color - dev: false - /@adonisjs/shield@1.1.0: resolution: {integrity: sha512-3qVwnLTeTk5w0Agi7xuQKj7r7QeA1yFXy0QfpjTIYIzQVy9QTk3DgIK5ZvGtr/2/ESHVosyOrCGr+kQDjtcBhA==} dependencies: @@ -1523,10 +1484,10 @@ packages: resolution: {integrity: sha512-m4HEDZleaaCH+XgDDsPF15Ht6wTLsgDTeR3WYj9Q/k76JtWhrJjcP4+/XlG8LGT/Rol9qUfOIztXeA84ATpqPQ==} dependencies: '@babel/helper-module-imports': 7.22.15 - '@babel/runtime': 7.23.5 + '@babel/runtime': 7.23.9 '@emotion/hash': 0.9.1 '@emotion/memoize': 0.8.1 - '@emotion/serialize': 1.1.2 + '@emotion/serialize': 1.1.4 babel-plugin-macros: 3.1.0 convert-source-map: 1.9.0 escape-string-regexp: 4.0.0 @@ -1587,7 +1548,7 @@ packages: '@babel/runtime': 7.23.9 '@emotion/babel-plugin': 11.11.0 '@emotion/cache': 11.11.0 - '@emotion/serialize': 1.1.3 + '@emotion/serialize': 1.1.4 '@emotion/use-insertion-effect-with-fallbacks': 1.0.1(react@18.2.0) '@emotion/utils': 1.2.1 '@emotion/weak-memoize': 0.3.1 @@ -1596,26 +1557,6 @@ packages: react: 18.2.0 dev: false - /@emotion/serialize@1.1.2: - resolution: {integrity: sha512-zR6a/fkFP4EAcCMQtLOhIgpprZOwNmCldtpaISpvz348+DP4Mz8ZoKaGGCQpbzepNIUWbq4w6hNZkwDyKoS+HA==} - dependencies: - '@emotion/hash': 0.9.1 - '@emotion/memoize': 0.8.1 - '@emotion/unitless': 0.8.1 - '@emotion/utils': 1.2.1 - csstype: 3.1.3 - dev: false - - /@emotion/serialize@1.1.3: - resolution: {integrity: sha512-iD4D6QVZFDhcbH0RAG1uVu1CwVLMWUkCvAqqlewO/rxf8+87yIBAlt4+AxMiiKPLs5hFc0owNk/sLLAOROw3cA==} - dependencies: - '@emotion/hash': 0.9.1 - '@emotion/memoize': 0.8.1 - '@emotion/unitless': 0.8.1 - '@emotion/utils': 1.2.1 - csstype: 3.1.3 - dev: false - /@emotion/serialize@1.1.4: resolution: {integrity: sha512-RIN04MBT8g+FnDwgvIUi8czvr1LU1alUMI05LekWB5DGyTm8cCBMCRpq3GqaiyEDRptEXOyXnvZ58GZYu4kBxQ==} dependencies: @@ -3108,8 +3049,8 @@ packages: resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} dev: true - /@types/parse-json@4.0.0: - resolution: {integrity: sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==} + /@types/parse-json@4.0.2: + resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==} dev: false /@types/plist@3.0.5: @@ -4482,13 +4423,6 @@ packages: pascalcase: 0.1.1 dev: false - /basic-auth@2.0.1: - resolution: {integrity: sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==} - engines: {node: '>= 0.8'} - dependencies: - safe-buffer: 5.1.2 - dev: false - /bcrypt-pbkdf@1.0.2: resolution: {integrity: sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==} dependencies: @@ -4620,11 +4554,6 @@ packages: node-int64: 0.4.0 dev: true - /bson@1.1.6: - resolution: {integrity: sha512-EvVNVeGo4tHxwi8L6bPj3y3itEvStdwvvlojVxxbyYfoaxJ6keLgrTuKdyfEAszFK+H3olzBuafE0yoh0D1gdg==} - engines: {node: '>=0.6.19'} - dev: false - /buffer-alloc-unsafe@1.1.0: resolution: {integrity: sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==} dev: false @@ -5353,7 +5282,7 @@ packages: resolution: {integrity: sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==} engines: {node: '>=10'} dependencies: - '@types/parse-json': 4.0.0 + '@types/parse-json': 4.0.2 import-fresh: 3.3.0 parse-json: 5.2.0 path-type: 4.0.0 @@ -9422,22 +9351,6 @@ packages: engines: {'0': node >= 0.2.0} dev: true - /jsonwebtoken@8.5.1: - resolution: {integrity: sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==} - engines: {node: '>=4', npm: '>=1.4.28'} - dependencies: - jws: 3.2.2 - lodash.includes: 4.3.0 - lodash.isboolean: 3.0.3 - lodash.isinteger: 4.0.4 - lodash.isnumber: 3.0.3 - lodash.isplainobject: 4.0.6 - lodash.isstring: 4.0.1 - lodash.once: 4.1.1 - ms: 2.1.3 - semver: 5.7.2 - dev: false - /jsonwebtoken@9.0.2: resolution: {integrity: sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==} engines: {node: '>=12', npm: '>=6'} @@ -13672,11 +13585,6 @@ packages: mime-types: 2.1.35 dev: false - /type-of-is@3.5.1: - resolution: {integrity: sha512-SOnx8xygcAh8lvDU2exnK2bomASfNjzB3Qz71s2tw9QnX8fkAo7aC+D0H7FV0HjRKj94CKV2Hi71kVkkO6nOxg==} - engines: {node: '>=0.10.5'} - dev: false - /type@2.7.2: resolution: {integrity: sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==} dev: false diff --git a/src/api/server/ServerApi.ts b/src/api/server/ServerApi.ts index 69994114e..ab6866b13 100644 --- a/src/api/server/ServerApi.ts +++ b/src/api/server/ServerApi.ts @@ -379,8 +379,7 @@ export default class ServerApi { .filter(recipe => recipe.id); // @ts-expect-error Type 'boolean' is not assignable to type 'ConcatArray'. - // eslint-disable-next-line unicorn/prefer-spread - this.recipes = this.recipes.concat(this._getDevRecipes()); + this.recipes = [...this.recipes, ...this._getDevRecipes()]; debug('StubServerApi::getInstalledRecipes resolves', this.recipes); return this.recipes; @@ -582,7 +581,7 @@ export default class ServerApi { file !== 'temp', ); - const recipes = paths + const recipes: IRecipe[] = paths .map(id => { try { // eslint-disable-next-line import/no-dynamic-require diff --git a/src/models/Recipe.ts b/src/models/Recipe.ts index e8f11df5f..11eb1884f 100644 --- a/src/models/Recipe.ts +++ b/src/models/Recipe.ts @@ -50,14 +50,14 @@ export interface IRecipe { partition: string; local: boolean; - // eslint-disable-next-line @typescript-eslint/ban-types - readonly overrideUserAgent?: null | Function; - // eslint-disable-next-line @typescript-eslint/ban-types - readonly buildUrl?: null | Function; - // eslint-disable-next-line @typescript-eslint/ban-types - readonly modifyRequestHeaders?: null | Function; - // eslint-disable-next-line @typescript-eslint/ban-types - readonly knownCertificateHosts?: null | Function; + readonly overrideUserAgent?: () => string; + + readonly buildUrl?: (url: string) => string; + + readonly modifyRequestHeaders?: () => void; + + readonly knownCertificateHosts?: () => void; + readonly events?: null | ((key: string) => string); // TODO: [TS DEBT] Need to check if below properties are needed and where is inherited / implemented from diff --git a/src/stores/SettingsStore.ts b/src/stores/SettingsStore.ts index 72d6331cb..29f173f91 100644 --- a/src/stores/SettingsStore.ts +++ b/src/stores/SettingsStore.ts @@ -183,8 +183,10 @@ export default class SettingsStore extends TypedStore { } } - // eslint-disable-next-line @typescript-eslint/ban-types - _ensureMigrationAndMarkDone(migrationName: string, callback: Function): void { + _ensureMigrationAndMarkDone( + migrationName: string, + callback: () => void, + ): void { if (!this.all.migration[migrationName]) { callback(); diff --git a/src/webview/contextMenuBuilder.ts b/src/webview/contextMenuBuilder.ts index dd39560da..f81b051ee 100644 --- a/src/webview/contextMenuBuilder.ts +++ b/src/webview/contextMenuBuilder.ts @@ -288,11 +288,9 @@ export class ContextMenuBuilder { this.addPaste(menu, menuInfo); this.addPastePlain(menu, menuInfo); this.addInspectElement(menu, menuInfo); - // @ts-expect-error Expected 1 arguments, but got 2. - this.processMenu(menu, menuInfo); + this.processMenu(menu); - // @ts-expect-error Expected 2 arguments, but got 1. - this.copyPageUrl(menu); + this.copyPageUrl(menu, menuInfo); this.goToHomePage(menu, menuInfo); this.openInBrowser(menu, menuInfo); @@ -349,14 +347,12 @@ export class ContextMenuBuilder { } this.addInspectElement(menu, menuInfo); - // @ts-expect-error Expected 1 arguments, but got 2. - this.processMenu(menu, menuInfo); + this.processMenu(menu); this.addSeparator(menu); this.goBack(menu); this.goForward(menu); - // @ts-expect-error Expected 2 arguments, but got 1. - this.copyPageUrl(menu); + this.copyPageUrl(menu, menuInfo); this.goToHomePage(menu, menuInfo); this.openInBrowser(menu, menuInfo); diff --git a/test/helpers/array-helpers.test.ts b/test/helpers/array-helpers.test.ts index 662d6b828..135123b6a 100644 --- a/test/helpers/array-helpers.test.ts +++ b/test/helpers/array-helpers.test.ts @@ -7,7 +7,8 @@ describe('array_helpers', () => { // Expect the arrays to be exactly the same // when both are sorted alphabetically - // eslint-disable-next-line sonar/no-alphabetical-sort - expect(shuffledArray.sort()).toEqual(originalArray.sort()); + expect(shuffledArray.toSorted((a, b) => a.localeCompare(b))).toEqual( + originalArray.toSorted((a, b) => a.localeCompare(b)), + ); }); }); -- cgit v1.2.3-54-g00ecf