diff --git a/eslint.config.mjs b/eslint.config.mjs index 4913738c4f..9d8dfc33a7 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,28 +1,42 @@ import antfu from '@antfu/eslint-config' +import simpleImportSort from 'eslint-plugin-simple-import-sort' -export default antfu({ - rules: { - 'vue/max-attributes-per-line': [ - 'error', - { - singleline: { - max: 5, +export default antfu( + { + rules: { + 'vue/max-attributes-per-line': [ + 'error', + { + singleline: { + max: 5, + }, + multiline: { + max: 5, + }, }, - multiline: { - max: 5, - }, - }, - ], - 'no-alert': 'off', - 'style/quote-props': 'off', + ], + 'no-alert': 'off', + 'style/quote-props': 'off', + }, + eslint: { + ignorePatterns: [ + 'dist', + 'node_modules', + 'public', + 'extension', + 'extension-firefox', + ], + }, }, - eslint: { - ignorePatterns: [ - 'dist', - 'node_modules', - 'public', - 'extension', - 'extension-firefox', - ], + { + plugins: { + 'simple-import-sort': simpleImportSort, + }, + rules: { + 'import/order': 'off', + 'sort-imports': 'off', + 'simple-import-sort/imports': 'error', + 'simple-import-sort/exports': 'error', + }, }, -}) +) diff --git a/package.json b/package.json index c034e01afe..193a5ced55 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "cross-env": "^7.0.3", "crx": "^5.0.1", "eslint": "^9.2.0", + "eslint-plugin-simple-import-sort": "^12.1.0", "esno": "^4.7.0", "fs-extra": "^11.2.0", "jsdom": "^24.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4cb397a11d..8b26a11255 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -81,6 +81,9 @@ importers: eslint: specifier: ^9.2.0 version: 9.2.0 + eslint-plugin-simple-import-sort: + specifier: ^12.1.0 + version: 12.1.0(eslint@9.2.0) esno: specifier: ^4.7.0 version: 4.7.0 @@ -2367,6 +2370,11 @@ packages: vue-eslint-parser: optional: true + eslint-plugin-simple-import-sort@12.1.0: + resolution: {integrity: sha512-Y2fqAfC11TcG/WP3TrI1Gi3p3nc8XJyEOJYHyEPEGI/UAgNx6akxxlX74p7SbAQdLcgASKhj8M0GKvH3vq/+ig==} + peerDependencies: + eslint: '>=5.0.0' + eslint-plugin-toml@0.11.0: resolution: {integrity: sha512-sau+YvPU4fWTjB+qtBt3n8WS87aoDCs+BVbSUAemGaIsRNbvR9uEk+Tt892iLHTGvp/DPWYoCX4/8DoyAbB+sQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -7934,6 +7942,10 @@ snapshots: - supports-color - typescript + eslint-plugin-simple-import-sort@12.1.0(eslint@9.2.0): + dependencies: + eslint: 9.2.0 + eslint-plugin-toml@0.11.0(eslint@9.2.0): dependencies: debug: 4.3.4 diff --git a/scripts/client.ts b/scripts/client.ts index 88b4b181fd..5a12d23b06 100644 --- a/scripts/client.ts +++ b/scripts/client.ts @@ -1,6 +1,6 @@ import type { ErrorPayload, HMRPayload, Update } from 'vite' -import type { ViteHotContext } from 'vite/types/hot' import type { InferCustomEventPayload } from 'vite/types/customEvent' +import type { ViteHotContext } from 'vite/types/hot' // Vite v3 doesn't export overlay // import { ErrorOverlay, overlayId } from 'vite/src/client/overlay' diff --git a/scripts/manifest.ts b/scripts/manifest.ts index dbe354b710..7cca6b73ea 100644 --- a/scripts/manifest.ts +++ b/scripts/manifest.ts @@ -1,4 +1,5 @@ import fs from 'fs-extra' + import { getManifest } from '../src/manifest' import { isFirefox, log, r } from './utils' diff --git a/scripts/prepare.ts b/scripts/prepare.ts index c36835c220..f3abbab188 100644 --- a/scripts/prepare.ts +++ b/scripts/prepare.ts @@ -1,7 +1,9 @@ // generate stub index.html files for dev entry import { execSync } from 'node:child_process' -import fs from 'fs-extra' + import chokidar from 'chokidar' +import fs from 'fs-extra' + import { isDev, isFirefox, log, r } from './utils' /** diff --git a/scripts/utils.ts b/scripts/utils.ts index 8d573b0acc..818d516e71 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,6 +1,7 @@ import { dirname, resolve } from 'node:path' import process from 'node:process' import { fileURLToPath } from 'node:url' + import { bgCyan, black } from 'kolorist' export const port = Number.parseInt(process.env.PORT || '') || 3303 diff --git a/src/background/index.ts b/src/background/index.ts index fc1968ac98..c31a1a9699 100644 --- a/src/background/index.ts +++ b/src/background/index.ts @@ -1,4 +1,5 @@ import browser from 'webextension-polyfill' + import { setupAllMsgLstnrs } from './messageListeners' browser.runtime.onInstalled.addListener((): void => { diff --git a/src/background/messageListeners/index.ts b/src/background/messageListeners/index.ts index bf9850e19b..9d3f6ee0f0 100644 --- a/src/background/messageListeners/index.ts +++ b/src/background/messageListeners/index.ts @@ -1,10 +1,10 @@ import browser from 'webextension-polyfill' -import { apiListenerFactory } from '../utils' -import API_AUTH from './auth' +import { apiListenerFactory } from '../utils' import API_ANIME from './anime' -import API_HISTORY from './history' +import API_AUTH from './auth' import API_FAVORITE from './favorite' +import API_HISTORY from './history' import API_MOMENT from './moment' import API_NOTIFICATION from './notification' import API_RANKING from './ranking' diff --git a/src/background/utils.ts b/src/background/utils.ts index e6a2d9d7e3..2ad6b86e84 100644 --- a/src/background/utils.ts +++ b/src/background/utils.ts @@ -119,14 +119,14 @@ function apiListenerFactory(API_MAP: APIMAP) { } export { - type FetchAfterHandler, - toJsonHandler, - toData, - sendResponseHandler, - AHS, - type Message, type _FETCH, + AHS, type API, - type APIMAP, apiListenerFactory, + type APIMAP, + type FetchAfterHandler, + type Message, + sendResponseHandler, + toData, + toJsonHandler, } diff --git a/src/components/Dialog.vue b/src/components/Dialog.vue index 2343a735dc..78d38509d3 100644 --- a/src/components/Dialog.vue +++ b/src/components/Dialog.vue @@ -1,5 +1,6 @@