diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..0c4623c1 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,20 @@ +/* eslint-env node */ +module.exports = { + env: { + browser: true, + es2021: true, + }, + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended", + ], + overrides: [], + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + }, + plugins: ["@typescript-eslint"], + rules: {}, +}; diff --git a/.hintrc b/.hintrc index ae62a1a0..31cbb894 100644 --- a/.hintrc +++ b/.hintrc @@ -10,4 +10,4 @@ } ] } -} \ No newline at end of file +} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..1b8ac889 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# Ignore artifacts: +build +coverage diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/.prettierrc @@ -0,0 +1 @@ +{} diff --git a/commitlint.config.js b/commitlint.config.js index a84c3423..078c6b9b 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,91 +1,101 @@ // eslint-disable-next-line no-undef module.exports = { - extends: ['@commitlint/config-conventional'], // extends can be nested - parserPreset: 'conventional-changelog-conventionalcommits', + extends: ["@commitlint/config-conventional"], // extends can be nested + parserPreset: "conventional-changelog-conventionalcommits", prompt: { settings: {}, messages: { - skip: ':skip', - max: 'upper %d chars', - min: '%d chars at least', - emptyWarning: 'can not be empty', - upperLimitWarning: 'over limit', - lowerLimitWarning: 'below limit' + skip: ":skip", + max: "upper %d chars", + min: "%d chars at least", + emptyWarning: "can not be empty", + upperLimitWarning: "over limit", + lowerLimitWarning: "below limit", }, types: [ - { value: 'feat', name: 'feat: ✨ A new feature', emoji: '✨ ' }, - { value: 'fix', name: 'fix: 🐛 A bug fix', emoji: '🐛 ' }, - { value: 'docs', name: 'docs: 📝 Documentation only changes', emoji: '📝 ' }, + { value: "feat", name: "feat: ✨ A new feature", emoji: "✨ " }, + { value: "fix", name: "fix: 🐛 A bug fix", emoji: "🐛 " }, { - value: 'style', - name: 'style: 💄 Changes that do not affect the meaning of the code', - emoji: '💄 ' + value: "docs", + name: "docs: 📝 Documentation only changes", + emoji: "📝 ", }, { - value: 'refactor', - name: 'refactor: 📦️ A code change that neither fixes a bug nor adds a feature', - emoji: '📦️ ' + value: "style", + name: "style: 💄 Changes that do not affect the meaning of the code", + emoji: "💄 ", }, { - value: 'perf', - name: 'perf: 🚀 A code change that improves performance', - emoji: '🚀 ' + value: "refactor", + name: "refactor: 📦️ A code change that neither fixes a bug nor adds a feature", + emoji: "📦️ ", }, { - value: 'test', - name: 'test: 🚨 Adding missing tests or correcting existing tests', - emoji: '🚨 ' + value: "perf", + name: "perf: 🚀 A code change that improves performance", + emoji: "🚀 ", }, { - value: 'build', - name: 'build: 🛠 Changes that affect the build system or external dependencies', - emoji: '🛠 ' + value: "test", + name: "test: 🚨 Adding missing tests or correcting existing tests", + emoji: "🚨 ", }, { - value: 'ci', - name: 'ci: 🎡 Changes to our CI configuration files and scripts', - emoji: '🎡 ' + value: "build", + name: "build: 🛠 Changes that affect the build system or external dependencies", + emoji: "🛠 ", }, { - value: 'chore', + value: "ci", + name: "ci: 🎡 Changes to our CI configuration files and scripts", + emoji: "🎡 ", + }, + { + value: "chore", name: "chore: 🔨 Other changes that don't modify src or test files", - emoji: '🔨 ' + emoji: "🔨 ", + }, + { + value: "revert", + name: "revert: ⏪️ Reverts a previous commit", + emoji: ":rewind:", }, - { value: 'revert', name: 'revert: ⏪️ Reverts a previous commit', emoji: ':rewind:' } ], useEmoji: true, confirmColorize: true, - emojiAlign: 'center', + emojiAlign: "center", questions: { scope: { - description: 'What is the scope of this change (e.g. component or file name)' + description: + "What is the scope of this change (e.g. component or file name)", }, subject: { - description: 'Write a short, imperative tense description of the change' + description: + "Write a short, imperative tense description of the change", }, body: { - description: 'Provide a longer description of the change' + description: "Provide a longer description of the change", }, isBreaking: { - description: 'Are there any breaking changes?' + description: "Are there any breaking changes?", }, breakingBody: { description: - 'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself' + "A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself", }, breaking: { - description: 'Describe the breaking changes' + description: "Describe the breaking changes", }, isIssueAffected: { - description: 'Does this change affect any open issues?' + description: "Does this change affect any open issues?", }, issuesBody: { description: - 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself' + "If issues are closed, the commit requires a body. Please enter a longer description of the commit itself", }, issues: { - description: 'Add issue references (e.g. "fix #123", "re #123".)' - } - } - } -} + description: 'Add issue references (e.g. "fix #123", "re #123".)', + }, + }, + }, +}; diff --git a/cspell.json b/cspell.json index 852c1b7c..529d6930 100644 --- a/cspell.json +++ b/cspell.json @@ -20,4 +20,4 @@ "**/docs/**", "**/stats.html" ] -} \ No newline at end of file +} diff --git a/package.json b/package.json index 7636f8ad..afc64407 100644 --- a/package.json +++ b/package.json @@ -39,13 +39,19 @@ "@commitlint/cli": "^18.6.0", "@commitlint/config-conventional": "^18.6.0", "@commitlint/cz-commitlint": "^18.6.0", + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", "@waline/client": "^2.15.8", "commitizen": "^4.3.0", "cross-env": "^7.0.3", "cspell": "^8.3.2", "cz-git": "^1.8.0", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.1.3", "husky": "^9.0.10", "lint-staged": "^15.2.2", + "prettier": "3.2.5", "tsno": "^2.0.0", "vitepress": "1.0.0-beta.3", "vue": "^3.4.15", diff --git a/packages/plugin/src/types.ts b/packages/plugin/src/types.ts index 10f29f74..659fff20 100644 --- a/packages/plugin/src/types.ts +++ b/packages/plugin/src/types.ts @@ -1,4 +1,4 @@ -import { OneDialog, OneButton } from "./components"; +import { OneButton } from "./components"; import { ElectronApi } from "../../main/types/preload"; export enum DownloadType { @@ -16,7 +16,6 @@ export interface WebSource { declare global { interface HTMLElementTagNameMap { "one-button": OneButton; - "one-dialog": OneDialog; } interface Window { electron: ElectronApi; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 58406e09..614c0b34 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,6 +22,12 @@ importers: '@commitlint/cz-commitlint': specifier: ^18.6.0 version: 18.6.0(@types/node@20.11.5)(commitizen@4.3.0)(inquirer@8.2.6)(typescript@5.3.3) + '@typescript-eslint/eslint-plugin': + specifier: ^6.21.0 + version: 6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.56.0)(typescript@5.3.3) + '@typescript-eslint/parser': + specifier: ^6.21.0 + version: 6.21.0(eslint@8.56.0)(typescript@5.3.3) '@waline/client': specifier: ^2.15.8 version: 2.15.8(typescript@5.3.3) @@ -37,12 +43,24 @@ importers: cz-git: specifier: ^1.8.0 version: 1.8.0 + eslint: + specifier: ^8.56.0 + version: 8.56.0 + eslint-config-prettier: + specifier: ^9.1.0 + version: 9.1.0(eslint@8.56.0) + eslint-plugin-prettier: + specifier: ^5.1.3 + version: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.56.0)(prettier@3.2.5) husky: specifier: ^9.0.10 version: 9.0.10 lint-staged: specifier: ^15.2.2 version: 15.2.2 + prettier: + specifier: 3.2.5 + version: 3.2.5 tsno: specifier: ^2.0.0 version: 2.0.0 @@ -6548,7 +6566,7 @@ packages: typescript: '*' dependencies: '@typescript-eslint/eslint-plugin': 6.19.0(@typescript-eslint/parser@6.19.0)(eslint@8.56.0)(typescript@5.3.3) - '@typescript-eslint/parser': 6.19.0(eslint@8.56.0)(typescript@5.3.3) + '@typescript-eslint/parser': 6.21.0(eslint@8.56.0)(typescript@5.3.3) eslint: 8.56.0 eslint-config-standard: 17.1.0(eslint-plugin-import@2.29.1)(eslint-plugin-n@16.6.2)(eslint-plugin-promise@6.1.1)(eslint@8.56.0) eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.19.0)(eslint@8.56.0) diff --git a/scripts/build-server.ts b/scripts/build-server.ts index 5cf5a9f8..148da4f8 100644 --- a/scripts/build-server.ts +++ b/scripts/build-server.ts @@ -1,10 +1,10 @@ #!/usr/bin/env zx -import { $,os } from "zx"; +import { $, os } from "zx"; const platform = os.platform(); let GOOS = ""; -let GOARCH = "amd64"; +const GOARCH = "amd64"; let filename = `../packages/main/bin/${platform}/server`; if (platform == "darwin") { diff --git a/scripts/build.ts b/scripts/build.ts index fe34bd04..26d47830 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -5,14 +5,14 @@ import { echo,$ } from "zx"; echo("开始构建 production ..."); echo("当前所在的目录是:", process.cwd()); +await $`npm run types`; + await $`npm run build:server`; await $`npm run build:plugin`; await $`npm run build:mobile`; -await $`npm run types`; - await $`npm run build:main`; await $`npm run build:renderer`; diff --git a/scripts/check.ts b/scripts/check.ts index 18b81df1..f6a1ec33 100644 --- a/scripts/check.ts +++ b/scripts/check.ts @@ -1,8 +1,8 @@ #!/usr/bin/env zx -import type { ProcessOutput } from 'zx' -import { $ } from 'zx' -import { printObject } from './utils' +// import type { ProcessOutput } from "zx"; +// import { $ } from "zx"; +// import { printObject } from "./utils"; // await $`pnpm spellcheck`.catch((out: ProcessOutput) => { // console.log(out) diff --git a/scripts/dev.ts b/scripts/dev.ts index 987793a9..8165fde4 100644 --- a/scripts/dev.ts +++ b/scripts/dev.ts @@ -12,7 +12,7 @@ const main = path.resolve(root, "packages/main"); const app = path.resolve(main, "app"); const bin = path.resolve(app, "bin"); -let filename = path.resolve(bin, `${platform}/server`) +let filename = path.resolve(bin, `${platform}/server`); if (platform == "win32") { filename += ".exe"; } @@ -21,11 +21,11 @@ if (!fs.existsSync(filename)) { await $`npm run build:server`; } -if (!fs.existsSync(path.resolve(app, 'mobile'))) { +if (!fs.existsSync(path.resolve(app, "mobile"))) { await $`npm run build:mobile`; } -if (!fs.existsSync(path.resolve(app, 'plugin'))) { +if (!fs.existsSync(path.resolve(app, "plugin"))) { await $`npm run build:plugin`; } diff --git a/scripts/pre-commit.ts b/scripts/pre-commit.ts index 774e8589..3f7c3c29 100644 --- a/scripts/pre-commit.ts +++ b/scripts/pre-commit.ts @@ -1,13 +1,13 @@ #!/usr/bin/env zx -import { $ } from 'zx' +import { $ } from "zx"; -console.log('开始执行代码质量评估...\n') +console.log("开始执行代码质量评估...\n"); -await import('./check').catch((out) => { - throw new Error('代码质量评估失败, 请检查代码') -}) +await import("./check").catch(() => { + throw new Error("代码质量评估失败, 请检查代码"); +}); -console.log('printf "检测通过, 创建 commit 中...\n') +console.log('printf "检测通过, 创建 commit 中...\n'); -await $`git add .` +await $`git add .`; diff --git a/scripts/utils.ts b/scripts/utils.ts index e56067b0..83573b49 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,11 +1,11 @@ -import { ProcessOutput } from 'zx/core' +import { ProcessOutput } from "zx/core"; export function printObject( object: Record | ProcessOutput, - method: 'log' | 'warn' | 'error' = 'log' + method: "log" | "warn" | "error" = "log", ) { for (const [key, value] of Object.entries(object)) { // eslint-disable-next-line no-console - console[method](`${key}:\n${value}\n`) + console[method](`${key}:\n${value}\n`); } }