From 4a30d7cfbc40928979c361c46841bce6e3998cb0 Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Sun, 15 Dec 2024 18:02:35 +0800 Subject: [PATCH] feat: update linter and tweaks --- docs/package.json | 18 +- docs/src/.vuepress/utils/exportRaw.ts | 33 +- eslint.config.js | 23 +- package.json | 12 +- packages/admin/package.json | 10 +- packages/admin/src/pages/migration/index.jsx | 7 +- .../client/src/components/ArticleReaction.vue | 10 +- packages/client/src/components/CommentBox.vue | 115 +- .../client/src/components/CommentCard.vue | 19 +- packages/client/src/components/ImageWall.vue | 21 +- .../client/src/components/WalineComment.vue | 42 +- packages/client/src/composables/turnstile.ts | 4 +- packages/client/src/config/default.ts | 4 +- packages/client/src/config/i18n/index.ts | 1 + packages/client/src/config/index.ts | 8 + packages/client/src/config/sortKey.ts | 11 + packages/client/src/init.ts | 11 +- packages/client/src/utils/emoji.ts | 2 +- packages/client/src/utils/image.ts | 2 +- packages/client/src/utils/userAgent.ts | 4 - packages/client/src/widgets/recentComments.ts | 2 +- packages/server/package.json | 4 +- packages/server/src/config/adapter.js | 4 +- .../server/src/service/markdown/mathjax.js | 75 +- packages/server/src/service/storage/deta.js | 7 +- .../server/src/service/storage/postgresql.js | 1 + pnpm-lock.yaml | 2222 +++++++++-------- 27 files changed, 1378 insertions(+), 1294 deletions(-) create mode 100644 packages/client/src/config/sortKey.ts diff --git a/docs/package.json b/docs/package.json index 5e092ffd1f1..9bbecad463d 100644 --- a/docs/package.json +++ b/docs/package.json @@ -9,19 +9,19 @@ }, "devDependencies": { "@fancyapps/ui": "5.0.36", - "@vuepress/bundler-vite": "2.0.0-rc.18", - "@vuepress/helper": "2.0.0-rc.63", - "@vuepress/plugin-comment": "2.0.0-rc.63", - "@vuepress/plugin-docsearch": "2.0.0-rc.64", - "@vuepress/plugin-redirect": "2.0.0-rc.63", + "@vuepress/bundler-vite": "2.0.0-rc.19", + "@vuepress/helper": "2.0.0-rc.66", + "@vuepress/plugin-comment": "2.0.0-rc.66", + "@vuepress/plugin-docsearch": "2.0.0-rc.66", + "@vuepress/plugin-redirect": "2.0.0-rc.66", "@waline/client": "workspace:*", "marked": "15.0.3", "mathjax-full": "3.2.2", - "sass-embedded": "1.82.0", + "sass-embedded": "1.83.0", "vidstack": "1.12.12", "vue": "3.5.13", - "vuepress": "2.0.0-rc.18", - "vuepress-shared": "2.0.0-rc.60", - "vuepress-theme-hope": "2.0.0-rc.61" + "vuepress": "2.0.0-rc.19", + "vuepress-shared": "2.0.0-rc.64", + "vuepress-theme-hope": "2.0.0-rc.64" } } diff --git a/docs/src/.vuepress/utils/exportRaw.ts b/docs/src/.vuepress/utils/exportRaw.ts index e9c86b75ecd..ef5dc71ddb4 100644 --- a/docs/src/.vuepress/utils/exportRaw.ts +++ b/docs/src/.vuepress/utils/exportRaw.ts @@ -1,36 +1,15 @@ -const fakeClick = (element: HTMLElement): void => { - const ev = document.createEvent('MouseEvents'); - - ev.initMouseEvent( - 'click', - true, - false, - window, - 0, - 0, - 0, - 0, - 0, - false, - false, - false, - false, - 0, - null, - ); - - element.dispatchEvent(ev); -}; - export const exportRaw = (name: string, data: BlobPart): void => { - const urlObject = window.URL || window.webkitURL || window; const saveAnchor = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'a', ) as HTMLAnchorElement; - saveAnchor.href = urlObject.createObjectURL(new Blob([data])); + saveAnchor.href = window.URL.createObjectURL(new Blob([data])); saveAnchor.download = name; - fakeClick(saveAnchor); + const event = new MouseEvent('click', { + relatedTarget: window, + }); + + saveAnchor.dispatchEvent(event); }; diff --git a/eslint.config.js b/eslint.config.js index 407feba36fd..0c74fc97c50 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,14 +1,24 @@ -import hopeConfig, { +import { config, globals, + js, + jsImport, + prettier, + ts, + tsImport, tsParser, + vitest, } from 'eslint-config-mister-hope'; import { vue, vueParser } from 'eslint-config-mister-hope/vue'; import reactRecommended from 'eslint-plugin-react/configs/recommended.js'; export default config( + ...js, + ...jsImport, + ...ts, + ...tsImport, + vitest, ...vue, - ...hopeConfig, { ignores: [ '**/.vuepress/.cache/**', @@ -87,14 +97,6 @@ export default config( }, }, - { - files: ['**/*.vue'], - rules: { - // FIXME: Issues with vue files - 'import-x/no-unresolved': 'off', - }, - }, - // @ts-expect-error: react plugin types { files: ['packages/admin/src/**/*.{js,jsx}'], @@ -169,4 +171,5 @@ export default config( globals: globals.node, }, }, + prettier, ); diff --git a/package.json b/package.json index 44f44b60825..8a713abe5df 100644 --- a/package.json +++ b/package.json @@ -50,18 +50,18 @@ "@rollup/plugin-commonjs": "28.0.1", "@rollup/plugin-node-resolve": "15.3.0", "@rollup/plugin-replace": "6.0.1", - "@types/node": "22.10.1", + "@types/node": "22.10.2", "@vitejs/plugin-react": "4.3.4", "apidoc": "1.2.0", "commitizen": "4.3.1", "cross-env": "7.0.3", "cz-conventional-changelog": "3.3.0", - "eslint": "9.16.0", - "eslint-config-mister-hope": "0.3.0", + "eslint": "9.17.0", + "eslint-config-mister-hope": "0.4.0", "eslint-plugin-react": "7.37.2", "eslint-plugin-vue": "9.32.0", "husky": "9.1.7", - "markdownlint-cli2": "0.15.0", + "markdownlint-cli2": "0.16.0", "nano-staged": "0.8.0", "postcss": "8.4.49", "prettier": "3.4.2", @@ -70,13 +70,13 @@ "rollup-plugin-dts": "6.1.1", "rollup-plugin-esbuild": "6.1.1", "rollup-plugin-ts": "3.4.5", - "sass-embedded": "1.82.0", + "sass-embedded": "1.83.0", "sort-package-json": "2.12.0", "stylelint": "16.11.0", "stylelint-config-hope": "7.0.4", "tslib": "2.8.1", "typescript": "5.7.2", - "vercel": "39.1.3", + "vercel": "39.2.2", "vite-plugin-css-injected-by-js": "3.5.2", "vite-plugin-svgr": "4.3.0", "vitest": "2.1.8" diff --git a/packages/admin/package.json b/packages/admin/package.json index 3bb8f58c45c..f87db35a9f1 100644 --- a/packages/admin/package.json +++ b/packages/admin/package.json @@ -50,14 +50,14 @@ "@rematch/core": "2.2.0", "base-icon": "2.3.2", "classnames": "2.5.1", - "i18next": "24.0.5", - "i18next-browser-languagedetector": "8.0.1", + "i18next": "24.1.0", + "i18next-browser-languagedetector": "8.0.2", "md5": "2.3.0", - "qrcode.react": "4.1.0", + "qrcode.react": "4.2.0", "react": "18.3.1", "react-dom": "18.3.1", - "react-i18next": "15.1.3", - "react-redux": "9.1.2", + "react-i18next": "15.2.0", + "react-redux": "9.2.0", "react-router": "7.0.2", "redux": "5.0.1", "typescript": "5.7.2", diff --git a/packages/admin/src/pages/migration/index.jsx b/packages/admin/src/pages/migration/index.jsx index 10419dc0739..64daab00f34 100644 --- a/packages/admin/src/pages/migration/index.jsx +++ b/packages/admin/src/pages/migration/index.jsx @@ -82,9 +82,10 @@ export default function () { }) : data; - for (const k in body) { - if (body[k] === null || body[k] === undefined) { - delete body[k]; + for (const key in body) { + if (body[key] === null || body[key] === undefined) { + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete body[key]; } } diff --git a/packages/client/src/components/ArticleReaction.vue b/packages/client/src/components/ArticleReaction.vue index 46b4d1c32c0..166665fd71c 100644 --- a/packages/client/src/components/ArticleReaction.vue +++ b/packages/client/src/components/ArticleReaction.vue @@ -1,12 +1,11 @@