idea-react 2.0.0-rc.9 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReadMe.md +198 -208
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +62 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +47 -69
- package/source/CodeBlock.tsx +19 -17
- package/source/Countdown.tsx +118 -0
- package/source/Dialog.tsx +41 -41
- package/source/Editor.tsx +46 -46
- package/source/EditorHTML.tsx +16 -21
- package/source/HorizontalMarquee/index.module.less +52 -52
- package/source/HorizontalMarquee/index.tsx +67 -67
- package/source/LiveTSX.tsx +23 -0
- package/source/Loading.tsx +21 -21
- package/source/MonthCalendar.tsx +9 -33
- package/source/PageNav.tsx +102 -102
- package/source/Select.tsx +84 -84
- package/source/ShareBox.tsx +99 -99
- package/source/TableSpinner.tsx +24 -24
- package/source/Time.tsx +15 -14
- package/source/TimeDistance.tsx +41 -41
- package/source/Timeline/index.module.less +53 -53
- package/source/Timeline/index.tsx +3 -13
- package/source/TypeEcho.tsx +49 -49
- package/source/UserRank/index.tsx +108 -122
- package/source/VerticalMarquee/index.module.less +43 -43
- package/source/VerticalMarquee/index.tsx +27 -27
- package/source/ZodiacBar.tsx +51 -0
- package/source/index.ts +28 -25
- package/tsconfig.build.json +11 -11
- package/tsconfig.json +1 -1
- package/eslint.config.ts +0 -69
|
@@ -1,122 +1,108 @@
|
|
|
1
|
-
import { PureComponent } from 'react';
|
|
2
|
-
import { Badge, Col, Image, Row, RowProps, Table } from 'react-bootstrap';
|
|
3
|
-
|
|
4
|
-
import { UserAddress, UserAddressProps } from './Address';
|
|
5
|
-
import * as style from './index.module.less';
|
|
6
|
-
|
|
7
|
-
export interface UserRank extends UserAddressProps {
|
|
8
|
-
id: number | string;
|
|
9
|
-
name: string;
|
|
10
|
-
avatar?: string;
|
|
11
|
-
score: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface UserRankViewProps extends RowProps {
|
|
15
|
-
title: string;
|
|
16
|
-
rank: UserRank[];
|
|
17
|
-
linkOf?: (user: UserRank) => string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class UserRankView extends PureComponent<UserRankViewProps> {
|
|
21
|
-
static displayName = 'UserRankView';
|
|
22
|
-
|
|
23
|
-
renderMedal = (user: UserRank) => (
|
|
24
|
-
<Col key={user.id} as="li">
|
|
25
|
-
<div
|
|
26
|
-
|
|
27
|
-
>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
</
|
|
103
|
-
</
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
</Row>
|
|
110
|
-
</Col>
|
|
111
|
-
<Col xs={12} sm={12} lg={5}>
|
|
112
|
-
<Table
|
|
113
|
-
className={`my-3 pt-2 ${style.restUsers}`}
|
|
114
|
-
responsive
|
|
115
|
-
>
|
|
116
|
-
<tbody>{rank.slice(3, 10).map(this.renderRow)}</tbody>
|
|
117
|
-
</Table>
|
|
118
|
-
</Col>
|
|
119
|
-
</Row>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
1
|
+
import { PureComponent } from 'react';
|
|
2
|
+
import { Badge, Col, Image, Row, RowProps, Table } from 'react-bootstrap';
|
|
3
|
+
|
|
4
|
+
import { UserAddress, UserAddressProps } from './Address';
|
|
5
|
+
import * as style from './index.module.less';
|
|
6
|
+
|
|
7
|
+
export interface UserRank extends UserAddressProps {
|
|
8
|
+
id: number | string;
|
|
9
|
+
name: string;
|
|
10
|
+
avatar?: string;
|
|
11
|
+
score: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface UserRankViewProps extends RowProps {
|
|
15
|
+
title: string;
|
|
16
|
+
rank: UserRank[];
|
|
17
|
+
linkOf?: (user: UserRank) => string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class UserRankView extends PureComponent<UserRankViewProps> {
|
|
21
|
+
static displayName = 'UserRankView';
|
|
22
|
+
|
|
23
|
+
renderMedal = (user: UserRank) => (
|
|
24
|
+
<Col key={user.id} as="li">
|
|
25
|
+
<div className={`shadow-lg overflow-hidden rounded-circle m-auto ${style.image}`}>
|
|
26
|
+
<Image src={user.avatar} alt={user.name} loading="lazy" fluid />
|
|
27
|
+
</div>
|
|
28
|
+
<div className={`position-relative overflow-hidden ${style.topUser}`}>
|
|
29
|
+
<div className="position-relative">
|
|
30
|
+
<i className="d-block overflow-hidden m-auto mb-1 rounded-circle" />
|
|
31
|
+
<a
|
|
32
|
+
className="d-block mb-0 stretched-link"
|
|
33
|
+
href={this.props.linkOf?.(user) || '#'}
|
|
34
|
+
>
|
|
35
|
+
{user.name}
|
|
36
|
+
</a>
|
|
37
|
+
<strong>{user.score}</strong>
|
|
38
|
+
</div>
|
|
39
|
+
<UserAddress {...user} />
|
|
40
|
+
</div>
|
|
41
|
+
</Col>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
renderRow = (user: UserRank, index: number, { length }: UserRank[]) => (
|
|
45
|
+
<tr key={user.id} className="position-relative">
|
|
46
|
+
<td className="align-middle">
|
|
47
|
+
<Badge className="fw-bold fst-italic">
|
|
48
|
+
{(index + 4 + '').padStart((length + '').length, '0')}
|
|
49
|
+
</Badge>
|
|
50
|
+
</td>
|
|
51
|
+
<td className={`position-relative mw-50 text-truncate ${style.name}`}>
|
|
52
|
+
<div
|
|
53
|
+
className={`d-inline-block overflow-hidden align-middle rounded-circle ${style.image}`}
|
|
54
|
+
>
|
|
55
|
+
<Image src={user.avatar} alt={user.name} loading="lazy" fluid />
|
|
56
|
+
</div>
|
|
57
|
+
<a
|
|
58
|
+
className="ms-2 d-inline-block align-middle stretched-link"
|
|
59
|
+
style={{
|
|
60
|
+
color: `rgb(248, ${(index + 2) * 15}, ${(index + 2) * 35})`
|
|
61
|
+
}}
|
|
62
|
+
href={this.props.linkOf?.(user) || '#'}
|
|
63
|
+
>
|
|
64
|
+
{user.name}
|
|
65
|
+
</a>
|
|
66
|
+
</td>
|
|
67
|
+
<td className="align-middle">{user.score}</td>
|
|
68
|
+
<td className="align-middle">
|
|
69
|
+
<UserAddress {...user} />
|
|
70
|
+
</td>
|
|
71
|
+
</tr>
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
render() {
|
|
75
|
+
const { className = '', title, rank = [], linkOf, ...props } = this.props;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Row className={`${style.rankBox} ${className}`} {...props}>
|
|
79
|
+
<Col sm={12} xs={12} lg={7}>
|
|
80
|
+
<div className={`shadow rounded-3 ${style.title}`}>
|
|
81
|
+
<div className={style.medal}>
|
|
82
|
+
<i className="d-inline-block ms-1 overflow-hidden rounded-circle" />
|
|
83
|
+
<i className="d-inline-block ms-1 overflow-hidden rounded-circle" />
|
|
84
|
+
<i className="d-inline-block ms-1 overflow-hidden rounded-circle" />
|
|
85
|
+
</div>
|
|
86
|
+
<h3
|
|
87
|
+
data-text={title}
|
|
88
|
+
className="position-relative m-auto mb-0 fw-bold text-center"
|
|
89
|
+
>
|
|
90
|
+
{title}
|
|
91
|
+
</h3>
|
|
92
|
+
</div>
|
|
93
|
+
<Row
|
|
94
|
+
as="ul"
|
|
95
|
+
className={`mt-2 g-0 align-items-end text-center ps-0 pt-2 list-unstyled ${style.topUsers}`}
|
|
96
|
+
>
|
|
97
|
+
{rank.slice(0, 3).map(this.renderMedal)}
|
|
98
|
+
</Row>
|
|
99
|
+
</Col>
|
|
100
|
+
<Col xs={12} sm={12} lg={5}>
|
|
101
|
+
<Table className={`my-3 pt-2 ${style.restUsers}`} responsive>
|
|
102
|
+
<tbody>{rank.slice(3, 10).map(this.renderRow)}</tbody>
|
|
103
|
+
</Table>
|
|
104
|
+
</Col>
|
|
105
|
+
</Row>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
@keyframes scrollItem {
|
|
2
|
-
0%,
|
|
3
|
-
10% {
|
|
4
|
-
transform: translateY(0);
|
|
5
|
-
}
|
|
6
|
-
90%,
|
|
7
|
-
100% {
|
|
8
|
-
transform: translateY(-100%);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
@keyframes scrollWrap {
|
|
12
|
-
0%,
|
|
13
|
-
10% {
|
|
14
|
-
transform: translateY(0);
|
|
15
|
-
}
|
|
16
|
-
90%,
|
|
17
|
-
100% {
|
|
18
|
-
transform: translateY(100%);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.scrollWrap {
|
|
23
|
-
--duration: 10s;
|
|
24
|
-
animation: scrollWrap;
|
|
25
|
-
animation-duration: var(--duration);
|
|
26
|
-
animation-timing-function: linear;
|
|
27
|
-
animation-iteration-count: infinite;
|
|
28
|
-
animation-direction: alternate;
|
|
29
|
-
font-size: 0;
|
|
30
|
-
&:hover {
|
|
31
|
-
animation-play-state: paused;
|
|
32
|
-
.scrollItem {
|
|
33
|
-
animation-play-state: paused;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
.scrollItem {
|
|
37
|
-
animation: scrollItem;
|
|
38
|
-
animation-duration: var(--duration);
|
|
39
|
-
animation-timing-function: linear;
|
|
40
|
-
animation-iteration-count: infinite;
|
|
41
|
-
animation-direction: alternate;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
@keyframes scrollItem {
|
|
2
|
+
0%,
|
|
3
|
+
10% {
|
|
4
|
+
transform: translateY(0);
|
|
5
|
+
}
|
|
6
|
+
90%,
|
|
7
|
+
100% {
|
|
8
|
+
transform: translateY(-100%);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
@keyframes scrollWrap {
|
|
12
|
+
0%,
|
|
13
|
+
10% {
|
|
14
|
+
transform: translateY(0);
|
|
15
|
+
}
|
|
16
|
+
90%,
|
|
17
|
+
100% {
|
|
18
|
+
transform: translateY(100%);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.scrollWrap {
|
|
23
|
+
--duration: 10s;
|
|
24
|
+
animation: scrollWrap;
|
|
25
|
+
animation-duration: var(--duration);
|
|
26
|
+
animation-timing-function: linear;
|
|
27
|
+
animation-iteration-count: infinite;
|
|
28
|
+
animation-direction: alternate;
|
|
29
|
+
font-size: 0;
|
|
30
|
+
&:hover {
|
|
31
|
+
animation-play-state: paused;
|
|
32
|
+
.scrollItem {
|
|
33
|
+
animation-play-state: paused;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
.scrollItem {
|
|
37
|
+
animation: scrollItem;
|
|
38
|
+
animation-duration: var(--duration);
|
|
39
|
+
animation-timing-function: linear;
|
|
40
|
+
animation-iteration-count: infinite;
|
|
41
|
+
animation-direction: alternate;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react';
|
|
2
|
-
|
|
3
|
-
import * as style from './index.module.less';
|
|
4
|
-
|
|
5
|
-
export interface VerticalMarqueeProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
-
duration?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const VerticalMarquee: FC<VerticalMarqueeProps> = ({
|
|
10
|
-
className = '',
|
|
11
|
-
children,
|
|
12
|
-
duration,
|
|
13
|
-
...props
|
|
14
|
-
}) => (
|
|
15
|
-
<div className={`overflow-hidden ${className}`} {...props}>
|
|
16
|
-
<div
|
|
17
|
-
className={`d-inline-block mw-100 mh-100 ${style.scrollWrap}`}
|
|
18
|
-
// @ts-expect-error remove after React 19 released
|
|
19
|
-
style={{ '--duration': duration }}
|
|
20
|
-
>
|
|
21
|
-
<div className={`d-inline-block ${style.scrollItem}`}>
|
|
22
|
-
{children}
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
VerticalMarquee.displayName = 'VerticalMarquee';
|
|
1
|
+
import { FC, HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
import * as style from './index.module.less';
|
|
4
|
+
|
|
5
|
+
export interface VerticalMarqueeProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
duration?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const VerticalMarquee: FC<VerticalMarqueeProps> = ({
|
|
10
|
+
className = '',
|
|
11
|
+
children,
|
|
12
|
+
duration,
|
|
13
|
+
...props
|
|
14
|
+
}) => (
|
|
15
|
+
<div className={`overflow-hidden ${className}`} {...props}>
|
|
16
|
+
<div
|
|
17
|
+
className={`d-inline-block mw-100 mh-100 ${style.scrollWrap}`}
|
|
18
|
+
// @ts-expect-error remove after React 19 released
|
|
19
|
+
style={{ '--duration': duration }}
|
|
20
|
+
>
|
|
21
|
+
<div className={`d-inline-block ${style.scrollItem}`}>
|
|
22
|
+
{children}
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
VerticalMarquee.displayName = 'VerticalMarquee';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FC, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export const ZodiacSigns = ['🐵', '🐔', '🐶', '🐷', '🐭', '🐮', '🐯', '🐰', '🐲', '🐍', '🐴', '🐐'];
|
|
4
|
+
|
|
5
|
+
export const zodiacOf = (year: number) => {
|
|
6
|
+
// Historical year numbering has no year 0: 1 BCE is represented as year -1.
|
|
7
|
+
const astronomicalYear = year < 0 ? year + 1 : year;
|
|
8
|
+
|
|
9
|
+
return ZodiacSigns[((astronomicalYear % 12) + 12) % 12];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export interface ZodiacBarProps extends HTMLAttributes<HTMLOListElement> {
|
|
13
|
+
itemClassName?: string;
|
|
14
|
+
startYear: number;
|
|
15
|
+
endYear?: number;
|
|
16
|
+
itemOf?: (year: number, zodiac: string) => { link?: string; title?: ReactNode };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ZodiacBar: FC<ZodiacBarProps> = ({
|
|
20
|
+
className = '',
|
|
21
|
+
itemClassName = 'border rounded px-4 py-3 d-flex flex-column justify-content-center align-items-center',
|
|
22
|
+
startYear,
|
|
23
|
+
endYear = new Date().getFullYear(),
|
|
24
|
+
itemOf,
|
|
25
|
+
...props
|
|
26
|
+
}) => (
|
|
27
|
+
<ol
|
|
28
|
+
className={`list-unstyled m-0 d-flex flex-wrap justify-content-center gap-3 ${className}`}
|
|
29
|
+
{...props}
|
|
30
|
+
>
|
|
31
|
+
{Array.from({ length: endYear - startYear + 1 }, (_, index) => {
|
|
32
|
+
const year = endYear - index;
|
|
33
|
+
|
|
34
|
+
if (year === 0) return null;
|
|
35
|
+
|
|
36
|
+
const zodiac = zodiacOf(year);
|
|
37
|
+
const { link = '#', title } = itemOf?.(year, zodiac) || {};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<li key={year} className={itemClassName}>
|
|
41
|
+
<a className="d-inline-block p-3 text-decoration-none text-center" href={link}>
|
|
42
|
+
<div className="fs-1">{zodiac}</div>
|
|
43
|
+
|
|
44
|
+
{title}
|
|
45
|
+
</a>
|
|
46
|
+
</li>
|
|
47
|
+
);
|
|
48
|
+
})}
|
|
49
|
+
</ol>
|
|
50
|
+
);
|
|
51
|
+
ZodiacBar.displayName = 'ZodiacBar';
|
package/source/index.ts
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
export * from './animate';
|
|
2
|
-
export * from './Avatar';
|
|
3
|
-
export * from './ClickBoundary';
|
|
4
|
-
export * from './CodeBlock';
|
|
5
|
-
export * from './color';
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './
|
|
22
|
-
export * from './
|
|
23
|
-
export * from './
|
|
24
|
-
export * from './
|
|
25
|
-
export * from './
|
|
1
|
+
export * from './animate';
|
|
2
|
+
export * from './Avatar';
|
|
3
|
+
export * from './ClickBoundary';
|
|
4
|
+
export * from './CodeBlock';
|
|
5
|
+
export * from './color';
|
|
6
|
+
export * from './Countdown';
|
|
7
|
+
export * from './Dialog';
|
|
8
|
+
export * from './Editor';
|
|
9
|
+
export * from './EditorHTML';
|
|
10
|
+
export * from './HorizontalMarquee';
|
|
11
|
+
export * from './Icon';
|
|
12
|
+
export * from './LiveTSX';
|
|
13
|
+
export * from './Loading';
|
|
14
|
+
export * from './MonthCalendar';
|
|
15
|
+
export * from './Nameplate';
|
|
16
|
+
export * from './OverlayBox';
|
|
17
|
+
export * from './PageNav';
|
|
18
|
+
export * from './Select';
|
|
19
|
+
export * from './ShareBox';
|
|
20
|
+
export * from './SpinnerButton';
|
|
21
|
+
export * from './TableSpinner';
|
|
22
|
+
export * from './Time';
|
|
23
|
+
export * from './TimeDistance';
|
|
24
|
+
export * from './Timeline';
|
|
25
|
+
export * from './TypeEcho';
|
|
26
|
+
export * from './UserRank';
|
|
27
|
+
export * from './VerticalMarquee';
|
|
28
|
+
export * from './ZodiacBar';
|
package/tsconfig.build.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"emitDeclarationOnly": true,
|
|
6
|
-
"noEmit": false,
|
|
7
|
-
"outDir": "dist"
|
|
8
|
-
},
|
|
9
|
-
"include": ["source/**/*"],
|
|
10
|
-
"exclude": ["source/stories/*"]
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"emitDeclarationOnly": true,
|
|
6
|
+
"noEmit": false,
|
|
7
|
+
"outDir": "dist"
|
|
8
|
+
},
|
|
9
|
+
"include": ["source/**/*"],
|
|
10
|
+
"exclude": ["source/stories/*"]
|
|
11
|
+
}
|
package/tsconfig.json
CHANGED
package/eslint.config.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { fixupPluginRules } from '@eslint/compat';
|
|
2
|
-
import eslint from '@eslint/js';
|
|
3
|
-
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
4
|
-
import reactPlugin from 'eslint-plugin-react';
|
|
5
|
-
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
|
|
6
|
-
import globals from 'globals';
|
|
7
|
-
import tsEslint from 'typescript-eslint';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
|
-
|
|
10
|
-
const tsconfigRootDir = fileURLToPath(new URL('.', import.meta.url));
|
|
11
|
-
|
|
12
|
-
export default tsEslint.config(
|
|
13
|
-
// register all of the plugins up-front
|
|
14
|
-
{
|
|
15
|
-
plugins: {
|
|
16
|
-
'@typescript-eslint': tsEslint.plugin,
|
|
17
|
-
react: fixupPluginRules(reactPlugin),
|
|
18
|
-
'simple-import-sort': simpleImportSortPlugin
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
// config with just ignores is the replacement for `.eslintignore`
|
|
22
|
-
{ ignores: ['**/node_modules/**', '**/dist/**', '**/.parcel-cache/**'] },
|
|
23
|
-
|
|
24
|
-
// extends ...
|
|
25
|
-
eslint.configs.recommended,
|
|
26
|
-
...tsEslint.configs.recommended,
|
|
27
|
-
|
|
28
|
-
// base config
|
|
29
|
-
{
|
|
30
|
-
languageOptions: {
|
|
31
|
-
globals: { ...globals.es2020, ...globals.browser, ...globals.node },
|
|
32
|
-
parserOptions: {
|
|
33
|
-
projectService: true,
|
|
34
|
-
tsconfigRootDir,
|
|
35
|
-
warnOnUnsupportedTypeScriptVersion: false
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
rules: {
|
|
39
|
-
'simple-import-sort/exports': 'error',
|
|
40
|
-
'simple-import-sort/imports': 'error',
|
|
41
|
-
'react/jsx-no-target-blank': 'warn',
|
|
42
|
-
'react/jsx-sort-props': [
|
|
43
|
-
'error',
|
|
44
|
-
{
|
|
45
|
-
reservedFirst: true,
|
|
46
|
-
shorthandLast: true,
|
|
47
|
-
callbacksLast: true,
|
|
48
|
-
noSortAlphabetically: true
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
'@typescript-eslint/no-unused-vars': 'warn',
|
|
52
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
53
|
-
'@typescript-eslint/no-empty-object-type': 'off',
|
|
54
|
-
'@typescript-eslint/no-unsafe-declaration-merging': 'warn'
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
files: ['**/*.js'],
|
|
59
|
-
extends: [tsEslint.configs.disableTypeChecked],
|
|
60
|
-
rules: {
|
|
61
|
-
// turn off other type-aware rules
|
|
62
|
-
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
|
|
63
|
-
|
|
64
|
-
// turn off rules that don't apply to JS code
|
|
65
|
-
'@typescript-eslint/explicit-function-return-type': 'off'
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
eslintConfigPrettier
|
|
69
|
-
);
|