From 6429d1e9bf6998e18664c7fd143fd48444c4c3ce Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 10:03:29 +0800
Subject: [PATCH 01/14] chore: standardize repository maintenance
---
.github/FUNDING.yml | 2 +
.github/dependabot.yml | 53 ++++++++++----------
.github/workflows/codeql.yml | 43 ++++++++++++++++
.github/workflows/react-doctor.yml | 22 +++++++++
.github/workflows/surge-preview.yml | 48 ++++++++++++++++++
.github/workflows/test.yml | 16 ++++++
README.md | 76 +++++++++++++++++++++++------
README.zh-CN.md | 71 +++++++++++++++++++++++++++
package.json | 5 +-
tsconfig.json | 2 +-
vercel.json | 6 +++
11 files changed, 297 insertions(+), 47 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 f23a1fb..5e6c7fa 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,30 +1,27 @@
version: 2
updates:
-- package-ecosystem: npm
- directory: "/"
- schedule:
- interval: daily
- time: "21:00"
- open-pull-requests-limit: 10
- ignore:
- - dependency-name: "@types/jest"
- versions:
- - 26.0.20
- - 26.0.21
- - 26.0.22
- - dependency-name: "@types/react"
- versions:
- - 17.0.0
- - 17.0.1
- - 17.0.2
- - 17.0.3
- - dependency-name: "@types/react-dom"
- versions:
- - 17.0.0
- - 17.0.1
- - 17.0.2
- - dependency-name: np
- versions:
- - 7.2.0
- - 7.3.0
- - 7.4.0
+ - 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
+ 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..394f2b0
--- /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: docs-dist
+ 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 6a37a26..f2257a9 100644
--- a/README.md
+++ b/README.md
@@ -1,25 +1,71 @@
-# @rc-component/context
+
+
@rc-component/context
+
Part of the Ant Design ecosystem.
+
🔁 Performant React context selector utilities for rc-component packages.
----
+
+
+
+
+
+
+
+
+
-React way perf context selector
+English | [简体中文](./README.zh-CN.md)
-[![NPM version][npm-image]][npm-url] [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![node version][node-image]][node-url] [![npm download][download-image]][download-url]
+## Highlights
-[npm-image]: http://img.shields.io/npm/v/@rc-component/context.svg?style=flat-square
-[npm-url]: http://npmjs.org/package/@rc-component/context
-[github-actions-image]: https://github.com/react-component/context/workflows/CI/badge.svg
-[github-actions-url]: https://github.com/react-component/context/actions
-[codecov-image]: https://img.shields.io/codecov/c/github/react-component/context/master.svg?style=flat-square
-[codecov-url]: https://app.codecov.io/gh/react-component/context
-[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
-[node-url]: http://nodejs.org/download/
-[download-image]: https://img.shields.io/npm/dm/@rc-component/context.svg?style=flat-square
-[download-url]: https://npmjs.org/package/@rc-component/context
+| Area | Support |
+| ------- | ---------------------------------------------------------------------- |
+| Purpose | Performant React context selector utilities for rc-component packages. |
+| Package | `@rc-component/context` |
+| Release | `@rc-component/np` / `rc-np` |
-## Development
+## Install
+```bash
+npm install @rc-component/context
```
+
+## Usage
+
+```tsx | pure
+import createContext from '@rc-component/context';
+
+const [Provider, useContext] = createContext({ count: 0 });
+
+export { Provider, useContext };
+```
+
+## API
+
+| API | Description |
+| ----------------------------- | -------------------------------------------------- |
+| `createContext(defaultValue)` | Create a provider and selector-aware context hook. |
+
+## Development
+
+```bash
npm install
npm start
+npm test
+npm run lint
+npm run tsc
+npm run compile
```
+
+The dumi site runs at `http://localhost:8000`.
+
+## Release
+
+```bash
+npm run prepublishOnly
+```
+
+The release flow is handled by `@rc-component/np` through the `rc-np` command when the package uses the shared release flow.
+
+## License
+
+@rc-component/context is released under the [MIT](./LICENSE.md) license.
diff --git a/README.zh-CN.md b/README.zh-CN.md
new file mode 100644
index 0000000..6b38326
--- /dev/null
+++ b/README.zh-CN.md
@@ -0,0 +1,71 @@
+
+
@rc-component/context
+
Ant Design 生态的一部分。
+
🔁 面向 rc-component 包的高性能 React Context 选择器工具。
+
+
+
+
+
+
+
+
+
+
+
+简体中文 | [English](./README.md)
+
+## 亮点
+
+| 方向 | 支持 |
+| ---- | ------------------------------------------------------- |
+| 定位 | 面向 rc-component 包的高性能 React Context 选择器工具。 |
+| 包名 | `@rc-component/context` |
+| 发布 | `@rc-component/np` / `rc-np` |
+
+## 安装
+
+```bash
+npm install @rc-component/context
+```
+
+## 用法
+
+```tsx | pure
+import createContext from '@rc-component/context';
+
+const [Provider, useContext] = createContext({ count: 0 });
+
+export { Provider, useContext };
+```
+
+## API
+
+| 名称 | 说明 |
+| ----------------------------- | ------------------------------------------- |
+| `createContext(defaultValue)` | 创建 Provider 与支持选择器的 context hook。 |
+
+## 本地开发
+
+```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/context 基于 [MIT](./LICENSE.md) 协议发布。
diff --git a/package.json b/package.json
index ea119af..6577bb5 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "@rc-component/context",
"version": "2.0.2",
- "description": "React way perf context selector",
+ "description": "🔁 Performant React context selector utilities for rc-component packages.",
"keywords": [
"react",
"react-component",
@@ -28,7 +28,6 @@
"compile": "father build",
"coverage": "father test --coverage",
"lint": "eslint src/ docs/ --ext .tsx,.ts,.jsx,.js",
- "now-build": "npm run build",
"prepublishOnly": "npm run compile && rc-np",
"start": "dumi dev",
"test": "rc-test",
@@ -53,7 +52,7 @@
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-unicorn": "^52.0.0",
"father": "^4.0.0",
- "rc-test": "^7.0.14",
+ "rc-test": "^7.1.3",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"typescript": "^5.0.2"
diff --git a/tsconfig.json b/tsconfig.json
index 4966b43..8e26f1a 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -13,5 +13,5 @@
"@rc-component/context": ["src/index.ts"]
}
},
- "include": [".dumi/**/*", ".dumirc.ts", "**/*.ts", "**/*.tsx"]
+ "include": [".dumirc.ts", "**/*.ts", "**/*.tsx"]
}
diff --git a/vercel.json b/vercel.json
new file mode 100644
index 0000000..5f9139e
--- /dev/null
+++ b/vercel.json
@@ -0,0 +1,6 @@
+{
+ "framework": "umijs",
+ "installCommand": "npm install",
+ "buildCommand": "npm run build",
+ "outputDirectory": "docs-dist"
+}
From 2d38c192c009ae7058d49a5f091151843d9cb04e Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 10:09:31 +0800
Subject: [PATCH 02/14] 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 23c872209823af11399c33829c5936bb05ad9933 Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 11:59:43 +0800
Subject: [PATCH 03/14] chore: address review feedback
---
.github/workflows/surge-preview.yml | 2 +-
README.md | 4 ++--
README.zh-CN.md | 4 ++--
vercel.json | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/surge-preview.yml b/.github/workflows/surge-preview.yml
index 394f2b0..67305c5 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 f2257a9..98ca6f1 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
-English | [简体中文](./README.zh-CN.md)
+English | 简体中文
## Highlights
@@ -48,7 +48,7 @@ export { Provider, useContext };
## 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 6b38326..ff00697 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -13,7 +13,7 @@
-简体中文 | [English](./README.md)
+简体中文 | English
## 亮点
@@ -48,7 +48,7 @@ export { Provider, useContext };
## 本地开发
```bash
-npm install
+ut install
npm start
npm test
npm run lint
diff --git a/vercel.json b/vercel.json
index 5f9139e..20b1714 100644
--- a/vercel.json
+++ b/vercel.json
@@ -1,6 +1,6 @@
{
"framework": "umijs",
- "installCommand": "npm install",
+ "installCommand": "ut install",
"buildCommand": "npm run build",
"outputDirectory": "docs-dist"
}
From 444ad20df6e8f9081d2d8b44645fefd3b48ea510 Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 12:04:16 +0800
Subject: [PATCH 04/14] 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 67305c5..ba9f1dd 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 ea6cd5669824ec04b98747609046ab871da6f949 Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 13:32:18 +0800
Subject: [PATCH 05/14] 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 20b1714..5f9139e 100644
--- a/vercel.json
+++ b/vercel.json
@@ -1,6 +1,6 @@
{
"framework": "umijs",
- "installCommand": "ut install",
+ "installCommand": "npm install",
"buildCommand": "npm run build",
"outputDirectory": "docs-dist"
}
From 20ab57c50a5619bfa2b3ae50c9e815aa5b6019c1 Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 14:01:14 +0800
Subject: [PATCH 06/14] chore: align maintenance dependencies
---
package.json | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/package.json b/package.json
index 6577bb5..306af47 100644
--- a/package.json
+++ b/package.json
@@ -39,26 +39,26 @@
"devDependencies": {
"@rc-component/father-plugin": "^2.2.0",
"@rc-component/np": "^1.0.4",
- "@types/jest": "^29.5.0",
- "@types/node": "^24.5.2",
- "@types/react": "^18.0.0",
- "@types/react-dom": "^18.0.0",
- "@types/warning": "^3.0.0",
- "@typescript-eslint/eslint-plugin": "^5.62.0",
- "@typescript-eslint/parser": "^5.62.0",
- "@umijs/fabric": "^4.0.0",
- "dumi": "^2.0.15",
- "eslint": "^8.54.0",
- "eslint-plugin-jest": "^27.9.0",
- "eslint-plugin-unicorn": "^52.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",
+ "@types/warning": "^3.0.4",
+ "@typescript-eslint/eslint-plugin": "^8.62.1",
+ "@typescript-eslint/parser": "^8.62.1",
+ "@umijs/fabric": "^4.0.1",
+ "dumi": "^2.4.38",
+ "eslint": "^9.39.4",
+ "eslint-plugin-jest": "^29.15.4",
+ "eslint-plugin-unicorn": "^65.0.1",
+ "father": "^4.6.24",
"rc-test": "^7.1.3",
- "react": "^18.0.0",
- "react-dom": "^18.0.0",
- "typescript": "^5.0.2"
+ "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"
}
}
From f11ca84cfc740196c584bbd567e4681ed7ae98f2 Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 14:23:36 +0800
Subject: [PATCH 07/14] chore: fix upgraded test tooling
---
eslint.config.mjs | 64 +++++++++++++++++++++++++++++++++++++++++++++++
package.json | 9 ++++++-
2 files changed, 72 insertions(+), 1 deletion(-)
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 306af47..0ccecc2 100644
--- a/package.json
+++ b/package.json
@@ -44,6 +44,7 @@
"@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3",
"@types/warning": "^3.0.4",
+ "@testing-library/react": "^16.3.2",
"@typescript-eslint/eslint-plugin": "^8.62.1",
"@typescript-eslint/parser": "^8.62.1",
"@umijs/fabric": "^4.0.1",
@@ -55,7 +56,13 @@
"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",
+ "eslint-plugin-import": "^2.32.0",
+ "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",
From c4a6b113a67f175a1412f8309fa58715c641010b Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 14:26:26 +0800
Subject: [PATCH 08/14] 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 ff00697..2f912e2 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -13,7 +13,7 @@
-简体中文 | English
+English | 简体中文
## 亮点
From 32f2c0254f818a1cf542902d39e25ed88a01f93a Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 14:33:49 +0800
Subject: [PATCH 09/14] 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 0ccecc2..99ae1c4 100644
--- a/package.json
+++ b/package.json
@@ -65,7 +65,7 @@
"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"
}
}
From 9bd91a088ff0b1796bdf77d9067fd6867d2ec7ae Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 14:44:57 +0800
Subject: [PATCH 10/14] chore: fix upgraded tooling checks
---
src/Immutable.tsx | 9 +++++----
src/context.tsx | 2 +-
tsconfig.json | 3 +++
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/Immutable.tsx b/src/Immutable.tsx
index 4a70674..f62f24e 100644
--- a/src/Immutable.tsx
+++ b/src/Immutable.tsx
@@ -94,10 +94,11 @@ export default function createImmutable() {
})`;
}
- return React.memo(
- refAble ? React.forwardRef(ImmutableComponent) : ImmutableComponent,
- propsAreEqual,
- ) as unknown as T;
+ const MemoComponent = refAble
+ ? React.forwardRef(ImmutableComponent)
+ : (ImmutableComponent as React.ComponentType);
+
+ return React.memo(MemoComponent, propsAreEqual) as unknown as T;
}
return {
diff --git a/src/context.tsx b/src/context.tsx
index c8ddcca..a99b56c 100644
--- a/src/context.tsx
+++ b/src/context.tsx
@@ -101,7 +101,7 @@ export function useContext(
const context = React.useContext(holder?.Context);
const { listeners, getValue } = context || {};
- const valueRef = React.useRef();
+ const valueRef = React.useRef(undefined);
valueRef.current = eventSelector(context ? getValue() : holder?.defaultValue);
const [, forceUpdate] = React.useState({});
diff --git a/tsconfig.json b/tsconfig.json
index 8e26f1a..094a947 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,6 +1,9 @@
{
"compilerOptions": {
"target": "esnext",
+ "ignoreDeprecations": "6.0",
+ "strict": false,
+ "types": ["node", "jest"],
"moduleResolution": "node",
"baseUrl": "./",
"jsx": "react",
From 34fdc04d5aff99ac0884cdeaeaf157459aa36623 Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 14:56:06 +0800
Subject: [PATCH 11/14] chore: align TypeScript 6 tooling checks
---
tsconfig.json | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/tsconfig.json b/tsconfig.json
index 094a947..c742fff 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,19 +1,17 @@
{
"compilerOptions": {
"target": "esnext",
- "ignoreDeprecations": "6.0",
"strict": false,
"types": ["node", "jest"],
- "moduleResolution": "node",
- "baseUrl": "./",
+ "moduleResolution": "bundler",
"jsx": "react",
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true,
"paths": {
- "@/*": ["src/*"],
- "@@/*": [".dumi/tmp/*"],
- "@rc-component/context": ["src/index.ts"]
+ "@/*": ["./src/*"],
+ "@@/*": ["./.dumi/tmp/*"],
+ "@rc-component/context": ["./src/index.ts"]
}
},
"include": [".dumirc.ts", "**/*.ts", "**/*.tsx"]
From 880c90885d454c894d9959870f5476d84662ef4c Mon Sep 17 00:00:00 2001
From: afc163
Date: Wed, 1 Jul 2026 18:35:14 +0800
Subject: [PATCH 12/14] 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 98ca6f1..3033390 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,7 @@ export { Provider, useContext };
## 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 2f912e2..b8e67ab 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -48,7 +48,7 @@ export { Provider, useContext };
## 本地开发
```bash
-ut install
+npm install
npm start
npm test
npm run lint
From b46365e402021bf0966f07cb61a866e40983624c Mon Sep 17 00:00:00 2001
From: afc163
Date: Thu, 2 Jul 2026 11:53:59 +0800
Subject: [PATCH 13/14] chore: migrate to native eslint flat config
---
.eslintrc.js | 11 ----
eslint.config.mjs | 131 +++++++++++++++++++++++++++++++---------------
package.json | 20 ++++---
3 files changed, 98 insertions(+), 64 deletions(-)
delete mode 100644 .eslintrc.js
diff --git a/.eslintrc.js b/.eslintrc.js
deleted file mode 100644
index dc20b71..0000000
--- a/.eslintrc.js
+++ /dev/null
@@ -1,11 +0,0 @@
-const base = require('@umijs/fabric/dist/eslint');
-
-module.exports = {
- ...base,
- rules: {
- ...base.rules,
- 'react/no-find-dom-node': 0,
- 'jsx-a11y/label-has-associated-control': 0,
- 'jsx-a11y/label-has-for': 0,
- },
-};
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 99ae1c4..f428a80 100644
--- a/package.json
+++ b/package.json
@@ -37,32 +37,30 @@
"@rc-component/util": "^1.11.0"
},
"devDependencies": {
+ "@eslint/js": "^9.39.4",
"@rc-component/father-plugin": "^2.2.0",
"@rc-component/np": "^1.0.4",
+ "@testing-library/react": "^16.3.2",
"@types/jest": "^30.0.0",
"@types/node": "^26.0.1",
"@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3",
"@types/warning": "^3.0.4",
- "@testing-library/react": "^16.3.2",
- "@typescript-eslint/eslint-plugin": "^8.62.1",
- "@typescript-eslint/parser": "^8.62.1",
- "@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-unicorn": "^65.0.1",
+ "eslint-plugin-jsx-a11y": "^6.10.2",
+ "eslint-plugin-react": "^7.37.5",
+ "eslint-plugin-react-hooks": "^7.1.1",
"father": "^4.6.24",
+ "globals": "^17.7.0",
"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",
- "eslint-plugin-import": "^2.32.0",
- "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 2f7c75b601e9013e7b35c7446d82ca20177578aa Mon Sep 17 00:00:00 2001
From: afc163
Date: Fri, 3 Jul 2026 10:58:03 +0800
Subject: [PATCH 14/14] chore: address review comments
---
README.md | 2 +-
README.zh-CN.md | 2 +-
eslint.config.mjs | 10 +++++++---
package.json | 2 --
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 3033390..e3d7d5c 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ npm install @rc-component/context
## Usage
```tsx | pure
-import createContext from '@rc-component/context';
+import { createContext } from '@rc-component/context';
const [Provider, useContext] = createContext({ count: 0 });
diff --git a/README.zh-CN.md b/README.zh-CN.md
index b8e67ab..2fc4b23 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -32,7 +32,7 @@ npm install @rc-component/context
## 用法
```tsx | pure
-import createContext from '@rc-component/context';
+import { createContext } from '@rc-component/context';
const [Provider, useContext] = createContext({ count: 0 });
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 f428a80..0c840c2 100644
--- a/package.json
+++ b/package.json
@@ -49,9 +49,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",