Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: '/'
Expand All @@ -17,3 +21,7 @@ updates:
time: '21:00'
timezone: Asia/Shanghai
open-pull-requests-limit: 10
groups:
github-actions:
patterns:
- '*'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<h1>@rc-component/slider</h1>
<p><sub><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /> Part of the Ant Design ecosystem.</sub></p>
<p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p>
<p>🎚️ Accessible React slider for single values, ranges, marks, and editable handles.</p>

<p>
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<h1>@rc-component/slider</h1>
<p><sub><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /> Ant Design 生态的一部分。</sub></p>
<p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Ant Design 生态的一部分。</sub></p>
<p>🎚️ React 滑动输入组件,支持范围、刻度、提示和键盘交互。</p>

<p>
Expand Down
88 changes: 88 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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 || {}),
Comment on lines +18 to +19

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== .eslintrc.js ==\n'
nl -ba .eslintrc.js | sed -n '1,240p'

printf '\n== `@typescript-eslint` rules declared in .eslintrc.js ==\n'
rg -n "`@typescript-eslint/`" .eslintrc.js || true

Repository: react-component/slider

Length of output: 219


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== eslint.config.mjs (relevant slice) ==\n'
sed -n '1,140p' eslint.config.mjs | cat -n

printf '\n== .eslintrc.js (full) ==\n'
sed -n '1,240p' .eslintrc.js | cat -n

printf '\n== `@typescript-eslint` rule keys in .eslintrc.js ==\n'
python3 - <<'PY'
import re, pathlib
text = pathlib.Path('.eslintrc.js').read_text()
rules = sorted(set(re.findall(r'["\'](`@typescript-eslint/`[^"\']+)["\']\s*:', text)))
for r in rules:
    print(r)
print(f'\ncount={len(rules)}')
PY

Repository: react-component/slider

Length of output: 3863


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== package.json references ==\n'
rg -n '"`@typescript-eslint/eslint-plugin`"|typescript-eslint|eslint' package.json package-lock.json pnpm-lock.yaml yarn.lock 2>/dev/null || true

printf '\n== repo files mentioning no-empty-interface / no-explicit-any / no-inferrable-types ==\n'
rg -n "`@typescript-eslint/`(no-explicit-any|no-empty-interface|no-inferrable-types)" -S .

Repository: react-component/slider

Length of output: 20999


🌐 Web query:

@typescript-eslint/eslint-plugin recommended rules no-explicit-any no-empty-interface no-inferrable-types

💡 Result:

In the @typescript-eslint/eslint-plugin, the inclusion of these rules in the recommended configuration is as follows: - @typescript-eslint/no-explicit-any: Included in the recommended configuration [1]. - @typescript-eslint/no-empty-interface: Historically included in the recommended configuration, but this rule is now deprecated in favor of @typescript-eslint/no-empty-object-type [2], which is included in the recommended configuration [1]. - @typescript-eslint/no-inferrable-types: This rule is not included in the recommended configuration [1][3]. It is part of the stylistic configuration [4]. Summary Table Rule | Recommended Config | Notes --- | --- | --- @typescript-eslint/no-explicit-any | Yes [1] | - @typescript-eslint/no-empty-interface | Deprecated [2] | Replaced by @typescript-eslint/no-empty-object-type (included) [1][2] @typescript-eslint/no-inferrable-types | No [1][3] | Included in stylistic config [4] As of June 2026, typescript-eslint recommends using shared configurations such as recommended, strict, or stylistic [5][6]. The recommended configuration focuses on rules for code correctness, while the stylistic configuration contains rules that enforce consistent coding patterns without necessarily catching bugs [5].

Citations:


别静默丢掉自定义 TS 规则 这里会把 .eslintrc.js 里的 @typescript-eslint/no-inferrable-types 过滤掉;@typescript-eslint/no-empty-interface 也需要单独迁移/映射到 @typescript-eslint/no-empty-object-type,否则不会自动保留等价约束。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@eslint.config.mjs` around lines 18 - 19, The TypeScript recommended-rule
allowlist in eslint.config.mjs is dropping custom rules from the old
.eslintrc.js setup, so update the migration logic around recommendedTsRules to
preserve user-defined TS rules instead of filtering them out. Make sure
`@typescript-eslint/no-inferrable-types` is carried through, and add an explicit
mapping in the config migration for `@typescript-eslint/no-empty-interface` to its
modern equivalent `@typescript-eslint/no-empty-object-type` so the same constraint
stays enabled.

);
const noopRule = {
meta: { type: 'problem', docs: {}, schema: [] },
create: () => ({}),
};

function normalizeConfig(config) {
const next = { ...config };

if (next.plugins?.['@typescript-eslint']) {
next.plugins = { ...next.plugins };
delete next.plugins['@typescript-eslint'];
}

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',
],
},
{
plugins: {
'@typescript-eslint': {
...tsEslintPlugin,
rules: {
...tsEslintPlugin.rules,
'ban-types': noopRule,
'consistent-type-exports': noopRule,
},
},
},
},
...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',
},
},
];
48 changes: 48 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/// <reference types="jest" />
/// <reference types="node" />
/// <reference types="react" />
/// <reference types="react-dom" />
/// <reference types="@testing-library/jest-dom" />

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<C, P> = React.JSX.LibraryManagedAttributes<C, P>;
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
interface IntrinsicElements extends React.JSX.IntrinsicElements {}
}

declare namespace jest {
interface Matchers<R> {
lastCalledWith(...expected: unknown[]): R;
nthCalledWith(nthCall: number, ...expected: unknown[]): R;
toBeCalled(): R;
toBeCalledTimes(expected: number): R;
toBeCalledWith(...expected: unknown[]): R;
}
}

declare const vi: {
fn: <T extends (...args: any[]) => any = (...args: any[]) => any>(implementation?: T) => jest.MockedFunction<T>;
mock: (moduleName: string, factory?: (importOriginal: <T>() => Promise<T>) => unknown) => void;
spyOn: typeof jest.spyOn;
useFakeTimers: () => void;
useRealTimers: () => void;
advanceTimersByTime: (msToRun: number) => void;
clearAllTimers: () => void;
runAllTimers: () => void;
importActual: <T>(moduleName: string) => Promise<T>;
clearAllMocks: () => void;
resetAllMocks: () => void;
restoreAllMocks: () => void;
};


declare module 'moment/locale/zh-cn';
37 changes: 22 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,45 @@
"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",
"prettier": "^3.9.0",
"@rc-component/np": "^1.0.4",
"@rc-component/tooltip": "^1.2.1",
"@rc-component/trigger": "^3.5.2",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^15.0.7",
"@types/jest": "^29.5.14",
"@testing-library/react": "^16.3.2",
"@types/jest": "^30.0.0",
"@types/node": "^26.0.1",
"@types/react": "^18.3.31",
"@types/react-dom": "^18.3.7",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@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": "^8.57.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-unicorn": "^56.0.1",
"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",
"father-build": "^1.18.6",
"gh-pages": "^6.3.0",
"glob": "^13.0.6",
"husky": "^9.1.7",
"less": "^4.6.7",
"lint-staged": "^17.0.8",
"prettier": "^3.9.0",
"rc-test": "^7.1.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "^19.2.7",
"react-dom": "^19.2.7",
"regenerator-runtime": "^0.14.0",
"typescript": "^5.9.3",
"husky": "^9.1.7",
"lint-staged": "^16.4.0"
"typescript": "^6.0.3"
},
"peerDependencies": {
"react": ">=16.9.0",
Expand Down
16 changes: 16 additions & 0 deletions react-compat.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from 'react';

declare module 'react' {
type ReactText = string | number;
function useRef<T = undefined>(): React.MutableRefObject<T | undefined>;
function isValidElement<P = any>(object: {} | null | undefined): object is React.ReactElement<P>;
function cloneElement<P = any>(
element: React.ReactElement<P>,
props?: (Partial<P> & React.Attributes) | null,
...children: React.ReactNode[]
): React.ReactElement<P>;
}

declare module 'react-dom' {
function hydrate(element: React.ReactNode, container: Element | DocumentFragment): void;
}
Comment on lines +14 to +16

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Shimming hydrate in react-dom for React 19 is unsafe. React 19 has completely removed hydrate from react-dom (replaced by hydrateRoot in react-dom/client). Shimming the type will allow the code to compile but will result in runtime crashes if hydrate is called. It is recommended to migrate the usage to hydrateRoot instead.

Comment on lines +14 to +16

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -nP --glob '!react-compat.d.ts' --type=ts --type=tsx '\bhydrate\s*\(' .

Repository: react-component/slider

Length of output: 188


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the compatibility file and related React API usages.
git ls-files | rg '(^|/)react-compat\.d\.ts$|(^|/)package\.json$|(^|/)tsconfig.*\.json$|(^|/)react-dom|(^|/)react\.d\.ts$'
printf '\n--- react-compat.d.ts ---\n'
cat -n react-compat.d.ts

printf '\n--- hydrate / hydrateRoot usages ---\n'
rg -n --glob '*.ts' --glob '*.tsx' --glob '*.d.ts' '\bhydrateRoot\b|\bhydrate\s*\(' .

printf '\n--- useRef overloads/usages in compat file ---\n'
rg -n --glob '*.d.ts' '\buseRef\b' react-compat.d.ts

Repository: react-component/slider

Length of output: 1200


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n--- package.json ---\n'
cat -n package.json

printf '\n--- tsconfig.json ---\n'
cat -n tsconfig.json

Repository: react-component/slider

Length of output: 5326


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check whether the repo targets React 18/19 or ships its own typings shim.
rg -n --glob 'package.json' '"react"|"react-dom"|"`@types/react`"|"`@types/react-dom`"'

Repository: react-component/slider

Length of output: 160


🏁 Script executed:

#!/bin/bash
set -euo pipefail

cat -n package.json

Repository: react-component/slider

Length of output: 3886


不要把 react-dom.hydrate 加回类型定义。
这个仓库已经依赖 react / react-dom 19 和对应 typings,hydrate 在运行时并不存在;把它补进 ambient types 只会掩盖迁移问题。需要的话直接迁移到 hydrateRoot

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@react-compat.d.ts` around lines 14 - 16, Remove the ambient react-dom hydrate
declaration from react-compat.d.ts so the typings stay aligned with React 19.
This module augmentation is reintroducing an API that no longer exists at
runtime and can hide migration issues; update any call sites to use hydrateRoot
instead of relying on hydrate being typed.

26 changes: 17 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
{
"compilerOptions": {
"target": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"moduleResolution": "bundler",
"jsx": "react",
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true,
"paths": {
"@/*": [
"src/*"
"./src/*"
],
"@@/*": [
"src/.umi/*"
"./src/.umi/*"
],
"@rc-component/slider": [
"src/index.tsx"
"./src/index.tsx"
],
"@rc-component/slider/es": [
"src"
"./src"
],
"@rc-component/slider/es/*": [
"src/*"
"./src/*"
],
"@rc-component/slider/assets/*": [
"assets/*"
"./assets/*"
]
},
"ignoreDeprecations": "5.0"
"noImplicitAny": false,
"strictNullChecks": false,
"strictPropertyInitialization": false,
"strictFunctionTypes": false,
"strict": false,
"noImplicitThis": false,
"strictBindCallApply": false,
"module": "ESNext"
},
"include": [
"react-compat.d.ts",
"global.d.ts",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
".dumirc.ts",
".fatherrc.ts",
"src",
Expand Down
Loading