Skip to content

Commit 8804de4

Browse files
authored
upgrade father, fix eslint and prettier (#241)
* upgrade father, fix eslint and prettier * use father * upgrade father
1 parent 2060372 commit 8804de4

17 files changed

+98
-91
lines changed

.eslintrc.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
const base = require('@umijs/fabric/dist/eslint');
2-
31
module.exports = {
4-
...base,
2+
extends: [require.resolve('@umijs/fabric/dist/eslint')],
53
rules: {
6-
...base.rules,
74
'default-case': 0,
85
'import/no-extraneous-dependencies': 0,
96
'react/no-find-dom-node': 0,

examples/case.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint no-console:0 */
22

33
import React from 'react';
4-
import { CSSMotionProps } from 'rc-motion';
5-
import Trigger, { BuildInPlacements } from '../src';
4+
import type { CSSMotionProps } from 'rc-motion';
5+
import type { BuildInPlacements } from '../src';
6+
import Trigger from '../src';
67
import './case.less';
78

89
const builtinPlacements: BuildInPlacements = {
@@ -202,7 +203,7 @@ const Demo = () => {
202203
maskMotion={motion ? MaskMotion : null}
203204
maskClosable={maskClosable}
204205
stretch={stretch}
205-
action={Object.keys(actions).filter(action => actions[action])}
206+
action={Object.keys(actions).filter((action) => actions[action])}
206207
builtinPlacements={builtinPlacements}
207208
forceRender={forceRender}
208209
popupStyle={{

examples/click-nested.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,7 @@ const popupBorderStyle = {
3737
background: 'rgba(255, 0, 0, 0.1)',
3838
};
3939

40-
function saveRef(name, component) {
41-
this[name] = component;
42-
}
43-
4440
class Test extends React.Component {
45-
constructor(props) {
46-
super(props);
47-
48-
this.saveContainerRef = saveRef.bind(this, 'containerInstance');
49-
}
50-
5141
render() {
5242
return (
5343
<div style={{ margin: 200 }}>
@@ -68,7 +58,7 @@ class Test extends React.Component {
6858
i am a click popup{' '}
6959
<button
7060
type="button"
71-
onMouseDown={e => {
61+
onMouseDown={(e) => {
7262
e.stopPropagation();
7363
e.preventDefault();
7464
}}

examples/nested.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,10 @@ const popupBorderStyle = {
3636
padding: 10,
3737
};
3838

39-
function saveRef(name, component) {
40-
this[name] = component;
41-
}
42-
4339
class Test extends React.Component {
44-
constructor(props) {
45-
super(props);
46-
47-
this.saveContainerRef = saveRef.bind(this, 'containerInstance');
48-
}
40+
saveContainerRef = (node) => {
41+
this.containerInstanceNode = node;
42+
};
4943

5044
render() {
5145
const innerTrigger = (
@@ -55,7 +49,7 @@ class Test extends React.Component {
5549
popupPlacement="bottom"
5650
action={['click']}
5751
builtinPlacements={builtinPlacements}
58-
getPopupContainer={() => this.containerInstance}
52+
getPopupContainer={() => this.containerInstanceNode}
5953
popup={<div style={popupBorderStyle}>I am inner Trigger Popup</div>}
6054
>
6155
<span href="#" style={{ margin: 20 }}>

examples/simple.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function getPopupContainer(trigger) {
3535
return trigger.parentNode;
3636
}
3737

38-
const InnerTarget = props => (
38+
const InnerTarget = (props) => (
3939
<div
4040
style={{
4141
margin: 20,
@@ -78,7 +78,7 @@ interface TestState {
7878
mobile?: boolean;
7979
}
8080

81-
class Test extends React.Component<{}, TestState> {
81+
class Test extends React.Component<any, TestState> {
8282
state: TestState = {
8383
mask: true,
8484
maskClosable: true,
@@ -92,19 +92,19 @@ class Test extends React.Component<{}, TestState> {
9292
transitionName: 'rc-trigger-popup-zoom',
9393
};
9494

95-
onPlacementChange = e => {
95+
onPlacementChange = (e) => {
9696
this.setState({
9797
placement: e.target.value,
9898
});
9999
};
100100

101-
onStretch = e => {
101+
onStretch = (e) => {
102102
this.setState({
103103
stretch: e.target.value,
104104
});
105105
};
106106

107-
onTransitionChange = e => {
107+
onTransitionChange = (e) => {
108108
this.setState({
109109
transitionName: e.target.checked ? e.target.value : '',
110110
});
@@ -126,31 +126,31 @@ class Test extends React.Component<{}, TestState> {
126126
});
127127
};
128128

129-
onOffsetXChange = e => {
129+
onOffsetXChange = (e) => {
130130
const targetValue = e.target.value;
131131
this.setState({
132132
offsetX: targetValue || undefined,
133133
});
134134
};
135135

136-
onOffsetYChange = e => {
136+
onOffsetYChange = (e) => {
137137
const targetValue = e.target.value;
138138
this.setState({
139139
offsetY: targetValue || undefined,
140140
});
141141
};
142142

143-
onVisibleChange = visible => {
143+
onVisibleChange = (visible) => {
144144
console.log('tooltip', visible);
145145
};
146146

147-
onMask = e => {
147+
onMask = (e) => {
148148
this.setState({
149149
mask: e.target.checked,
150150
});
151151
};
152152

153-
onMaskClosable = e => {
153+
onMaskClosable = (e) => {
154154
this.setState({
155155
maskClosable: e.target.checked,
156156
});
@@ -173,13 +173,13 @@ class Test extends React.Component<{}, TestState> {
173173
});
174174
};
175175

176-
destroyPopupOnHide = e => {
176+
destroyPopupOnHide = (e) => {
177177
this.setState({
178178
destroyPopupOnHide: e.target.checked,
179179
});
180180
};
181181

182-
autoDestroy = e => {
182+
autoDestroy = (e) => {
183183
this.setState({
184184
autoDestroy: e.target.checked,
185185
});
@@ -374,7 +374,7 @@ class Test extends React.Component<{}, TestState> {
374374
background: '#FFF',
375375
textAlign: 'center',
376376
},
377-
popupRender: node => (
377+
popupRender: (node) => (
378378
<>
379379
<div>
380380
<input

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@
5050
"enzyme-adapter-react-16": "^1.14.0",
5151
"enzyme-to-json": "^3.4.0",
5252
"eslint": "^7.0.0",
53-
"father": "^2.13.2",
53+
"father": "^2.30.2",
5454
"np": "^6.2.0",
5555
"react": "^16.0.0",
5656
"react-dom": "^16.0.0",
5757
"regenerator-runtime": "^0.13.7",
58-
"typescript": "^3.5.2"
58+
"typescript": "^4.0.0"
5959
},
6060
"dependencies": {
6161
"@babel/runtime": "^7.11.2",

src/Popup/Mask.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
3-
import CSSMotion, { CSSMotionProps } from 'rc-motion';
4-
import { TransitionNameType, AnimationType } from '../interface';
3+
import type { CSSMotionProps } from 'rc-motion';
4+
import CSSMotion from 'rc-motion';
5+
import type { TransitionNameType, AnimationType } from '../interface';
56
import { getMotion } from '../utils/legacyUtil';
67

78
export interface MaskProps {

src/Popup/MobilePopupInner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from 'react';
22
import CSSMotion from 'rc-motion';
33
import classNames from 'classnames';
4-
import { PopupInnerProps, PopupInnerRef } from './PopupInner';
5-
import { MobileConfig } from '../interface';
4+
import type { PopupInnerProps, PopupInnerRef } from './PopupInner';
5+
import type { MobileConfig } from '../interface';
66

77
interface MobilePopupInnerProps extends PopupInnerProps {
88
mobile?: MobileConfig;

src/Popup/PopupInner.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import * as React from 'react';
22
import { useRef, useState } from 'react';
33
import Align from 'rc-align';
4-
import { RefAlign } from 'rc-align/lib/Align';
5-
import CSSMotion, { CSSMotionProps, MotionEndEventHandler } from 'rc-motion';
4+
import type { RefAlign } from 'rc-align/lib/Align';
5+
import type { CSSMotionProps, MotionEndEventHandler } from 'rc-motion';
6+
import CSSMotion from 'rc-motion';
67
import classNames from 'classnames';
7-
import {
8+
import type {
89
Point,
910
AlignType,
1011
StretchType,
@@ -97,7 +98,7 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
9798
const [status, goNextStatus] = useVisibleStatus(visible, doMeasure);
9899

99100
// ======================== Aligns ========================
100-
const prepareResolveRef = useRef<Function>();
101+
const prepareResolveRef = useRef<(value?: unknown) => void>();
101102

102103
// `target` on `rc-align` can accept as a function to get the bind element or a point.
103104
// ref: https://www.npmjs.com/package/rc-align
@@ -134,7 +135,7 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
134135

135136
// ======================== Motion ========================
136137
const motion = { ...getMotion(props) };
137-
['onAppearEnd', 'onEnterEnd', 'onLeaveEnd'].forEach(eventName => {
138+
['onAppearEnd', 'onEnterEnd', 'onLeaveEnd'].forEach((eventName) => {
138139
const originHandler: MotionEndEventHandler = motion[eventName];
139140
motion[eventName] = (element, event) => {
140141
goNextStatus();
@@ -143,7 +144,7 @@ const PopupInner = React.forwardRef<PopupInnerRef, PopupInnerProps>(
143144
});
144145

145146
function onShowPrepare() {
146-
return new Promise(resolve => {
147+
return new Promise((resolve) => {
147148
prepareResolveRef.current = resolve;
148149
});
149150
}

src/Popup/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from 'react';
22
import { useState, useEffect } from 'react';
3-
import { CSSMotionProps } from 'rc-motion';
3+
import type { CSSMotionProps } from 'rc-motion';
44
import isMobile from 'rc-util/lib/isMobile';
5-
import {
5+
import type {
66
StretchType,
77
AlignType,
88
TransitionNameType,
@@ -11,7 +11,8 @@ import {
1111
MobileConfig,
1212
} from '../interface';
1313
import Mask from './Mask';
14-
import PopupInner, { PopupInnerRef } from './PopupInner';
14+
import type { PopupInnerRef } from './PopupInner';
15+
import PopupInner from './PopupInner';
1516
import MobilePopupInner from './MobilePopupInner';
1617

1718
export interface PopupProps {
@@ -61,7 +62,7 @@ const Popup = React.forwardRef<PopupInnerRef, PopupProps>(
6162
if (visible && mobile) {
6263
setInMobile(isMobile());
6364
}
64-
}, [visible, !!mobile]);
65+
}, [visible, mobile]);
6566

6667
const popupNode: React.ReactNode = inMobile ? (
6768
<MobilePopupInner {...cloneProps} mobile={mobile} ref={ref} />

0 commit comments

Comments
 (0)