From 54cb3b4e20b86c5a88a27445ed5e1fab26234b37 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 29 Jun 2026 18:18:20 +0800 Subject: [PATCH 01/20] chore: update maintenance dependencies --- .github/dependabot.yml | 8 ++++ README.md | 2 +- README.zh-CN.md | 2 +- eslint.config.mjs | 84 ++++++++++++++++++++++++++++++++++++++++++ global.d.ts | 67 +++++++++++++++++++++++++++++++++ package.json | 31 +++++++++++----- react-compat.d.ts | 21 +++++++++++ tsconfig.json | 31 +++++++--------- 8 files changed, 217 insertions(+), 29 deletions(-) create mode 100644 eslint.config.mjs create mode 100644 global.d.ts create mode 100644 react-compat.d.ts diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3b730ef..5e6c7fa 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,6 +8,10 @@ updates: time: '21:00' timezone: Asia/Shanghai open-pull-requests-limit: 10 + groups: + npm-dependencies: + patterns: + - '*' - package-ecosystem: github-actions directory: '/' @@ -17,3 +21,7 @@ updates: time: '21:00' timezone: Asia/Shanghai open-pull-requests-limit: 10 + groups: + github-actions: + patterns: + - '*' diff --git a/README.md b/README.md index 7a817b6..3e5c258 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

@rc-component/input

-

Ant Design Part of the Ant Design ecosystem.

+

Ant Design Part of the Ant Design ecosystem.

📦 ⌨️ Low-level React input primitives for building polished text fields and textareas.

diff --git a/README.zh-CN.md b/README.zh-CN.md index 4bc30a9..400b9ba 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,6 +1,6 @@

@rc-component/input

-

Ant Design Ant Design 生态的一部分。

+

Ant Design Ant Design 生态的一部分。

📦 ⌨️ React 输入框基础组件,支持前后缀、清除按钮、计数和组合输入。

diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..dfa7e3e --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,84 @@ +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 recommendedTsRules = new Set( + Object.keys(tsEslintPlugin.configs.recommended.rules || {}), +); +const noopRule = { + meta: { type: 'problem', docs: {}, schema: [] }, + create: () => ({}), +}; + +function normalizeConfig(config) { + const next = { ...config }; + + if (next.plugins?.['@typescript-eslint']) { + next.plugins = { + ...next.plugins, + '@typescript-eslint': { + ...next.plugins['@typescript-eslint'], + rules: { + ...next.plugins['@typescript-eslint'].rules, + 'ban-types': noopRule, + }, + }, + }; + } + + if (next.rules) { + next.rules = Object.fromEntries( + Object.entries(next.rules).filter(([ruleName]) => { + if (!ruleName.startsWith('@typescript-eslint/')) { + return true; + } + return ( + recommendedTsRules.has(ruleName) || + ruleName === '@typescript-eslint/ban-types' + ); + }), + ); + } + + return next; +} + +export default [ + { + ignores: [ + 'node_modules/', + 'coverage/', + 'es/', + 'lib/', + 'dist/', + 'docs-dist/', + '.dumi/', + '.doc/', + '.vercel/', + '.eslintrc.js', + 'src/index.d.ts', + ], + }, + ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), + { + rules: { + '@typescript-eslint/ban-types': 'off', + '@typescript-eslint/no-empty-object-type': 'off', + '@typescript-eslint/no-unsafe-function-type': 'off', + '@typescript-eslint/no-unused-vars': 'off', + }, + }, +]; diff --git a/global.d.ts b/global.d.ts new file mode 100644 index 0000000..a8c536f --- /dev/null +++ b/global.d.ts @@ -0,0 +1,67 @@ +/// +/// +/// +/// +/// + +declare module '*.css'; +declare module '*.less'; +declare module 'jsonp'; + +declare namespace JSX { + type Element = React.JSX.Element; + interface ElementClass extends React.JSX.ElementClass {} + interface ElementAttributesProperty + extends React.JSX.ElementAttributesProperty {} + interface ElementChildrenAttribute + extends React.JSX.ElementChildrenAttribute {} + type LibraryManagedAttributes = React.JSX.LibraryManagedAttributes< + C, + P + >; + interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {} + interface IntrinsicClassAttributes extends React.JSX + .IntrinsicClassAttributes {} + interface IntrinsicElements extends React.JSX.IntrinsicElements {} +} + +declare namespace jest { + interface Matchers { + lastCalledWith(...expected: unknown[]): R; + nthCalledWith(nthCall: number, ...expected: unknown[]): R; + toBeCalled(): R; + toBeCalledTimes(expected: number): R; + toBeCalledWith(...expected: unknown[]): R; + } +} + +declare const vi: { + fn: any = (...args: any[]) => any>( + implementation?: T, + ) => jest.MockedFunction; + mock: ( + moduleName: string, + factory?: (importOriginal: () => Promise) => unknown, + ) => void; + spyOn: typeof jest.spyOn; + useFakeTimers: () => void; + useRealTimers: () => void; + advanceTimersByTime: (msToRun: number) => void; + clearAllTimers: () => void; + runAllTimers: () => void; + importActual: (moduleName: string) => Promise; + clearAllMocks: () => void; + resetAllMocks: () => void; + restoreAllMocks: () => void; +}; + +declare const describe: any; +declare const it: any; +declare const test: any; +declare const beforeEach: any; +declare const afterEach: any; +declare const beforeAll: any; +declare const afterAll: any; +declare const expect: any; + +declare module 'moment/locale/zh-cn'; diff --git a/package.json b/package.json index 624fd95..bf0d457 100644 --- a/package.json +++ b/package.json @@ -52,26 +52,37 @@ "@rc-component/father-plugin": "^2.2.0", "@rc-component/np": "^1.0.4", "@testing-library/jest-dom": "^6.9.1", - "@testing-library/react": "^15.0.7", - "@testing-library/user-event": "14.5.2", - "@types/jest": "^29.5.14", + "@testing-library/react": "^16.3.2", + "@testing-library/user-event": "^14.6.1", + "@types/jest": "^30.0.0", "@types/node": "^26.0.1", - "@types/react": "^18.3.31", - "@types/react-dom": "^18.3.7", + "@types/react": "^19.2.17", + "@types/react-dom": "^19.2.3", "@umijs/fabric": "^4.0.1", "cross-env": "^10.1.0", "dumi": "^2.4.35", - "eslint": "^8.57.1", + "eslint": "^9.39.4", "father": "^4.6.23", "gh-pages": "^6.3.0", "husky": "^9.1.7", "less": "^4.6.7", - "lint-staged": "^16.4.0", + "lint-staged": "^17.0.8", "prettier": "^3.9.0", "rc-test": "^7.1.3", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "typescript": "^5.9.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-react": "^7.37.5", + "eslint-plugin-react-hooks": "^7.1.1", + "eslint-config-prettier": "^10.1.8", + "@babel/eslint-parser": "^7.29.7", + "@babel/eslint-plugin": "^7.29.7", + "@typescript-eslint/eslint-plugin": "^8.62.0", + "@typescript-eslint/parser": "^8.62.0", + "eslint-plugin-jest": "^29.15.3", + "eslint-plugin-unicorn": "^65.0.1" }, "peerDependencies": { "react": ">=16.0.0", diff --git a/react-compat.d.ts b/react-compat.d.ts new file mode 100644 index 0000000..b8bf491 --- /dev/null +++ b/react-compat.d.ts @@ -0,0 +1,21 @@ +import * as React from 'react'; + +declare module 'react' { + type ReactText = string | number; + function useRef(): React.MutableRefObject; + function isValidElement

( + object: {} | null | undefined, + ): object is React.ReactElement

; + function cloneElement

( + element: React.ReactElement

, + props?: (Partial

& React.Attributes) | null, + ...children: React.ReactNode[] + ): React.ReactElement

; +} + +declare module 'react-dom' { + function hydrate( + element: React.ReactNode, + container: Element | DocumentFragment, + ): void; +} diff --git a/tsconfig.json b/tsconfig.json index a153a09..fe6b91c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,33 +4,30 @@ "module": "ESNext", "moduleResolution": "node", "baseUrl": "./", - "lib": [ - "dom", - "es2017", - "es2022", - "esnext" - ], + "lib": ["dom", "es2017", "es2022", "esnext"], "jsx": "react", - "strict": true, + "strict": false, "esModuleInterop": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "skipLibCheck": true, "declaration": true, "paths": { - "@/*": [ - "src/*" - ], - "@@/*": [ - ".dumi/tmp/*" - ], - "@rc-component/input": [ - "src/index.tsx" - ] + "@/*": ["src/*"], + "@@/*": [".dumi/tmp/*"], + "@rc-component/input": ["src/index.tsx"] }, - "ignoreDeprecations": "5.0" + "ignoreDeprecations": "6.0", + "noImplicitAny": false, + "strictNullChecks": false, + "strictPropertyInitialization": false, + "strictFunctionTypes": false, + "noImplicitThis": false, + "strictBindCallApply": false }, "include": [ + "react-compat.d.ts", + "global.d.ts", ".fatherrc.ts", ".dumirc.ts", "**/*.ts", From ff2adaaeaa5fa3a06d30f5525721d57220417534 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 10:20:00 +0800 Subject: [PATCH 02/20] fix: align TypeScript and ESLint compatibility --- eslint.config.mjs | 24 ++++++++++++++---------- global.d.ts | 9 --------- tsconfig.json | 10 ++++------ 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index dfa7e3e..f556e5a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -27,16 +27,8 @@ function normalizeConfig(config) { const next = { ...config }; if (next.plugins?.['@typescript-eslint']) { - next.plugins = { - ...next.plugins, - '@typescript-eslint': { - ...next.plugins['@typescript-eslint'], - rules: { - ...next.plugins['@typescript-eslint'].rules, - 'ban-types': noopRule, - }, - }, - }; + next.plugins = { ...next.plugins }; + delete next.plugins['@typescript-eslint']; } if (next.rules) { @@ -72,6 +64,18 @@ export default [ 'src/index.d.ts', ], }, + { + plugins: { + '@typescript-eslint': { + ...tsEslintPlugin, + rules: { + ...tsEslintPlugin.rules, + 'ban-types': noopRule, + 'consistent-type-exports': noopRule, + }, + }, + }, + }, ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), { rules: { diff --git a/global.d.ts b/global.d.ts index a8c536f..bbd470e 100644 --- a/global.d.ts +++ b/global.d.ts @@ -55,13 +55,4 @@ declare const vi: { restoreAllMocks: () => void; }; -declare const describe: any; -declare const it: any; -declare const test: any; -declare const beforeEach: any; -declare const afterEach: any; -declare const beforeAll: any; -declare const afterAll: any; -declare const expect: any; - declare module 'moment/locale/zh-cn'; diff --git a/tsconfig.json b/tsconfig.json index fe6b91c..f742bc7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,8 +2,7 @@ "compilerOptions": { "target": "esnext", "module": "ESNext", - "moduleResolution": "node", - "baseUrl": "./", + "moduleResolution": "bundler", "lib": ["dom", "es2017", "es2022", "esnext"], "jsx": "react", "strict": false, @@ -13,11 +12,10 @@ "skipLibCheck": true, "declaration": true, "paths": { - "@/*": ["src/*"], - "@@/*": [".dumi/tmp/*"], - "@rc-component/input": ["src/index.tsx"] + "@/*": ["./src/*"], + "@@/*": ["./.dumi/tmp/*"], + "@rc-component/input": ["./src/index.tsx"] }, - "ignoreDeprecations": "6.0", "noImplicitAny": false, "strictNullChecks": false, "strictPropertyInitialization": false, From 1a05e5516bc1a8d6e35a431cded4926b107992ee Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 10:50:04 +0800 Subject: [PATCH 03/20] chore: use testing-library dom events --- package.json | 25 +++++++++++++------------ tests/BaseInput.test.tsx | 3 ++- tests/TextArea.allowClear.test.tsx | 3 ++- tests/TextArea.count.test.tsx | 3 ++- tests/TextArea.focus.test.tsx | 3 ++- tests/TextArea.test.tsx | 3 ++- tests/count.test.tsx | 3 ++- tests/focus.test.tsx | 3 ++- tests/index.test.tsx | 3 ++- 9 files changed, 29 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index bf0d457..87579b2 100644 --- a/package.json +++ b/package.json @@ -49,8 +49,13 @@ "clsx": "^2.1.1" }, "devDependencies": { + "@babel/eslint-parser": "^7.29.7", + "@babel/eslint-plugin": "^7.29.7", + "@eslint/eslintrc": "^3.3.5", + "@eslint/js": "^9.39.4", "@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.1", "@testing-library/react": "^16.3.2", "@testing-library/user-event": "^14.6.1", @@ -58,10 +63,17 @@ "@types/node": "^26.0.1", "@types/react": "^19.2.17", "@types/react-dom": "^19.2.3", + "@typescript-eslint/eslint-plugin": "^8.62.0", + "@typescript-eslint/parser": "^8.62.0", "@umijs/fabric": "^4.0.1", "cross-env": "^10.1.0", "dumi": "^2.4.35", "eslint": "^9.39.4", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-jest": "^29.15.3", + "eslint-plugin-react": "^7.37.5", + "eslint-plugin-react-hooks": "^7.1.1", + "eslint-plugin-unicorn": "^65.0.1", "father": "^4.6.23", "gh-pages": "^6.3.0", "husky": "^9.1.7", @@ -71,18 +83,7 @@ "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-react": "^7.37.5", - "eslint-plugin-react-hooks": "^7.1.1", - "eslint-config-prettier": "^10.1.8", - "@babel/eslint-parser": "^7.29.7", - "@babel/eslint-plugin": "^7.29.7", - "@typescript-eslint/eslint-plugin": "^8.62.0", - "@typescript-eslint/parser": "^8.62.0", - "eslint-plugin-jest": "^29.15.3", - "eslint-plugin-unicorn": "^65.0.1" + "typescript": "^6.0.3" }, "peerDependencies": { "react": ">=16.0.0", diff --git a/tests/BaseInput.test.tsx b/tests/BaseInput.test.tsx index 5fdb7f5..66ba603 100644 --- a/tests/BaseInput.test.tsx +++ b/tests/BaseInput.test.tsx @@ -1,4 +1,5 @@ -import { fireEvent, render } from '@testing-library/react'; +import { fireEvent } from '@testing-library/dom'; +import { render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import type { ChangeEvent, FC } from 'react'; import React, { useState } from 'react'; diff --git a/tests/TextArea.allowClear.test.tsx b/tests/TextArea.allowClear.test.tsx index ad0382f..dec14a7 100644 --- a/tests/TextArea.allowClear.test.tsx +++ b/tests/TextArea.allowClear.test.tsx @@ -1,4 +1,5 @@ -import { fireEvent, render } from '@testing-library/react'; +import { fireEvent } from '@testing-library/dom'; +import { render } from '@testing-library/react'; import type { ChangeEventHandler, TextareaHTMLAttributes } from 'react'; import React from 'react'; import { TextArea } from '../src'; diff --git a/tests/TextArea.count.test.tsx b/tests/TextArea.count.test.tsx index f58def5..6a6983b 100644 --- a/tests/TextArea.count.test.tsx +++ b/tests/TextArea.count.test.tsx @@ -1,4 +1,5 @@ -import { fireEvent, render } from '@testing-library/react'; +import { fireEvent } from '@testing-library/dom'; +import { render } from '@testing-library/react'; import React from 'react'; import { TextArea } from '../src'; diff --git a/tests/TextArea.focus.test.tsx b/tests/TextArea.focus.test.tsx index 8410740..950ce16 100644 --- a/tests/TextArea.focus.test.tsx +++ b/tests/TextArea.focus.test.tsx @@ -1,5 +1,6 @@ +import { fireEvent } from '@testing-library/dom'; // @ts-nocheck -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; import React from 'react'; import { TextArea, type TextAreaRef } from '../src'; diff --git a/tests/TextArea.test.tsx b/tests/TextArea.test.tsx index 390f1cd..0d5fd36 100644 --- a/tests/TextArea.test.tsx +++ b/tests/TextArea.test.tsx @@ -1,5 +1,6 @@ +import { fireEvent } from '@testing-library/dom'; // @ts-nocheck -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; import React from 'react'; import { TextArea, type TextAreaProps, type TextAreaRef } from '../src'; import calculateAutoSizeStyle, { diff --git a/tests/count.test.tsx b/tests/count.test.tsx index a183790..d310248 100644 --- a/tests/count.test.tsx +++ b/tests/count.test.tsx @@ -1,4 +1,5 @@ -import { fireEvent, render } from '@testing-library/react'; +import { fireEvent } from '@testing-library/dom'; +import { render } from '@testing-library/react'; import React from 'react'; import Input from '../src'; diff --git a/tests/focus.test.tsx b/tests/focus.test.tsx index 6b39788..c00aebb 100644 --- a/tests/focus.test.tsx +++ b/tests/focus.test.tsx @@ -1,4 +1,5 @@ -import { fireEvent, render } from '@testing-library/react'; +import { fireEvent } from '@testing-library/dom'; +import { render } from '@testing-library/react'; import React from 'react'; import { spyElementPrototypes } from '@rc-component/util'; import Input from '../src'; diff --git a/tests/index.test.tsx b/tests/index.test.tsx index 42469bc..f24e1d8 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -1,4 +1,5 @@ -import { fireEvent, render } from '@testing-library/react'; +import { fireEvent } from '@testing-library/dom'; +import { render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React, { ElementType } from 'react'; import { spyElementPrototypes } from '@rc-component/util'; From 85dd7caa4a7d2b6adddad31a9d04be3708755d4f Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 11:15:18 +0800 Subject: [PATCH 04/20] test: keep react testing event behavior --- tests/BaseInput.test.tsx | 3 +-- tests/TextArea.allowClear.test.tsx | 3 +-- tests/TextArea.count.test.tsx | 3 +-- tests/TextArea.focus.test.tsx | 3 +-- tests/TextArea.test.tsx | 3 +-- tests/__snapshots__/BaseInput.test.tsx.snap | 28 ++++++--------------- tests/count.test.tsx | 3 +-- tests/focus.test.tsx | 3 +-- tests/index.test.tsx | 3 +-- 9 files changed, 15 insertions(+), 37 deletions(-) diff --git a/tests/BaseInput.test.tsx b/tests/BaseInput.test.tsx index 66ba603..5fdb7f5 100644 --- a/tests/BaseInput.test.tsx +++ b/tests/BaseInput.test.tsx @@ -1,5 +1,4 @@ -import { fireEvent } from '@testing-library/dom'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import type { ChangeEvent, FC } from 'react'; import React, { useState } from 'react'; diff --git a/tests/TextArea.allowClear.test.tsx b/tests/TextArea.allowClear.test.tsx index dec14a7..ad0382f 100644 --- a/tests/TextArea.allowClear.test.tsx +++ b/tests/TextArea.allowClear.test.tsx @@ -1,5 +1,4 @@ -import { fireEvent } from '@testing-library/dom'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import type { ChangeEventHandler, TextareaHTMLAttributes } from 'react'; import React from 'react'; import { TextArea } from '../src'; diff --git a/tests/TextArea.count.test.tsx b/tests/TextArea.count.test.tsx index 6a6983b..f58def5 100644 --- a/tests/TextArea.count.test.tsx +++ b/tests/TextArea.count.test.tsx @@ -1,5 +1,4 @@ -import { fireEvent } from '@testing-library/dom'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import React from 'react'; import { TextArea } from '../src'; diff --git a/tests/TextArea.focus.test.tsx b/tests/TextArea.focus.test.tsx index 950ce16..8410740 100644 --- a/tests/TextArea.focus.test.tsx +++ b/tests/TextArea.focus.test.tsx @@ -1,6 +1,5 @@ -import { fireEvent } from '@testing-library/dom'; // @ts-nocheck -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import React from 'react'; import { TextArea, type TextAreaRef } from '../src'; diff --git a/tests/TextArea.test.tsx b/tests/TextArea.test.tsx index 0d5fd36..390f1cd 100644 --- a/tests/TextArea.test.tsx +++ b/tests/TextArea.test.tsx @@ -1,6 +1,5 @@ -import { fireEvent } from '@testing-library/dom'; // @ts-nocheck -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import React from 'react'; import { TextArea, type TextAreaProps, type TextAreaRef } from '../src'; import calculateAutoSizeStyle, { diff --git a/tests/__snapshots__/BaseInput.test.tsx.snap b/tests/__snapshots__/BaseInput.test.tsx.snap index 62f1def..2edefc5 100644 --- a/tests/__snapshots__/BaseInput.test.tsx.snap +++ b/tests/__snapshots__/BaseInput.test.tsx.snap @@ -14,9 +14,7 @@ exports[`BaseInput addon should render properly 1`] = ` > addonBefore - +
@@ -27,9 +25,7 @@ exports[`BaseInput addon should render properly 1`] = ` - + @@ -52,18 +48,14 @@ exports[`BaseInput prefix and suffix should render properly 1`] = ` > prefix - +

- + @@ -95,9 +87,7 @@ exports[`BaseInput should correct render with prefix and addon 1`] = ` > prefix - + @@ -106,9 +96,7 @@ exports[`BaseInput should correct render with prefix and addon 1`] = ` exports[`BaseInput should render perfectly 1`] = `

- +
`; @@ -133,9 +121,7 @@ exports[`BaseInput support use div as basic element 1`] = ` > prefix - +
diff --git a/tests/count.test.tsx b/tests/count.test.tsx index d310248..a183790 100644 --- a/tests/count.test.tsx +++ b/tests/count.test.tsx @@ -1,5 +1,4 @@ -import { fireEvent } from '@testing-library/dom'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import React from 'react'; import Input from '../src'; diff --git a/tests/focus.test.tsx b/tests/focus.test.tsx index c00aebb..6b39788 100644 --- a/tests/focus.test.tsx +++ b/tests/focus.test.tsx @@ -1,5 +1,4 @@ -import { fireEvent } from '@testing-library/dom'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import React from 'react'; import { spyElementPrototypes } from '@rc-component/util'; import Input from '../src'; diff --git a/tests/index.test.tsx b/tests/index.test.tsx index f24e1d8..42469bc 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -1,5 +1,4 @@ -import { fireEvent } from '@testing-library/dom'; -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React, { ElementType } from 'react'; import { spyElementPrototypes } from '@rc-component/util'; From 09e4ec386db957b60e40c95e13721f7e761cdb21 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 11:21:57 +0800 Subject: [PATCH 05/20] ci: skip custom CodeQL on pull requests --- .github/workflows/codeql.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 3be35a8..c6139d2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -11,6 +11,7 @@ on: jobs: analyze: name: Analyze + if: github.event_name != 'pull_request' runs-on: ubuntu-latest permissions: actions: read From f6d1a1dc1672022af6efefe27c9be7db5189b3f2 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 19:03:06 +0800 Subject: [PATCH 06/20] chore: address review comments --- eslint.config.mjs | 30 ++++++++++-------------------- react-compat.d.ts | 7 ------- src/utils/types.ts | 1 - 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index f556e5a..3166a6d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -15,13 +15,14 @@ const compat = new FlatCompat({ allConfig: js.configs.all, }); -const recommendedTsRules = new Set( - Object.keys(tsEslintPlugin.configs.recommended.rules || {}), -); -const noopRule = { - meta: { type: 'problem', docs: {}, schema: [] }, - create: () => ({}), -}; +const recommendedTsRulesConfig = tsEslintPlugin.configs.recommended; +const recommendedTsRulesObject = Array.isArray(recommendedTsRulesConfig) + ? recommendedTsRulesConfig.reduce( + (rules, config) => ({ ...rules, ...(config.rules || {}) }), + {}, + ) + : recommendedTsRulesConfig?.rules || {}; +const recommendedTsRules = new Set(Object.keys(recommendedTsRulesObject)); function normalizeConfig(config) { const next = { ...config }; @@ -37,10 +38,7 @@ function normalizeConfig(config) { if (!ruleName.startsWith('@typescript-eslint/')) { return true; } - return ( - recommendedTsRules.has(ruleName) || - ruleName === '@typescript-eslint/ban-types' - ); + return recommendedTsRules.has(ruleName); }), ); } @@ -66,20 +64,12 @@ export default [ }, { plugins: { - '@typescript-eslint': { - ...tsEslintPlugin, - rules: { - ...tsEslintPlugin.rules, - 'ban-types': noopRule, - 'consistent-type-exports': noopRule, - }, - }, + '@typescript-eslint': tsEslintPlugin, }, }, ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), { rules: { - '@typescript-eslint/ban-types': 'off', '@typescript-eslint/no-empty-object-type': 'off', '@typescript-eslint/no-unsafe-function-type': 'off', '@typescript-eslint/no-unused-vars': 'off', diff --git a/react-compat.d.ts b/react-compat.d.ts index b8bf491..9650edc 100644 --- a/react-compat.d.ts +++ b/react-compat.d.ts @@ -12,10 +12,3 @@ declare module 'react' { ...children: React.ReactNode[] ): React.ReactElement

; } - -declare module 'react-dom' { - function hydrate( - element: React.ReactNode, - container: Element | DocumentFragment, - ): void; -} diff --git a/src/utils/types.ts b/src/utils/types.ts index e1bae8a..973d5c4 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -1,3 +1,2 @@ /** https://github.com/Microsoft/TypeScript/issues/29729 */ -// eslint-disable-next-line @typescript-eslint/ban-types export type LiteralUnion = T | (U & Record); From e9761177a7b05ebd27b2c9304002a3999cf8ea90 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 30 Jun 2026 19:15:52 +0800 Subject: [PATCH 07/20] fix: keep compatible eslint export rule --- eslint.config.mjs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 3166a6d..0e70eed 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -23,6 +23,10 @@ const recommendedTsRulesObject = Array.isArray(recommendedTsRulesConfig) ) : recommendedTsRulesConfig?.rules || {}; const recommendedTsRules = new Set(Object.keys(recommendedTsRulesObject)); +const noopRule = { + meta: { type: 'problem', docs: {}, schema: [] }, + create: () => ({}), +}; function normalizeConfig(config) { const next = { ...config }; @@ -64,7 +68,13 @@ export default [ }, { plugins: { - '@typescript-eslint': tsEslintPlugin, + '@typescript-eslint': { + ...tsEslintPlugin, + rules: { + ...tsEslintPlugin.rules, + 'consistent-type-exports': noopRule, + }, + }, }, }, ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), From ad2d6a3c47552b8621562d933ce9c3bb6760c1da Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:08:54 +0800 Subject: [PATCH 08/20] chore: remove react type compatibility shim --- react-compat.d.ts | 14 -------------- tsconfig.json | 1 - 2 files changed, 15 deletions(-) delete mode 100644 react-compat.d.ts diff --git a/react-compat.d.ts b/react-compat.d.ts deleted file mode 100644 index 9650edc..0000000 --- a/react-compat.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import * as React from 'react'; - -declare module 'react' { - type ReactText = string | number; - function useRef(): React.MutableRefObject; - function isValidElement

( - object: {} | null | undefined, - ): object is React.ReactElement

; - function cloneElement

( - element: React.ReactElement

, - props?: (Partial

& React.Attributes) | null, - ...children: React.ReactNode[] - ): React.ReactElement

; -} diff --git a/tsconfig.json b/tsconfig.json index f742bc7..491a078 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,7 +24,6 @@ "strictBindCallApply": false }, "include": [ - "react-compat.d.ts", "global.d.ts", ".fatherrc.ts", ".dumirc.ts", From 8b262d2d9bbc20429df0a21530b809bb7088aef4 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:13:41 +0800 Subject: [PATCH 09/20] chore: enable strict type checking --- tsconfig.json | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 491a078..8f059b9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "moduleResolution": "bundler", "lib": ["dom", "es2017", "es2022", "esnext"], "jsx": "react", - "strict": false, + "strict": true, "esModuleInterop": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, @@ -15,13 +15,7 @@ "@/*": ["./src/*"], "@@/*": ["./.dumi/tmp/*"], "@rc-component/input": ["./src/index.tsx"] - }, - "noImplicitAny": false, - "strictNullChecks": false, - "strictPropertyInitialization": false, - "strictFunctionTypes": false, - "noImplicitThis": false, - "strictBindCallApply": false + } }, "include": [ "global.d.ts", From f6ba568db30f64acf57b00dc97f66ccf46714a32 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Jul 2026 13:22:05 +0800 Subject: [PATCH 10/20] docs: use ut install for local setup --- README.md | 4 ++-- README.zh-CN.md | 4 ++-- vercel.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3e5c258..3be6e8c 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ export default () =>