Skip to content

Commit 099ea91

Browse files
committed
chore: update maintenance dependencies
1 parent 56a1695 commit 099ea91

10 files changed

Lines changed: 236 additions & 56 deletions

File tree

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ updates:
88
time: '21:00'
99
timezone: Asia/Shanghai
1010
open-pull-requests-limit: 10
11+
groups:
12+
npm-dependencies:
13+
patterns:
14+
- '*'
1115

1216
- package-ecosystem: github-actions
1317
directory: '/'
@@ -17,3 +21,7 @@ updates:
1721
time: '21:00'
1822
timezone: Asia/Shanghai
1923
open-pull-requests-limit: 10
24+
groups:
25+
github-actions:
26+
patterns:
27+
- '*'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div align="center">
22
<h1>@rc-component/segmented</h1>
3-
<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>
3+
<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>
44
<p>🧩 React segmented control for switching between compact options.</p>
55

66
<p>

README.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div align="center">
22
<h1>@rc-component/segmented</h1>
3-
<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>
3+
<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>
44
<p>🧩 React 分段控制器组件。</p>
55

66
<p>

docs/demo/refs.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import React from 'react';
33
import '../../assets/style.less';
44

55
class ClassComponentWithStringRef extends React.Component {
6+
refs: {
7+
segmentedRef: HTMLDivElement;
8+
};
9+
610
componentDidMount() {
711
// eslint-disable-next-line react/no-string-refs
812
console.log(this.refs.segmentedRef, 'ref');
@@ -29,7 +33,9 @@ class ClassComponent2 extends React.Component {
2933
return (
3034
<Segmented
3135
options={['iOS', 'Android', 'Web']}
32-
ref={(ref) => (this.segmentedRef = ref)}
36+
ref={(ref) => {
37+
this.segmentedRef = ref;
38+
}}
3339
/>
3440
);
3541
}

eslint.config.mjs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { FlatCompat } from '@eslint/eslintrc';
2+
import js from '@eslint/js';
3+
import tsEslintPlugin from '@typescript-eslint/eslint-plugin';
4+
import { createRequire } from 'node:module';
5+
import path from 'node:path';
6+
import { fileURLToPath } from 'node:url';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const require = createRequire(import.meta.url);
11+
12+
const compat = new FlatCompat({
13+
baseDirectory: __dirname,
14+
recommendedConfig: js.configs.recommended,
15+
allConfig: js.configs.all,
16+
});
17+
18+
const recommendedTsRules = new Set(
19+
Object.keys(tsEslintPlugin.configs.recommended.rules || {}),
20+
);
21+
const noopRule = {
22+
meta: { type: 'problem', docs: {}, schema: [] },
23+
create: () => ({}),
24+
};
25+
26+
function normalizeConfig(config) {
27+
const next = { ...config };
28+
29+
if (next.plugins?.['@typescript-eslint']) {
30+
next.plugins = {
31+
...next.plugins,
32+
'@typescript-eslint': {
33+
...next.plugins['@typescript-eslint'],
34+
rules: {
35+
...next.plugins['@typescript-eslint'].rules,
36+
'ban-types': noopRule,
37+
},
38+
},
39+
};
40+
}
41+
42+
if (next.rules) {
43+
next.rules = Object.fromEntries(
44+
Object.entries(next.rules).filter(([ruleName]) => {
45+
if (!ruleName.startsWith('@typescript-eslint/')) {
46+
return true;
47+
}
48+
return (
49+
recommendedTsRules.has(ruleName) ||
50+
ruleName === '@typescript-eslint/ban-types'
51+
);
52+
}),
53+
);
54+
}
55+
56+
return next;
57+
}
58+
59+
export default [
60+
{
61+
ignores: [
62+
'node_modules/',
63+
'coverage/',
64+
'es/',
65+
'lib/',
66+
'dist/',
67+
'docs-dist/',
68+
'.dumi/',
69+
'.doc/',
70+
'.vercel/',
71+
'.eslintrc.js',
72+
'src/index.d.ts',
73+
],
74+
},
75+
...compat.config(require('./.eslintrc.js')).map(normalizeConfig),
76+
{
77+
rules: {
78+
'@typescript-eslint/ban-types': 'off',
79+
'@typescript-eslint/no-empty-object-type': 'off',
80+
'@typescript-eslint/no-unsafe-function-type': 'off',
81+
'@typescript-eslint/no-unused-vars': 'off',
82+
},
83+
},
84+
];

global.d.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/// <reference types="jest" />
2+
/// <reference types="node" />
3+
/// <reference types="react" />
4+
/// <reference types="react-dom" />
5+
/// <reference types="@testing-library/jest-dom" />
6+
7+
declare module '*.css';
8+
declare module '*.less';
9+
declare module 'jsonp';
10+
11+
declare namespace JSX {
12+
type Element = React.JSX.Element;
13+
interface ElementClass extends React.JSX.ElementClass {}
14+
interface ElementAttributesProperty
15+
extends React.JSX.ElementAttributesProperty {}
16+
interface ElementChildrenAttribute
17+
extends React.JSX.ElementChildrenAttribute {}
18+
type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<
19+
C,
20+
P
21+
>;
22+
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
23+
interface IntrinsicClassAttributes<T> extends React.JSX
24+
.IntrinsicClassAttributes<T> {}
25+
interface IntrinsicElements extends React.JSX.IntrinsicElements {}
26+
}
27+
28+
declare namespace jest {
29+
interface Matchers<R> {
30+
lastCalledWith(...expected: unknown[]): R;
31+
nthCalledWith(nthCall: number, ...expected: unknown[]): R;
32+
toBeCalled(): R;
33+
toBeCalledTimes(expected: number): R;
34+
toBeCalledWith(...expected: unknown[]): R;
35+
}
36+
}
37+
38+
declare const vi: {
39+
fn: <T extends (...args: any[]) => any = (...args: any[]) => any>(
40+
implementation?: T,
41+
) => jest.MockedFunction<T>;
42+
mock: (
43+
moduleName: string,
44+
factory?: (importOriginal: <T>() => Promise<T>) => unknown,
45+
) => void;
46+
spyOn: typeof jest.spyOn;
47+
useFakeTimers: () => void;
48+
useRealTimers: () => void;
49+
advanceTimersByTime: (msToRun: number) => void;
50+
clearAllTimers: () => void;
51+
runAllTimers: () => void;
52+
importActual: <T>(moduleName: string) => Promise<T>;
53+
clearAllMocks: () => void;
54+
resetAllMocks: () => void;
55+
restoreAllMocks: () => void;
56+
};
57+
58+
declare const describe: any;
59+
declare const it: any;
60+
declare const test: any;
61+
declare const beforeEach: any;
62+
declare const afterEach: any;
63+
declare const beforeAll: any;
64+
declare const afterAll: any;
65+
declare const expect: any;
66+
67+
declare module 'moment/locale/zh-cn';

package.json

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,40 @@
5656
"@rc-component/father-plugin": "^2.2.0",
5757
"@rc-component/np": "^1.0.4",
5858
"@testing-library/jest-dom": "^6.9.1",
59-
"@testing-library/react": "^15.0.7",
60-
"@testing-library/user-event": "14.5.2",
61-
"@types/jest": "^29.5.14",
59+
"@testing-library/react": "^16.3.2",
60+
"@testing-library/user-event": "^14.6.1",
61+
"@types/jest": "^30.0.0",
6262
"@types/node": "^26.0.1",
63-
"@types/react": "^18.3.31",
64-
"@types/react-dom": "^18.3.7",
63+
"@types/react": "^19.2.17",
64+
"@types/react-dom": "^19.2.3",
6565
"@umijs/fabric": "^4.0.1",
6666
"@umijs/test": "^4.6.68",
6767
"cross-env": "^10.1.0",
6868
"dumi": "^2.4.35",
69-
"eslint": "^8.57.1",
69+
"eslint": "^9.39.4",
7070
"father": "^4.6.23",
7171
"gh-pages": "^6.3.0",
7272
"husky": "^9.1.7",
7373
"jest": "^29.7.0",
7474
"jest-environment-jsdom": "^29.7.0",
7575
"less": "^4.6.7",
7676
"prettier": "^3.9.0",
77-
"react": "^18.3.1",
78-
"react-dom": "^18.3.1",
77+
"react": "^19.2.7",
78+
"react-dom": "^19.2.7",
7979
"ts-node": "^10.9.1",
80-
"typescript": "^5.9.3",
81-
"lint-staged": "^16.4.0"
80+
"typescript": "^6.0.3",
81+
"lint-staged": "^17.0.8",
82+
"@eslint/eslintrc": "^3.3.5",
83+
"@eslint/js": "^9.39.4",
84+
"eslint-plugin-react": "^7.37.5",
85+
"eslint-plugin-react-hooks": "^7.1.1",
86+
"eslint-config-prettier": "^10.1.8",
87+
"@babel/eslint-parser": "^7.29.7",
88+
"@babel/eslint-plugin": "^7.29.7",
89+
"@typescript-eslint/eslint-plugin": "^8.62.0",
90+
"@typescript-eslint/parser": "^8.62.0",
91+
"eslint-plugin-jest": "^29.15.3",
92+
"eslint-plugin-unicorn": "^65.0.1"
8293
},
8394
"peerDependencies": {
8495
"react": ">=16.0.0",

react-compat.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as React from 'react';
2+
3+
declare module 'react' {
4+
type ReactText = string | number;
5+
function useRef<T = undefined>(): React.MutableRefObject<T | undefined>;
6+
function isValidElement<P = any>(
7+
object: {} | null | undefined,
8+
): object is React.ReactElement<P>;
9+
function cloneElement<P = any>(
10+
element: React.ReactElement<P>,
11+
props?: (Partial<P> & React.Attributes) | null,
12+
...children: React.ReactNode[]
13+
): React.ReactElement<P>;
14+
}
15+
16+
declare module 'react-dom' {
17+
function hydrate(
18+
element: React.ReactNode,
19+
container: Element | DocumentFragment,
20+
): void;
21+
}

src/index.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ type ItemRender = (
2626
) => React.ReactNode;
2727

2828
type SegmentedOptions<T = SegmentedRawOption> = (
29-
| T
30-
| SegmentedLabeledOption<T>
29+
T | SegmentedLabeledOption<T>
3130
)[];
3231

33-
export interface SegmentedProps<ValueType = SegmentedValue>
34-
extends Omit<
35-
React.HTMLProps<HTMLDivElement>,
36-
'defaultValue' | 'value' | 'onChange'
37-
> {
32+
export interface SegmentedProps<ValueType = SegmentedValue> extends Omit<
33+
React.HTMLProps<HTMLDivElement>,
34+
'defaultValue' | 'value' | 'onChange'
35+
> {
3836
options: SegmentedOptions<ValueType>;
3937
defaultValue?: ValueType;
4038
value?: ValueType;
@@ -67,13 +65,14 @@ function normalizeOptions(options: SegmentedOptions): SegmentedLabeledOption[] {
6765
const validTitle = getValidTitle(option);
6866
return {
6967
...option,
68+
value: option.value as SegmentedValue,
7069
title: validTitle,
71-
};
70+
} as SegmentedLabeledOption;
7271
}
7372
return {
7473
label: option?.toString(),
7574
title: option?.toString(),
76-
value: option,
75+
value: option as SegmentedValue,
7776
};
7877
});
7978
}

tsconfig.json

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,38 @@
44
"module": "ESNext",
55
"moduleResolution": "node",
66
"baseUrl": "./",
7-
"lib": [
8-
"dom",
9-
"es2017"
10-
],
7+
"lib": ["dom", "es2017"],
118
"jsx": "react",
12-
"strict": true,
9+
"strict": false,
1310
"esModuleInterop": true,
1411
"experimentalDecorators": true,
1512
"emitDecoratorMetadata": true,
1613
"skipLibCheck": true,
1714
"declaration": true,
18-
"types": [
19-
"jest",
20-
"node",
21-
"@testing-library/jest-dom"
22-
],
2315
"paths": {
24-
"@/*": [
25-
"src/*"
26-
],
27-
"@@/*": [
28-
".dumi/tmp/*"
29-
],
30-
"@rc-component/segmented": [
31-
"src/index.tsx"
32-
],
33-
"@rc-component/segmented/es": [
34-
"src"
35-
],
36-
"@rc-component/segmented/es/*": [
37-
"src/*"
38-
],
39-
"@rc-component/segmented/assets/*": [
40-
"assets/*"
41-
]
16+
"@/*": ["src/*"],
17+
"@@/*": [".dumi/tmp/*"],
18+
"@rc-component/segmented": ["src/index.tsx"],
19+
"@rc-component/segmented/es": ["src"],
20+
"@rc-component/segmented/es/*": ["src/*"],
21+
"@rc-component/segmented/assets/*": ["assets/*"]
4222
},
43-
"ignoreDeprecations": "5.0"
23+
"ignoreDeprecations": "6.0",
24+
"noImplicitAny": false,
25+
"strictNullChecks": false,
26+
"strictPropertyInitialization": false,
27+
"strictFunctionTypes": false,
28+
"noImplicitThis": false,
29+
"strictBindCallApply": false
4430
},
4531
"include": [
32+
"react-compat.d.ts",
33+
"global.d.ts",
4634
".fatherrc.ts",
4735
".dumirc.ts",
4836
"src",
4937
"tests",
5038
"docs/demo"
5139
],
52-
"exclude": [
53-
"docs-dist",
54-
"lib",
55-
"es"
56-
]
40+
"exclude": ["docs-dist", "lib", "es"]
5741
}

0 commit comments

Comments
 (0)