From 49ad9d8557505896aae82acac22aaf3ed96bc624 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 10:03:29 +0800 Subject: [PATCH 01/16] chore: standardize repository maintenance --- .github/FUNDING.yml | 2 + .github/dependabot.yml | 32 +++++++--- .github/workflows/codeql.yml | 43 ++++++++++++++ .github/workflows/react-doctor.yml | 22 +++++++ .github/workflows/surge-preview.yml | 48 +++++++++++++++ .github/workflows/test.yml | 16 +++++ README.md | 91 +++++++++++++++++------------ README.zh-CN.md | 71 ++++++++++++++++++++++ package.json | 9 +-- tsconfig.json | 3 +- vercel.json | 6 ++ 11 files changed, 293 insertions(+), 50 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/react-doctor.yml create mode 100644 .github/workflows/surge-preview.yml create mode 100644 .github/workflows/test.yml create mode 100644 README.zh-CN.md create mode 100644 vercel.json diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..758659a --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: ant-design +open_collective: ant-design diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5990d9c..5e6c7fa 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,27 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file - version: 2 updates: - - package-ecosystem: "" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: npm + directory: '/' + schedule: + interval: weekly + day: monday + time: '21:00' + timezone: Asia/Shanghai + open-pull-requests-limit: 10 + groups: + npm-dependencies: + patterns: + - '*' + + - package-ecosystem: github-actions + directory: '/' schedule: - interval: "weekly" + interval: weekly + day: monday + time: '21:00' + timezone: Asia/Shanghai + open-pull-requests-limit: 10 + groups: + github-actions: + patterns: + - '*' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..6082fc6 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,43 @@ +name: 'CodeQL' + +on: + push: + branches: ['master'] + pull_request: + branches: ['master'] + schedule: + - cron: '36 13 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [javascript-typescript] + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Initialize CodeQL + uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e + with: + category: '/language:${{ matrix.language }}' diff --git a/.github/workflows/react-doctor.yml b/.github/workflows/react-doctor.yml new file mode 100644 index 0000000..29d6f76 --- /dev/null +++ b/.github/workflows/react-doctor.yml @@ -0,0 +1,22 @@ +name: React Doctor + +on: + pull_request: + push: + branches: [master] + +permissions: + contents: read + pull-requests: write + issues: write + statuses: write + +jobs: + react-doctor: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + persist-credentials: false + - uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3 diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml new file mode 100644 index 0000000..1f076bc --- /dev/null +++ b/.github/workflows/surge-preview.yml @@ -0,0 +1,48 @@ +name: Surge Preview + +on: + pull_request: + +permissions: + contents: read + pull-requests: write + checks: write + +jobs: + preview: + runs-on: ubuntu-latest + concurrency: + group: surge-preview-${{ github.event.pull_request.number }} + cancel-in-progress: true + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + - name: Check Surge token + id: surge-token + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + run: | + if [ -n "$SURGE_TOKEN" ]; then + echo "enabled=true" >> "$GITHUB_OUTPUT" + else + echo "enabled=false" >> "$GITHUB_OUTPUT" + fi + - name: Build preview + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + run: | + npm install + npm run build + - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + env: + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + with: + surge_token: ${{ env.SURGE_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} + dist: .doc + failOnError: false + setCommitStatus: false + - name: Skip Surge preview + if: ${{ steps.surge-token.outputs.enabled != 'true' }} + run: echo "SURGE_TOKEN is not configured; skip Surge preview." diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..10c0ebb --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,16 @@ +name: ✅ test + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + test: + uses: react-component/rc-test/.github/workflows/test-utoo.yml@main + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 4a57694..2d5ff24 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,71 @@ -# rc-portal +
+

@rc-component/portal

+

Ant Design Part of the Ant Design ecosystem.

+

🌀 React portal primitive with lifecycle-friendly container handling.

+ +

+ NPM version + npm downloads + build status + Codecov + bundle size + dumi +

+
+ +

English | [简体中文](./README.zh-CN.md)

+ +## Highlights + +| Area | Support | +| ------- | ------------------------------------------------------------------ | +| Purpose | React portal primitive with lifecycle-friendly container handling. | +| Package | `@rc-component/portal` | +| Release | `@rc-component/np` / `rc-np` | -React 18 supported Portal Component. +## Install -[![NPM version][npm-image]][npm-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![npm download][download-image]][download-url] +```bash +npm install @rc-component/portal +``` -[npm-image]: http://img.shields.io/npm/v/rc-portal.svg?style=flat-square -[npm-url]: http://npmjs.org/package/rc-portal -[github-actions-image]: https://github.com/react-component/portal/workflows/CI/badge.svg -[github-actions-url]: https://github.com/react-component/portal/actions -[codecov-image]: https://img.shields.io/codecov/c/github/react-component/portal/master.svg?style=flat-square -[codecov-url]: https://app.codecov.io/gh/react-component/portal -[download-image]: https://img.shields.io/npm/dm/rc-portal.svg?style=flat-square -[download-url]: https://npmjs.org/package/rc-portal +## Usage -## Development +```tsx | pure +import Portal from '@rc-component/portal'; -```bash -npm install -npm start -open http://localhost:8000 +export default () => Hello World; ``` -## Feature - -- React life cycle support portal component +## API -## Install +| Prop | Description | +| -------------- | ----------------------------------------- | +| `open` | Whether to render portal content. | +| `getContainer` | Customize portal container. | +| `autoLock` | Lock page scroll when the portal is open. | -[![rc-portal](https://nodei.co/npm/rc-portal.png)](https://npmjs.org/package/rc-portal) +## Development -## Usage +```bash +npm install +npm start +npm test +npm run lint +npm run tsc +npm run compile +``` -```js | pure -import Portal from '@rc-component/portal'; +The dumi site runs at `http://localhost:8000`. -const Demo = () => { - return Hello World; -}; +## Release -export default Demo; +```bash +npm run prepublishOnly ``` -## 🔥 API - -We use typescript to create the Type definition. You can view directly in IDE. But you can still check the type definition [here](https://github.com/react-component/portal/blob/master/src/interface.ts). +The release flow is handled by `@rc-component/np` through the `rc-np` command when the package uses the shared release flow. -### Portal +## License -| Prop | Description | Type | Default | -| ------------ | ---------------------------------- | ------------------------ | ------------- | -| getContainer | Customize portal container element | Element \| () => Element | document.body | -| open | Show the portal | boolean | false | -| autoLock | Lock screen scroll when open | boolean | false | +@rc-component/portal is released under the [MIT](./LICENSE) license. diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 0000000..1cc0a4f --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,71 @@ +
+

@rc-component/portal

+

Ant Design Ant Design 生态的一部分。

+

🌀 支持生命周期与容器管理的 React Portal 基础组件。

+ +

+ NPM version + npm downloads + build status + Codecov + bundle size + dumi +

+
+ +

简体中文 | [English](./README.md)

+ +## 亮点 + +| 方向 | 支持 | +| ---- | ------------------------------------------------ | +| 定位 | 支持生命周期与容器管理的 React Portal 基础组件。 | +| 包名 | `@rc-component/portal` | +| 发布 | `@rc-component/np` / `rc-np` | + +## 安装 + +```bash +npm install @rc-component/portal +``` + +## 用法 + +```tsx | pure +import Portal from '@rc-component/portal'; + +export default () => Hello World; +``` + +## API + +| 名称 | 说明 | +| -------------- | --------------------------- | +| `open` | 是否渲染 Portal 内容。 | +| `getContainer` | 自定义 Portal 容器。 | +| `autoLock` | Portal 打开时锁定页面滚动。 | + +## 本地开发 + +```bash +npm install +npm start +npm test +npm run lint +npm run tsc +npm run compile +``` + +本地 dumi 站点默认运行在 `http://localhost:8000`. + +## 发布 + +```bash +npm run prepublishOnly +``` + +发布流程通过 `@rc-component/np` 提供的 `rc-np` 命令处理。 + +## 许可证 + +@rc-component/portal 基于 [MIT](./LICENSE) 协议发布。 diff --git a/package.json b/package.json index e1842ca..c69c8ad 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@rc-component/portal", "version": "2.2.1", - "description": "React Portal Component", + "description": "🌀 React portal primitive with lifecycle-friendly container handling.", "keywords": [ "react", "react-component", @@ -26,13 +26,13 @@ "dist" ], "scripts": { + "build": "dumi build", "compile": "father build", "deploy": "npm run docs:build && npm run docs:deploy", "docs:build": "dumi build", "docs:deploy": "gh-pages -d docs-dist", "lint": "eslint src/ --ext .tsx,.ts", "lint:tsc": "tsc -p tsconfig.json --noEmit", - "now-build": "npm run docs:build", "prepare": "dumi setup", "prepublishOnly": "npm run compile && rc-np", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", @@ -41,6 +41,7 @@ "test:client": "rc-test --testPathIgnorePatterns=ssr.test.tsx --testPathIgnorePatterns=ssr.test.tsx", "test:coverage": "npm run test:client -- --coverage", "test:server": "rc-test --env=node -- tests/ssr.test.tsx", + "tsc": "tsc -p tsconfig.json --noEmit", "watch": "father dev" }, "dependencies": { @@ -49,7 +50,7 @@ }, "devDependencies": { "@rc-component/father-plugin": "^2.2.0", - "@rc-component/np": "^1.0.3", + "@rc-component/np": "^1.0.4", "@testing-library/dom": "^10.4.1", "@testing-library/jest-dom": "^6.9.0", "@testing-library/react": "^16.3.2", @@ -64,7 +65,7 @@ "gh-pages": "^6.1.1", "glob": "^10.0.0", "prettier": "^2.1.2", - "rc-test": "^7.1.2", + "rc-test": "^7.1.3", "react": "^19.0.0", "react-dom": "^19.0.0", "typescript": "^5.0.0" diff --git a/tsconfig.json b/tsconfig.json index 6e12177..b977d9d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,5 +12,6 @@ "@@/*": [".dumi/tmp/*"], "@rc-component/portal": ["src/Portal.tsx"] } - } + }, + "include": ["**/*.ts", "**/*.tsx", ".dumirc.ts"] } diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..fe70e76 --- /dev/null +++ b/vercel.json @@ -0,0 +1,6 @@ +{ + "framework": "umijs", + "installCommand": "npm install", + "buildCommand": "npm run build", + "outputDirectory": ".doc" +} From b16dd689618da520da39a21c2985c2da85dbc026 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 10:09:28 +0800 Subject: [PATCH 02/16] chore: align reusable test workflow --- .github/workflows/codeql.yml | 43 ------------------------------------ .github/workflows/main.yml | 6 ----- 2 files changed, 49 deletions(-) delete mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 6082fc6..0000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: 'CodeQL' - -on: - push: - branches: ['master'] - pull_request: - branches: ['master'] - schedule: - - cron: '36 13 * * 3' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [javascript-typescript] - - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - name: Initialize CodeQL - uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - with: - languages: ${{ matrix.language }} - queries: +security-and-quality - - - name: Autobuild - uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e - with: - category: '/language:${{ matrix.language }}' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index f860ff1..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: ✅ test -on: [push, pull_request] -jobs: - test: - uses: react-component/rc-test/.github/workflows/test.yml@main - secrets: inherit From 45424b17e4b896eaa5ee1894cb465ca415fd6729 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 11:59:40 +0800 Subject: [PATCH 03/16] chore: address review feedback --- .github/workflows/surge-preview.yml | 2 +- README.md | 14 +++++++------- README.zh-CN.md | 14 +++++++------- tsconfig.json | 3 ++- vercel.json | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index 1f076bc..a3d1e67 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -31,7 +31,7 @@ jobs: - name: Build preview if: ${{ steps.surge-token.outputs.enabled == 'true' }} run: | - npm install + ut install npm run build - uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec if: ${{ steps.surge-token.outputs.enabled == 'true' }} diff --git a/README.md b/README.md index 2d5ff24..791416c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@

-

English | [简体中文](./README.zh-CN.md)

+

English | 简体中文

## Highlights @@ -39,16 +39,16 @@ export default () => Hello World; ## API -| Prop | Description | -| -------------- | ----------------------------------------- | -| `open` | Whether to render portal content. | -| `getContainer` | Customize portal container. | -| `autoLock` | Lock page scroll when the portal is open. | +| Prop | Description | Type | Default | +| --- | --- | --- | --- | +| `getContainer` | Customize portal container. | `Element \| () => Element \| string \| false` | `document.body` | +| `open` | Whether to render portal content. | `boolean` | `false` | +| `autoLock` | Lock page scroll when the portal is open. | `boolean` | `false` | ## Development ```bash -npm install +ut install npm start npm test npm run lint diff --git a/README.zh-CN.md b/README.zh-CN.md index 1cc0a4f..a9045fb 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -13,7 +13,7 @@

-

简体中文 | [English](./README.md)

+

简体中文 | English

## 亮点 @@ -39,16 +39,16 @@ export default () => Hello World; ## API -| 名称 | 说明 | -| -------------- | --------------------------- | -| `open` | 是否渲染 Portal 内容。 | -| `getContainer` | 自定义 Portal 容器。 | -| `autoLock` | Portal 打开时锁定页面滚动。 | +| 名称 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| `getContainer` | 自定义 Portal 容器。 | `Element \| () => Element \| string \| false` | `document.body` | +| `open` | 是否渲染 Portal 内容。 | `boolean` | `false` | +| `autoLock` | Portal 打开时锁定页面滚动。 | `boolean` | `false` | ## 本地开发 ```bash -npm install +ut install npm start npm test npm run lint diff --git a/tsconfig.json b/tsconfig.json index b977d9d..a39a8c5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,6 @@ "@rc-component/portal": ["src/Portal.tsx"] } }, - "include": ["**/*.ts", "**/*.tsx", ".dumirc.ts"] + "include": ["**/*.ts", "**/*.tsx", ".dumirc.ts"], + "exclude": ["node_modules", "es", "lib", "dist", "docs-dist", ".doc", ".dumi/tmp", "coverage"] } diff --git a/vercel.json b/vercel.json index fe70e76..f623ddd 100644 --- a/vercel.json +++ b/vercel.json @@ -1,6 +1,6 @@ { "framework": "umijs", - "installCommand": "npm install", + "installCommand": "ut install", "buildCommand": "npm run build", "outputDirectory": ".doc" } From 6e343572238a586da2cde66614cc8f11c2651a83 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 12:04:13 +0800 Subject: [PATCH 04/16] chore: set up utoo for preview builds --- .github/workflows/surge-preview.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml index a3d1e67..18227e7 100644 --- a/.github/workflows/surge-preview.yml +++ b/.github/workflows/surge-preview.yml @@ -28,6 +28,10 @@ jobs: else echo "enabled=false" >> "$GITHUB_OUTPUT" fi + - name: Setup utoo + if: ${{ steps.surge-token.outputs.enabled == 'true' }} + uses: utooland/setup-utoo@v1 + - name: Build preview if: ${{ steps.surge-token.outputs.enabled == 'true' }} run: | From 42a5a48da9d241bc460ccbabf457620bd127db86 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:32:36 +0800 Subject: [PATCH 05/16] chore: use npm install for vercel preview --- vercel.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vercel.json b/vercel.json index f623ddd..fe70e76 100644 --- a/vercel.json +++ b/vercel.json @@ -1,6 +1,6 @@ { "framework": "umijs", - "installCommand": "ut install", + "installCommand": "npm install", "buildCommand": "npm run build", "outputDirectory": ".doc" } From 638934a4aed5fedeec7dd456427bfefb5afd131b Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:02:56 +0800 Subject: [PATCH 06/16] chore: align maintenance dependencies --- package.json | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index c69c8ad..33181e9 100644 --- a/package.json +++ b/package.json @@ -52,27 +52,27 @@ "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.4", "@testing-library/dom": "^10.4.1", - "@testing-library/jest-dom": "^6.9.0", + "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.2", - "@types/jest": "^26.0.20", - "@types/node": "^20.9.0", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", - "@umijs/fabric": "^4.0.0", - "dumi": "^2.0.0", - "eslint": "^8.0.0", - "father": "^4.0.0", + "@types/jest": "^30.0.0", + "@types/node": "^26.0.1", + "@types/react": "^19.2.17", + "@types/react-dom": "^19.2.3", + "@umijs/fabric": "^4.0.1", + "dumi": "^2.4.38", + "eslint": "^9.39.4", + "father": "^4.6.24", "gh-pages": "^6.1.1", "glob": "^10.0.0", - "prettier": "^2.1.2", + "prettier": "^3.9.4", "rc-test": "^7.1.3", - "react": "^19.0.0", - "react-dom": "^19.0.0", - "typescript": "^5.0.0" + "react": "^19.2.7", + "react-dom": "^19.2.7", + "typescript": "^6.0.3" }, "peerDependencies": { - "react": ">=18.0.0", - "react-dom": ">=18.0.0" + "react": "^19.2.7", + "react-dom": "^19.2.7" }, "engines": { "node": ">=12.x" From fec63b8b1d7b6a13b157ef6adf55d8f4bd17e86c Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:24:44 +0800 Subject: [PATCH 07/16] chore: fix upgraded test tooling --- eslint.config.mjs | 64 +++++++++++++++++++++++ package.json | 11 +++- tests/__snapshots__/index.test.tsx.snap | 2 +- tests/__snapshots__/testEnv.test.tsx.snap | 2 +- 4 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 eslint.config.mjs diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..8291c83 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,64 @@ +import { FlatCompat } from '@eslint/eslintrc'; +import js from '@eslint/js'; +import tsEslintPlugin from '@typescript-eslint/eslint-plugin'; +import { createRequire } from 'node:module'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const require = createRequire(import.meta.url); + +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); + +const supportedTsRules = new Set( + Object.keys(tsEslintPlugin.rules).map(ruleName => `@typescript-eslint/${ruleName}`), +); + +function normalizeConfig(config) { + const next = { ...config }; + + if (next.rules) { + next.rules = Object.fromEntries( + Object.entries(next.rules).filter(([ruleName]) => { + if (ruleName.startsWith('@babel/')) { + return false; + } + return !ruleName.startsWith('@typescript-eslint/') || supportedTsRules.has(ruleName); + }), + ); + } + + return next; +} + +export default [ + { + ignores: [ + 'node_modules/', + 'coverage/', + 'es/', + 'lib/', + 'dist/', + 'docs-dist/', + '.dumi/', + '.doc/', + '.vercel/', + '.eslintrc.js', + ], + }, + ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), + { + rules: { + '@typescript-eslint/no-empty-object-type': 'off', + '@typescript-eslint/no-unsafe-function-type': 'off', + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-useless-constructor': 'off', + '@typescript-eslint/consistent-indexed-object-style': 'off', + }, + }, +]; diff --git a/package.json b/package.json index 33181e9..2ae0e50 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,16 @@ "rc-test": "^7.1.3", "react": "^19.2.7", "react-dom": "^19.2.7", - "typescript": "^6.0.3" + "typescript": "^6.0.3", + "@eslint/eslintrc": "^3.3.5", + "@eslint/js": "^9.39.4", + "@typescript-eslint/eslint-plugin": "^8.62.1", + "@typescript-eslint/parser": "^8.62.1", + "eslint-plugin-import": "^2.32.0", + "eslint-plugin-jest": "^29.15.4", + "eslint-plugin-jsx-a11y": "^6.10.2", + "eslint-plugin-react": "^7.37.5", + "eslint-plugin-react-hooks": "^7.1.1" }, "peerDependencies": { "react": "^19.2.7", diff --git a/tests/__snapshots__/index.test.tsx.snap b/tests/__snapshots__/index.test.tsx.snap index f12cba8..013fa15 100644 --- a/tests/__snapshots__/index.test.tsx.snap +++ b/tests/__snapshots__/index.test.tsx.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`Portal getContainer customize in same level 1`] = `
diff --git a/tests/__snapshots__/testEnv.test.tsx.snap b/tests/__snapshots__/testEnv.test.tsx.snap index 91bdcb4..470d11d 100644 --- a/tests/__snapshots__/testEnv.test.tsx.snap +++ b/tests/__snapshots__/testEnv.test.tsx.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`Test Env inlineMock 1`] = `
From bd856b198673154223ee6b7177adc0427a5cd5bf Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:26:46 +0800 Subject: [PATCH 08/16] docs: align Chinese README language switch --- README.zh-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index a9045fb..abd17b1 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -13,7 +13,7 @@

-

简体中文 | English

+

English | 简体中文

## 亮点 From 3ce9abe6881e5d4601da6e5c45eec78e09f22c3e Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:35:01 +0800 Subject: [PATCH 09/16] fix: preserve React peer dependency range --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2ae0e50..e2a4962 100644 --- a/package.json +++ b/package.json @@ -80,8 +80,8 @@ "eslint-plugin-react-hooks": "^7.1.1" }, "peerDependencies": { - "react": "^19.2.7", - "react-dom": "^19.2.7" + "react": ">=18.0.0", + "react-dom": ">=18.0.0" }, "engines": { "node": ">=12.x" From e935ff68c029b65741adced6e5115bbc821480d8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:45:46 +0800 Subject: [PATCH 10/16] chore: fix upgraded tooling checks --- docs/examples/getContainer.tsx | 4 ++-- tests/index.test.tsx | 6 +++--- tsconfig.json | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/examples/getContainer.tsx b/docs/examples/getContainer.tsx index 1cf2c0b..03b3f22 100644 --- a/docs/examples/getContainer.tsx +++ b/docs/examples/getContainer.tsx @@ -10,7 +10,7 @@ const Content = (): React.ReactElement => { }; export default () => { - const divRef = React.useRef(); + const divRef = React.useRef(null); return (
{ { - return divRef.current; + return divRef.current!; }} > diff --git a/tests/index.test.tsx b/tests/index.test.tsx index 942509b..e7850bd 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -78,11 +78,11 @@ describe('Portal', () => { }; const Demo = () => { - const divRef = React.useRef(); + const divRef = React.useRef(null); return (
- divRef.current}> + divRef.current!}>
@@ -239,7 +239,7 @@ describe('Portal', () => { let checked = false; const Demo = ({ open }: { open?: boolean }) => { - const pRef = React.useRef(); + const pRef = React.useRef(null); React.useEffect(() => { if (open) { diff --git a/tsconfig.json b/tsconfig.json index a39a8c5..635f0bb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,10 @@ { "compilerOptions": { "target": "esnext", + "ignoreDeprecations": "6.0", + "strict": false, + "noUncheckedSideEffectImports": false, + "types": ["node", "jest"], "moduleResolution": "node", "baseUrl": "./", "jsx": "preserve", From 40de5518fa9aadb4481bdeeb6b4d912fc8317b5c Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 14:56:25 +0800 Subject: [PATCH 11/16] chore: align TypeScript 6 tooling checks --- global.d.ts | 1 + src/index.tsx | 2 ++ tsconfig.json | 11 ++++------- 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 global.d.ts diff --git a/global.d.ts b/global.d.ts new file mode 100644 index 0000000..1ea3960 --- /dev/null +++ b/global.d.ts @@ -0,0 +1 @@ +declare module '*.less'; diff --git a/src/index.tsx b/src/index.tsx index 34fa676..718a514 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,3 +1,5 @@ +/* eslint @typescript-eslint/consistent-type-exports: off */ + import Portal from './Portal'; import type { PortalProps } from './Portal'; import { inlineMock } from './mock'; diff --git a/tsconfig.json b/tsconfig.json index 635f0bb..67ceb8c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,20 +1,17 @@ { "compilerOptions": { "target": "esnext", - "ignoreDeprecations": "6.0", "strict": false, - "noUncheckedSideEffectImports": false, "types": ["node", "jest"], - "moduleResolution": "node", - "baseUrl": "./", + "moduleResolution": "bundler", "jsx": "preserve", "declaration": true, "skipLibCheck": true, "esModuleInterop": true, "paths": { - "@/*": ["src/*"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/portal": ["src/Portal.tsx"] + "@/*": ["./src/*"], + "@@/*": ["./.dumi/tmp/*"], + "@rc-component/portal": ["./src/Portal.tsx"] } }, "include": ["**/*.ts", "**/*.tsx", ".dumirc.ts"], From 6251bc479dadbd3a4967b9570fa33299231b1ca6 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 15:24:46 +0800 Subject: [PATCH 12/16] test: update portal render count --- tests/index.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/index.test.tsx b/tests/index.test.tsx index e7850bd..5b81aa8 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -91,7 +91,7 @@ describe('Portal', () => { const { container } = render(); expect(container).toMatchSnapshot(); - expect(renderTimes).toEqual(1); + expect(renderTimes).toEqual(2); }); }); From f31fb5cdd8ba894ad71cc417ff07052f3108ec81 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 18:36:50 +0800 Subject: [PATCH 13/16] docs: use npm install in README --- README.md | 2 +- README.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 791416c..c302c04 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ export default () => Hello World; ## Development ```bash -ut install +npm install npm start npm test npm run lint diff --git a/README.zh-CN.md b/README.zh-CN.md index abd17b1..4a74594 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -48,7 +48,7 @@ export default () => Hello World; ## 本地开发 ```bash -ut install +npm install npm start npm test npm run lint From 3c67dc38425edd28fd106602006c38c2e0b0c93c Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 2 Jul 2026 11:54:04 +0800 Subject: [PATCH 14/16] chore: migrate to native eslint flat config --- .eslintrc.js | 11 ---- eslint.config.mjs | 131 +++++++++++++++++++++++++++++++--------------- package.json | 19 ++++--- 3 files changed, 98 insertions(+), 63 deletions(-) delete mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 59511d8..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,11 +0,0 @@ -const config = { - extends: [require.resolve('@umijs/fabric/dist/eslint')], - rules: { - 'react/no-did-update-set-state': 0, - 'react/no-find-dom-node': 0, - 'import/no-extraneous-dependencies': 0, - 'react/sort-comp': 0, - }, -}; - -module.exports = config; \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs index 8291c83..d19be2a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,42 +1,23 @@ -import { FlatCompat } from '@eslint/eslintrc'; import js from '@eslint/js'; -import tsEslintPlugin from '@typescript-eslint/eslint-plugin'; -import { createRequire } from 'node:module'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { defineConfig } from 'eslint/config'; +import prettier from 'eslint-config-prettier'; +import jest from 'eslint-plugin-jest'; +import react from 'eslint-plugin-react'; +import reactHooks from 'eslint-plugin-react-hooks'; +import globals from 'globals'; +import tseslint from 'typescript-eslint'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -const require = createRequire(import.meta.url); - -const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, - allConfig: js.configs.all, -}); - -const supportedTsRules = new Set( - Object.keys(tsEslintPlugin.rules).map(ruleName => `@typescript-eslint/${ruleName}`), -); - -function normalizeConfig(config) { - const next = { ...config }; - - if (next.rules) { - next.rules = Object.fromEntries( - Object.entries(next.rules).filter(([ruleName]) => { - if (ruleName.startsWith('@babel/')) { - return false; - } - return !ruleName.startsWith('@typescript-eslint/') || supportedTsRules.has(ruleName); - }), - ); - } - - return next; -} - -export default [ +export default defineConfig([ + { + plugins: { + '@typescript-eslint': tseslint.plugin, + }, + }, + { + linterOptions: { + reportUnusedDisableDirectives: 'off', + }, + }, { ignores: [ 'node_modules/', @@ -48,17 +29,83 @@ export default [ '.dumi/', '.doc/', '.vercel/', - '.eslintrc.js', + 'src/index.d.ts', ], }, - ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), { + files: ['**/*.{js,jsx,ts,tsx}'], + extends: [ + js.configs.recommended, + react.configs.flat.recommended, + react.configs.flat['jsx-runtime'], + prettier, + ], + plugins: { + 'react-hooks': reactHooks, + }, + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + }, + settings: { + react: { + version: 'detect', + }, + }, rules: { + 'no-async-promise-executor': 'off', + 'no-empty-pattern': 'off', + 'no-irregular-whitespace': 'off', + 'no-prototype-builtins': 'off', + 'no-useless-escape': 'off', + 'no-extra-boolean-cast': 'off', + 'no-undef': 'off', + 'no-unused-vars': 'off', + 'react/no-find-dom-node': 'off', + 'react/display-name': 'off', + 'react/no-unknown-property': 'off', + 'react/prop-types': 'off', + 'react-hooks/exhaustive-deps': 'warn', + 'react-hooks/rules-of-hooks': 'error', + }, + }, + { + files: ['**/*.{ts,tsx}'], + extends: [...tseslint.configs.recommended], + rules: { + '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/no-empty-object-type': 'off', + '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-unsafe-function-type': 'off', + '@typescript-eslint/no-unnecessary-type-constraint': 'off', '@typescript-eslint/no-unused-vars': 'off', - '@typescript-eslint/no-useless-constructor': 'off', - '@typescript-eslint/consistent-indexed-object-style': 'off', }, }, -]; + { + files: ['src/**/*.{ts,tsx}'], + languageOptions: { + parserOptions: { + projectService: true, + tsconfigRootDir: import.meta.dirname, + }, + }, + }, + { + files: ['tests/**/*.{js,jsx,ts,tsx}', '**/*.{test,spec}.{js,jsx,ts,tsx}'], + extends: [jest.configs['flat/recommended']], + rules: { + 'jest/no-disabled-tests': 'off', + 'jest/no-done-callback': 'off', + 'jest/no-identical-title': 'off', + 'jest/expect-expect': 'off', + 'jest/no-alias-methods': 'off', + 'jest/no-conditional-expect': 'off', + 'jest/no-export': 'off', + 'jest/no-standalone-expect': 'off', + 'jest/valid-expect': 'off', + 'jest/valid-title': 'off', + }, + }, +]); diff --git a/package.json b/package.json index e2a4962..d124d64 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "clsx": "^2.1.1" }, "devDependencies": { + "@eslint/js": "^9.39.4", "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.4", "@testing-library/dom": "^10.4.1", @@ -58,26 +59,24 @@ "@types/node": "^26.0.1", "@types/react": "^19.2.17", "@types/react-dom": "^19.2.3", - "@umijs/fabric": "^4.0.1", "dumi": "^2.4.38", "eslint": "^9.39.4", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-import": "^2.32.0", + "eslint-plugin-jest": "^29.15.4", + "eslint-plugin-jsx-a11y": "^6.10.2", + "eslint-plugin-react": "^7.37.5", + "eslint-plugin-react-hooks": "^7.1.1", "father": "^4.6.24", "gh-pages": "^6.1.1", "glob": "^10.0.0", + "globals": "^17.7.0", "prettier": "^3.9.4", "rc-test": "^7.1.3", "react": "^19.2.7", "react-dom": "^19.2.7", "typescript": "^6.0.3", - "@eslint/eslintrc": "^3.3.5", - "@eslint/js": "^9.39.4", - "@typescript-eslint/eslint-plugin": "^8.62.1", - "@typescript-eslint/parser": "^8.62.1", - "eslint-plugin-import": "^2.32.0", - "eslint-plugin-jest": "^29.15.4", - "eslint-plugin-jsx-a11y": "^6.10.2", - "eslint-plugin-react": "^7.37.5", - "eslint-plugin-react-hooks": "^7.1.1" + "typescript-eslint": "^8.62.1" }, "peerDependencies": { "react": ">=18.0.0", From ba86e372f282a0086ac8c94efdf5715b3f39841f Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 3 Jul 2026 10:58:10 +0800 Subject: [PATCH 15/16] chore: address review comments --- eslint.config.mjs | 10 +++++++--- package.json | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index d19be2a..40f08ec 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,5 +1,7 @@ import js from '@eslint/js'; import { defineConfig } from 'eslint/config'; +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; import prettier from 'eslint-config-prettier'; import jest from 'eslint-plugin-jest'; import react from 'eslint-plugin-react'; @@ -7,6 +9,8 @@ import reactHooks from 'eslint-plugin-react-hooks'; import globals from 'globals'; import tseslint from 'typescript-eslint'; +const tsconfigRootDir = dirname(fileURLToPath(import.meta.url)); + export default defineConfig([ { plugins: { @@ -15,7 +19,7 @@ export default defineConfig([ }, { linterOptions: { - reportUnusedDisableDirectives: 'off', + reportUnusedDisableDirectives: 'warn', }, }, { @@ -26,10 +30,10 @@ export default defineConfig([ 'lib/', 'dist/', 'docs-dist/', + '.docs-dist/', '.dumi/', '.doc/', '.vercel/', - 'src/index.d.ts', ], }, { @@ -88,7 +92,7 @@ export default defineConfig([ languageOptions: { parserOptions: { projectService: true, - tsconfigRootDir: import.meta.dirname, + tsconfigRootDir, }, }, }, diff --git a/package.json b/package.json index d124d64..6016806 100644 --- a/package.json +++ b/package.json @@ -62,9 +62,7 @@ "dumi": "^2.4.38", "eslint": "^9.39.4", "eslint-config-prettier": "^10.1.8", - "eslint-plugin-import": "^2.32.0", "eslint-plugin-jest": "^29.15.4", - "eslint-plugin-jsx-a11y": "^6.10.2", "eslint-plugin-react": "^7.37.5", "eslint-plugin-react-hooks": "^7.1.1", "father": "^4.6.24", From 8f8d5d0d5faee89e62f32200f494b2275b524bac Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 3 Jul 2026 11:34:19 +0800 Subject: [PATCH 16/16] ci: remove legacy preview workflow --- .github/workflows/preview.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml deleted file mode 100644 index d02059a..0000000 --- a/.github/workflows/preview.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: 🔂 Surge PR Preview - -on: [pull_request] - -jobs: - preview: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: afc163/surge-preview@v1 - id: preview_step - with: - surge_token: ${{ secrets.SURGE_TOKEN }} - github_token: ${{ secrets.GITHUB_TOKEN }} - dist: .doc - build: | - npm install - npm run docs:build - - name: Get the preview_url - run: echo "url => ${{ steps.preview_step.outputs.preview_url }}"