diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 0dd314b..0000000 --- a/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -# Common -node_modules -dist -# No rules to lint -**/*.md -**/*.json -**/*.yaml diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 288cc8e..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,72 +0,0 @@ -const stylistic = require('@stylistic/eslint-plugin') - -const customized = stylistic.configs.customize({ - // the following options are the default values - indent: 2, - quotes: 'single', - semi: false, -}) - -module.exports = { - parser: 'vue-eslint-parser', - parserOptions: { - parser: '@typescript-eslint/parser', - sourceType: 'module', - }, - env: { - browser: true, - node: true, - }, - plugins: [ - '@typescript-eslint', - '@stylistic', - ], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:vue/vue3-recommended', - ], - rules: { - ...customized.rules, - // js/ts - 'eol-last': 'error', - 'no-trailing-spaces': 'error', - 'comma-style': ['error', 'last'], - 'comma-dangle': ['error', 'always-multiline'], - 'no-multi-spaces': 'error', - 'quotes': [ - 'error', - 'single', - { avoidEscape: true, allowTemplateLiterals: true }, - ], - 'camelcase': ['error', { properties: 'never' }], - 'object-curly-spacing': ['error', 'always'], - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-var-requires': 'off', - '@typescript-eslint/no-unused-vars': [ - 'warn', - { - args: 'all', - argsIgnorePattern: '^_', - caughtErrors: 'all', - caughtErrorsIgnorePattern: '^_', - destructuredArrayIgnorePattern: '^_', - varsIgnorePattern: '^_', - ignoreRestSiblings: true, - }, - ], - '@typescript-eslint/no-this-alias': 'off', - '@typescript-eslint/ban-ts-comment': 'off', - '@typescript-eslint/no-empty-function': 'off', - }, - overrides: [ - { - files: ['packages/docs/**/*.vue'], - rules: { - 'vue/multi-word-component-names': 'off', - '@typescript-eslint/no-unused-vars': 'off', - }, - }, - ], - -} diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index c94f007..9fd457f 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -1,7 +1,7 @@ -name: '🐛 Bug report' +name: 🐛 Bug report description: Create a report to help us improve Fluent Editor title: '🐛 [Bug]: ' -labels: ['🐛 bug'] +labels: [🐛 bug] body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index f43040a..a239ee0 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -1,7 +1,7 @@ name: ✨ Feature Request description: Propose new features to @opentiny/fluent-editor to improve it. title: '✨ [Feature]: ' -labels: ['✨ feature'] +labels: [✨ feature] body: - type: textarea id: feature-solve diff --git a/.github/auto-labeler.yml b/.github/auto-labeler.yml index b84f229..895188d 100644 --- a/.github/auto-labeler.yml +++ b/.github/auto-labeler.yml @@ -1,27 +1,27 @@ version: v1 labels: - - label: 'enhancement' + - label: enhancement sync: true matcher: title: '^feat:.*' - - label: 'documentation' + - label: documentation sync: true matcher: title: '^docs:.*' - - label: 'documentation' + - label: documentation sync: true matcher: title: '^chore:.*' - - label: 'bug' + - label: bug sync: true matcher: title: '^fix:.*' - - label: 'ci' + - label: ci sync: true matcher: title: '^ci:.*' - - label: 'e2e-test' + - label: e2e-test sync: true matcher: title: '^test:.*' diff --git a/.github/workflows/auto-deploy.yml b/.github/workflows/auto-deploy.yml index 3f9c263..c5a21bc 100644 --- a/.github/workflows/auto-deploy.yml +++ b/.github/workflows/auto-deploy.yml @@ -4,7 +4,7 @@ name: Auto Deploy on: # Runs on pushes targeting the default branch push: - branches: ["main"] + branches: [main] paths: - 'packages/docs/**' - '!packages/docs/**/*.spec.ts' @@ -20,7 +20,7 @@ permissions: # Allow one concurrent deployment concurrency: - group: "pages" + group: pages cancel-in-progress: true jobs: @@ -58,4 +58,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v1 \ No newline at end of file + uses: actions/deploy-pages@v1 diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index c43a7f9..3178425 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,29 +1,29 @@ name: Playwright Tests on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: test: timeout-minutes: 60 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install dependencies - run: npm install -g pnpm && pnpm install - - name: dev start - run: pnpm dev & sleep 5 - - name: Install Playwright Browsers - run: pnpm install:browser - - name: Run Playwright tests - run: pnpm test - - uses: actions/upload-artifact@v4 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: npm install -g pnpm && pnpm install + - name: dev start + run: pnpm dev & sleep 5 + - name: Install Playwright Browsers + run: pnpm install:browser + - name: Run Playwright tests + run: pnpm test + - uses: actions/upload-artifact@v4 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.vscode/settings.json b/.vscode/settings.json index 5aa41da..97146c1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,12 +9,24 @@ "source.organizeImports": "never" }, "eslint.enable": true, - "eslint.runtime": "node", "eslint.format.enable": true, - "eslint.useFlatConfig": false, "eslint.validate": [ "javascript", + "javascriptreact", "typescript", + "typescriptreact", "vue", + "html", + "markdown", + "json", + "jsonc", + "yaml", + "toml", + "xml", + "css", + "less", + "scss", + "pcss", + "postcss" ] } diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..c485f7c --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,62 @@ +import antfu from '@antfu/eslint-config' + +export default antfu( + { + stylistic: { + indent: 2, + quotes: 'single', + semi: false, + }, + typescript: true, + vue: true, + regexp: false, + ignores: [ + 'dist', + 'node_modules', + ], + }, + { + rules: { + 'eol-last': 'error', + 'no-trailing-spaces': 'error', + 'comma-style': ['error', 'last'], + 'comma-dangle': ['error', 'always-multiline'], + 'no-multi-spaces': 'error', + 'quotes': [ + 'error', + 'single', + { avoidEscape: true, allowTemplateLiterals: true }, + ], + 'camelcase': ['error', { properties: 'never' }], + 'object-curly-spacing': ['error', 'always'], + + 'ts/no-unused-vars': 'off', + 'ts/explicit-module-boundary-types': 'off', + 'ts/no-explicit-any': 'off', + 'ts/no-var-requires': 'off', + 'ts/no-this-alias': 'off', + 'ts/ban-ts-comment': 'off', + 'ts/no-empty-function': 'off', + 'ts/no-use-before-define': 'off', + 'ts/no-unsafe-function-type': 'off', + + 'vue/multi-word-component-names': 'off', + + 'node/prefer-global/process': 'off', + + 'no-restricted-globals': 'off', + 'eqeqeq': 'off', + 'no-new-func': 'off', + 'no-alert': 'off', + 'prefer-promise-reject-errors': 'off', + + 'antfu/if-newline': 'off', + + 'command/command': 'off', + + 'unused-imports/no-unused-vars': 'off', + + 'unicorn/no-new-array': 'off', + }, + }, +) diff --git a/package.json b/package.json index 254c48e..f76477f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,16 @@ "name": "root", "private": true, "description": "A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It is powerful and out-of-the-box.", + "author": "OpenTiny Team", + "license": "MIT", "homepage": "", + "repository": { + "type": "git", + "url": "git@github.com:opentiny/fluent-editor.git" + }, + "bugs": { + "url": "https://github.com/opentiny/fluent-editor/issues" + }, "keywords": [ "editor", "rich-text-editor", @@ -13,34 +22,21 @@ "opentiny", "fluent-editor" ], - "author": "OpenTiny Team", - "license": "MIT", - "repository": { - "type": "git", - "url": "git@github.com:opentiny/fluent-editor.git" - }, - "bugs": { - "url": "https://github.com/opentiny/fluent-editor/issues" - }, "scripts": { "dev": "pnpm -F fluent-editor-docs dev", "build": "pnpm -F fluent-editor-docs build", "build:lib": "pnpm -F @opentiny/fluent-editor build", - "lint": "eslint \"packages/**/*.{js,ts,vue}\" --cache", - "lint:fix": "eslint \"packages/**/*.{js,ts,vue}\" --fix", + "lint": "eslint . --cache", + "lint:fix": "eslint . --fix", "install:browser": "pnpm -F fluent-editor-docs install:browser", "test": "pnpm -F fluent-editor-docs test", "report": "pnpm -F fluent-editor-docs report" }, "devDependencies": { - "@types/node": "^15.0.2", - "@stylistic/eslint-plugin": "^2.7.2", - "@typescript-eslint/eslint-plugin": "^5.7.0", - "@typescript-eslint/parser": "^5.7.0", - "eslint": "^8.57.0", - "eslint-plugin-vue": "^9.27.0", - "lint-staged": "^12.1.4", - "quill":"^2.0.0" + "@antfu/eslint-config": "^3.7.3", + "@types/node": "^22.7.0", + "eslint": "^9.0.0", + "lint-staged": "^12.1.4" }, "gitHooks": { "pre-commit": "lint-staged", @@ -52,4 +48,4 @@ "git add" ] } -} \ No newline at end of file +} diff --git a/packages/docs/fluent-editor/.vitepress/config.ts b/packages/docs/fluent-editor/.vitepress/config.ts index e5148a2..6b2da9e 100644 --- a/packages/docs/fluent-editor/.vitepress/config.ts +++ b/packages/docs/fluent-editor/.vitepress/config.ts @@ -1,6 +1,6 @@ import { fileURLToPath, URL } from 'node:url' -import { defineConfig } from 'vitepress' import { demoPreviewPlugin } from '@vitepress-code-preview/plugin' +import { defineConfig } from 'vitepress' import { sidebar } from './sidebar' export default defineConfig({ @@ -10,7 +10,7 @@ export default defineConfig({ base: '/fluent-editor/', cleanUrls: true, head: [ - ['link', { rel: 'icon', href: 'favicon.ico' }] + ['link', { rel: 'icon', href: 'favicon.ico' }], ], themeConfig: { logo: '/logo.svg', @@ -19,28 +19,28 @@ export default defineConfig({ { text: '生态', items: [ - { text: 'TinyVue', link: 'https://opentiny.design/tiny-vue/' } - ] - } + { text: 'TinyVue', link: 'https://opentiny.design/tiny-vue/' }, + ], + }, ], socialLinks: [ - { icon: 'github', link: 'https://github.com/opentiny/fluent-editor/' } + { icon: 'github', link: 'https://github.com/opentiny/fluent-editor/' }, ], sidebar: { '/docs/': sidebar(), }, footer: { message: 'Made with ❤ by', - copyright: 'OpenTiny and his friends' + copyright: 'OpenTiny and his friends', }, outline: { - label: '本页目录' + label: '本页目录', }, sidebarMenuLabel: '菜单', returnToTopLabel: '返回顶部', docFooter: { prev: '上一篇', - next: '下一篇' + next: '下一篇', }, search: { provider: 'local', @@ -48,7 +48,7 @@ export default defineConfig({ translations: { button: { buttonText: '搜索', - buttonAriaLabel: '搜索' + buttonAriaLabel: '搜索', }, modal: { displayDetails: '显示详情', @@ -62,12 +62,12 @@ export default defineConfig({ navigateUpKeyAriaLabel: '向上箭头', navigateDownKeyAriaLabel: '向下箭头', closeText: '关闭', - closeKeyAriaLabel: 'ESC' - } - } - } - } - } + closeKeyAriaLabel: 'ESC', + }, + }, + }, + }, + }, }, markdown: { config(md) { diff --git a/packages/docs/fluent-editor/.vitepress/theme/index.ts b/packages/docs/fluent-editor/.vitepress/theme/index.ts index 7d92f3d..bc80195 100644 --- a/packages/docs/fluent-editor/.vitepress/theme/index.ts +++ b/packages/docs/fluent-editor/.vitepress/theme/index.ts @@ -1,15 +1,15 @@ -import type { Theme } from 'vitepress'; -import DefaultTheme from 'vitepress/theme' +import type { Theme } from 'vitepress' import DemoPreview, { useComponents } from '@vitepress-code-preview/container' +import DefaultTheme from 'vitepress/theme' +import { insertBaiduScript } from './insert-baidu-script' import '@vitepress-code-preview/container/dist/style.css' import './style.css' -import { insertBaiduScript } from './insert-baidu-script' -export const define = (value: T): T => value; +export const define = (value: T): T => value export default define({ ...DefaultTheme, enhanceApp({ app }) { useComponents(app, DemoPreview) insertBaiduScript() - } -}); + }, +}) diff --git a/packages/docs/fluent-editor/.vitepress/theme/insert-baidu-script.ts b/packages/docs/fluent-editor/.vitepress/theme/insert-baidu-script.ts index dcc13f0..ac48a5f 100644 --- a/packages/docs/fluent-editor/.vitepress/theme/insert-baidu-script.ts +++ b/packages/docs/fluent-editor/.vitepress/theme/insert-baidu-script.ts @@ -12,4 +12,4 @@ export function insertBaiduScript() { ` baiduScript.textContent = baiduScriptStr document.body.append(baiduScript) -} \ No newline at end of file +} diff --git a/packages/docs/fluent-editor/demos/basic-usage.spec.ts b/packages/docs/fluent-editor/demos/basic-usage.spec.ts index e43c63e..a478be5 100644 --- a/packages/docs/fluent-editor/demos/basic-usage.spec.ts +++ b/packages/docs/fluent-editor/demos/basic-usage.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from '@playwright/test' +import { expect, test } from '@playwright/test' test('has toolbar', async ({ page }) => { page.on('pageerror', exception => expect(exception).toBeNull()) diff --git a/packages/docs/fluent-editor/demos/code-block-highlight.vue b/packages/docs/fluent-editor/demos/code-block-highlight.vue index 2d863ae..c9b5d6e 100644 --- a/packages/docs/fluent-editor/demos/code-block-highlight.vue +++ b/packages/docs/fluent-editor/demos/code-block-highlight.vue @@ -1,10 +1,11 @@