idea-react 2.0.0-rc.11 → 2.0.0-rc.12
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/dist/index.css.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/source/Dialog.tsx +41 -41
- package/source/Editor.tsx +46 -46
- package/source/HorizontalMarquee/index.module.less +52 -52
- package/source/HorizontalMarquee/index.tsx +67 -67
- package/source/Loading.tsx +21 -21
- 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 +14 -14
- package/source/TimeDistance.tsx +41 -41
- package/source/Timeline/index.module.less +53 -53
- package/source/TypeEcho.tsx +49 -49
- package/source/VerticalMarquee/index.module.less +43 -43
- package/source/VerticalMarquee/index.tsx +27 -27
- package/source/index.ts +25 -25
- package/tsconfig.build.json +11 -11
- package/eslint.config.ts +0 -69
package/source/TimeDistance.tsx
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { FC, HTMLAttributes } from 'react';
|
|
2
|
-
import { diffTime, TimeData } from 'web-utility';
|
|
3
|
-
|
|
4
|
-
export interface TimeDistanceProps extends HTMLAttributes<HTMLTimeElement> {
|
|
5
|
-
date: TimeData;
|
|
6
|
-
unitWords?: Record<string, string>;
|
|
7
|
-
beforeWord?: string;
|
|
8
|
-
afterWord?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const UnitWords = {
|
|
12
|
-
ms: 'millisecond(s)',
|
|
13
|
-
s: 'second(s)',
|
|
14
|
-
m: 'minute(s)',
|
|
15
|
-
H: 'hour(s)',
|
|
16
|
-
D: 'day(s)',
|
|
17
|
-
W: 'week(s)',
|
|
18
|
-
M: 'month(s)',
|
|
19
|
-
Y: 'year(s)'
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const TimeDistance: FC<TimeDistanceProps> = ({
|
|
23
|
-
date,
|
|
24
|
-
unitWords = UnitWords,
|
|
25
|
-
beforeWord = ' before',
|
|
26
|
-
afterWord = ' after',
|
|
27
|
-
...props
|
|
28
|
-
}) => {
|
|
29
|
-
date = new Date(date);
|
|
30
|
-
|
|
31
|
-
const { distance, unit } = diffTime(date);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<time {...props} dateTime={date.toJSON()} title={date.toLocaleString()}>
|
|
35
|
-
{Math.abs(distance)} {unitWords[unit]}
|
|
36
|
-
{distance < 0 ? beforeWord : afterWord}
|
|
37
|
-
</time>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
TimeDistance.displayName = 'TimeDistance';
|
|
1
|
+
import { FC, HTMLAttributes } from 'react';
|
|
2
|
+
import { diffTime, TimeData } from 'web-utility';
|
|
3
|
+
|
|
4
|
+
export interface TimeDistanceProps extends HTMLAttributes<HTMLTimeElement> {
|
|
5
|
+
date: TimeData;
|
|
6
|
+
unitWords?: Record<string, string>;
|
|
7
|
+
beforeWord?: string;
|
|
8
|
+
afterWord?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const UnitWords = {
|
|
12
|
+
ms: 'millisecond(s)',
|
|
13
|
+
s: 'second(s)',
|
|
14
|
+
m: 'minute(s)',
|
|
15
|
+
H: 'hour(s)',
|
|
16
|
+
D: 'day(s)',
|
|
17
|
+
W: 'week(s)',
|
|
18
|
+
M: 'month(s)',
|
|
19
|
+
Y: 'year(s)'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const TimeDistance: FC<TimeDistanceProps> = ({
|
|
23
|
+
date,
|
|
24
|
+
unitWords = UnitWords,
|
|
25
|
+
beforeWord = ' before',
|
|
26
|
+
afterWord = ' after',
|
|
27
|
+
...props
|
|
28
|
+
}) => {
|
|
29
|
+
date = new Date(date);
|
|
30
|
+
|
|
31
|
+
const { distance, unit } = diffTime(date);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<time {...props} dateTime={date.toJSON()} title={date.toLocaleString()}>
|
|
35
|
+
{Math.abs(distance)} {unitWords[unit]}
|
|
36
|
+
{distance < 0 ? beforeWord : afterWord}
|
|
37
|
+
</time>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
TimeDistance.displayName = 'TimeDistance';
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
.timeline {
|
|
2
|
-
position: relative;
|
|
3
|
-
margin: 0 auto;
|
|
4
|
-
max-width: 50%;
|
|
5
|
-
@media (max-width: 991px) {
|
|
6
|
-
max-width: 100%;
|
|
7
|
-
}
|
|
8
|
-
&::after {
|
|
9
|
-
position: absolute;
|
|
10
|
-
top: 0;
|
|
11
|
-
bottom: 0;
|
|
12
|
-
left: 10px;
|
|
13
|
-
margin-left: -3px;
|
|
14
|
-
background-color: #fff;
|
|
15
|
-
width: 3px;
|
|
16
|
-
content: '';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
.timelineItem {
|
|
20
|
-
position: relative;
|
|
21
|
-
background-color: inherit;
|
|
22
|
-
width: 100%;
|
|
23
|
-
|
|
24
|
-
&::after {
|
|
25
|
-
position: absolute;
|
|
26
|
-
top: 18px;
|
|
27
|
-
right: 1px;
|
|
28
|
-
z-index: 1;
|
|
29
|
-
border-radius: 50%;
|
|
30
|
-
background-color: #fff;
|
|
31
|
-
width: 17px;
|
|
32
|
-
height: 17px;
|
|
33
|
-
content: '';
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
.right {
|
|
37
|
-
left: auto;
|
|
38
|
-
padding: 0px 0px 20px 40px;
|
|
39
|
-
|
|
40
|
-
&::before {
|
|
41
|
-
position: absolute;
|
|
42
|
-
top: 18px;
|
|
43
|
-
left: 30px;
|
|
44
|
-
z-index: 1;
|
|
45
|
-
border: medium solid #fff;
|
|
46
|
-
border-width: 10px 10px 10px 0;
|
|
47
|
-
border-color: transparent #fff transparent transparent;
|
|
48
|
-
content: ' ';
|
|
49
|
-
}
|
|
50
|
-
&::after {
|
|
51
|
-
left: 0;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
.timeline {
|
|
2
|
+
position: relative;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
max-width: 50%;
|
|
5
|
+
@media (max-width: 991px) {
|
|
6
|
+
max-width: 100%;
|
|
7
|
+
}
|
|
8
|
+
&::after {
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: 0;
|
|
11
|
+
bottom: 0;
|
|
12
|
+
left: 10px;
|
|
13
|
+
margin-left: -3px;
|
|
14
|
+
background-color: #fff;
|
|
15
|
+
width: 3px;
|
|
16
|
+
content: '';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
.timelineItem {
|
|
20
|
+
position: relative;
|
|
21
|
+
background-color: inherit;
|
|
22
|
+
width: 100%;
|
|
23
|
+
|
|
24
|
+
&::after {
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: 18px;
|
|
27
|
+
right: 1px;
|
|
28
|
+
z-index: 1;
|
|
29
|
+
border-radius: 50%;
|
|
30
|
+
background-color: #fff;
|
|
31
|
+
width: 17px;
|
|
32
|
+
height: 17px;
|
|
33
|
+
content: '';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
.right {
|
|
37
|
+
left: auto;
|
|
38
|
+
padding: 0px 0px 20px 40px;
|
|
39
|
+
|
|
40
|
+
&::before {
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: 18px;
|
|
43
|
+
left: 30px;
|
|
44
|
+
z-index: 1;
|
|
45
|
+
border: medium solid #fff;
|
|
46
|
+
border-width: 10px 10px 10px 0;
|
|
47
|
+
border-color: transparent #fff transparent transparent;
|
|
48
|
+
content: ' ';
|
|
49
|
+
}
|
|
50
|
+
&::after {
|
|
51
|
+
left: 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/source/TypeEcho.tsx
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import { observable } from 'mobx';
|
|
3
|
-
import { observer } from 'mobx-react';
|
|
4
|
-
import { Component, HTMLAttributes, RefCallback } from 'react';
|
|
5
|
-
import { sleep } from 'web-utility';
|
|
6
|
-
|
|
7
|
-
export interface TypeEchoProps extends HTMLAttributes<HTMLPreElement> {
|
|
8
|
-
text: string;
|
|
9
|
-
intervals?: number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@observer
|
|
13
|
-
export class TypeEcho extends Component<TypeEchoProps> {
|
|
14
|
-
static displayName = 'TypeEcho';
|
|
15
|
-
|
|
16
|
-
@observable
|
|
17
|
-
accessor echoed = '';
|
|
18
|
-
|
|
19
|
-
init: RefCallback<HTMLPreElement> = node =>
|
|
20
|
-
node &&
|
|
21
|
-
new IntersectionObserver(async ([{ isIntersecting }], observer) => {
|
|
22
|
-
if (!isIntersecting) return;
|
|
23
|
-
|
|
24
|
-
observer.disconnect();
|
|
25
|
-
|
|
26
|
-
const { text, intervals = 150 } = this.props;
|
|
27
|
-
|
|
28
|
-
for (const char of text) {
|
|
29
|
-
await sleep(intervals / 1000);
|
|
30
|
-
|
|
31
|
-
this.echoed += char;
|
|
32
|
-
}
|
|
33
|
-
}).observe(node);
|
|
34
|
-
|
|
35
|
-
render() {
|
|
36
|
-
const { className, text, ...props } = this.props,
|
|
37
|
-
{ echoed } = this;
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<pre
|
|
41
|
-
{...props}
|
|
42
|
-
ref={this.init}
|
|
43
|
-
className={classNames('text-wrap', className)}
|
|
44
|
-
>
|
|
45
|
-
{echoed + (echoed === text ? '' : '_')}
|
|
46
|
-
</pre>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { observable } from 'mobx';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import { Component, HTMLAttributes, RefCallback } from 'react';
|
|
5
|
+
import { sleep } from 'web-utility';
|
|
6
|
+
|
|
7
|
+
export interface TypeEchoProps extends HTMLAttributes<HTMLPreElement> {
|
|
8
|
+
text: string;
|
|
9
|
+
intervals?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@observer
|
|
13
|
+
export class TypeEcho extends Component<TypeEchoProps> {
|
|
14
|
+
static displayName = 'TypeEcho';
|
|
15
|
+
|
|
16
|
+
@observable
|
|
17
|
+
accessor echoed = '';
|
|
18
|
+
|
|
19
|
+
init: RefCallback<HTMLPreElement> = node =>
|
|
20
|
+
node &&
|
|
21
|
+
new IntersectionObserver(async ([{ isIntersecting }], observer) => {
|
|
22
|
+
if (!isIntersecting) return;
|
|
23
|
+
|
|
24
|
+
observer.disconnect();
|
|
25
|
+
|
|
26
|
+
const { text, intervals = 150 } = this.props;
|
|
27
|
+
|
|
28
|
+
for (const char of text) {
|
|
29
|
+
await sleep(intervals / 1000);
|
|
30
|
+
|
|
31
|
+
this.echoed += char;
|
|
32
|
+
}
|
|
33
|
+
}).observe(node);
|
|
34
|
+
|
|
35
|
+
render() {
|
|
36
|
+
const { className, text, ...props } = this.props,
|
|
37
|
+
{ echoed } = this;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<pre
|
|
41
|
+
{...props}
|
|
42
|
+
ref={this.init}
|
|
43
|
+
className={classNames('text-wrap', className)}
|
|
44
|
+
>
|
|
45
|
+
{echoed + (echoed === text ? '' : '_')}
|
|
46
|
+
</pre>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -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';
|
package/source/index.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export * from './animate';
|
|
2
|
-
export * from './Avatar';
|
|
3
|
-
export * from './ClickBoundary';
|
|
4
|
-
export * from './CodeBlock';
|
|
5
|
-
export * from './color';
|
|
6
|
-
export * from './Dialog';
|
|
7
|
-
export * from './Editor';
|
|
8
|
-
export * from './EditorHTML';
|
|
9
|
-
export * from './HorizontalMarquee';
|
|
10
|
-
export * from './Icon';
|
|
11
|
-
export * from './Loading';
|
|
12
|
-
export * from './MonthCalendar';
|
|
13
|
-
export * from './Nameplate';
|
|
14
|
-
export * from './OverlayBox';
|
|
15
|
-
export * from './PageNav';
|
|
16
|
-
export * from './Select';
|
|
17
|
-
export * from './ShareBox';
|
|
18
|
-
export * from './SpinnerButton';
|
|
19
|
-
export * from './TableSpinner';
|
|
20
|
-
export * from './Time';
|
|
21
|
-
export * from './TimeDistance';
|
|
22
|
-
export * from './Timeline';
|
|
23
|
-
export * from './TypeEcho';
|
|
24
|
-
export * from './UserRank';
|
|
25
|
-
export * from './VerticalMarquee';
|
|
1
|
+
export * from './animate';
|
|
2
|
+
export * from './Avatar';
|
|
3
|
+
export * from './ClickBoundary';
|
|
4
|
+
export * from './CodeBlock';
|
|
5
|
+
export * from './color';
|
|
6
|
+
export * from './Dialog';
|
|
7
|
+
export * from './Editor';
|
|
8
|
+
export * from './EditorHTML';
|
|
9
|
+
export * from './HorizontalMarquee';
|
|
10
|
+
export * from './Icon';
|
|
11
|
+
export * from './Loading';
|
|
12
|
+
export * from './MonthCalendar';
|
|
13
|
+
export * from './Nameplate';
|
|
14
|
+
export * from './OverlayBox';
|
|
15
|
+
export * from './PageNav';
|
|
16
|
+
export * from './Select';
|
|
17
|
+
export * from './ShareBox';
|
|
18
|
+
export * from './SpinnerButton';
|
|
19
|
+
export * from './TableSpinner';
|
|
20
|
+
export * from './Time';
|
|
21
|
+
export * from './TimeDistance';
|
|
22
|
+
export * from './Timeline';
|
|
23
|
+
export * from './TypeEcho';
|
|
24
|
+
export * from './UserRank';
|
|
25
|
+
export * from './VerticalMarquee';
|
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/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
|
-
);
|