Skip to content

Commit ab73fc9

Browse files
afc163paranoidjk
authored andcommitted
Upgrade tslint (#1051)
* upgrade antd-tools for new tslint * Auto fix tslint errors * fix: tslint * fix: strictNullCheck with defaultProps DefinitelyTyped/DefinitelyTyped#11640 * fix: tslint-fix
1 parent bd7faf6 commit ab73fc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+182
-167
lines changed

components/action-sheet/AndroidContainer.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ActionSheetAndroid extends React.Component<Props, any> {
5050
<TouchableHighlight
5151
style={[ styles.btn ]}
5252
underlayColor={variables.fill_tap}
53-
onPress={() => this.confirm(index) }
53+
onPress={() => this.confirm(index)}
5454
>
5555
<Text style={[ destructiveButtonIndex === index ? styles.destructiveBtn : null ]}>
5656
{item}
@@ -74,7 +74,7 @@ class ActionSheetAndroid extends React.Component<Props, any> {
7474
>
7575
<View>
7676
{titleMsg}
77-
{message && <View style={styles.message} key="1"><Text>{message}</Text></View> }
77+
{message && <View style={styles.message} key="1"><Text>{message}</Text></View>}
7878
<View>{content}</View>
7979
</View>
8080
</Modal>

components/action-sheet/demo/basic.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class Test extends React.Component<any, any> {
1212
}
1313
render() {
1414
return (
15-
<View style={{marginTop: 30}}>
15+
<View style={{ marginTop: 30 }}>
1616
<View style={[{ padding: 8 }]}>
1717
<Button onClick={this.showActionSheet}>默认状态操作列表</Button>
1818
</View>
@@ -65,7 +65,7 @@ export default class Test extends React.Component<any, any> {
6565
} else {
6666
text = '您没有分享';
6767
}
68-
this.setState({text});
68+
this.setState({ text });
6969
});
7070
}
7171
}

components/action-sheet/index.web.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function createActionSheet(flag, config, callback) {
9898
mode = 'share';
9999
const multipleLine = options.length && Array.isArray(options[0]) || false;
100100
const createList = (item, index, rowIndex = 0) => (
101-
<div className={`${prefixCls}-share-list-item`} key={index} onClick={() => cb(index, rowIndex) }>
101+
<div className={`${prefixCls}-share-list-item`} key={index} onClick={() => cb(index, rowIndex)}>
102102
<div className={`${prefixCls}-share-list-item-icon`}>
103103
{item.iconName ? <Icon type={item.iconName}/> : item.icon}
104104
</div>
@@ -149,7 +149,7 @@ function createActionSheet(flag, config, callback) {
149149
>
150150
{children}
151151
</Dialog>,
152-
div
152+
div,
153153
);
154154

155155
return {

components/activity-indicator/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ export default class RNActivityIndicator extends React.Component<PropTypes, any>
2020
const styles = this.props.styles;
2121
return (
2222
<View style={[styles.container]}>
23-
<View style={[styles.innerContainer, { height: 89}]}>
23+
<View style={[styles.innerContainer, { height: 89 }]}>
2424
<View style={[styles.wrapper]}>
2525
<ActivityIndicator
2626
color="white"
2727
size="large"
2828
/>
29-
{ this.props.text && (<Text style={[styles.toast]}>{this.props.text}</Text>) }
29+
{this.props.text && (<Text style={[styles.toast]}>{this.props.text}</Text>)}
3030
</View>
3131
</View>
3232
</View>
@@ -40,7 +40,7 @@ export default class RNActivityIndicator extends React.Component<PropTypes, any>
4040
color={this.props.color}
4141
size={this.props.size}
4242
/>
43-
{ this.props.text && (<Text style={[this.props.styles.tip]}>{this.props.text}</Text>) }
43+
{this.props.text && (<Text style={[this.props.styles.tip]}>{this.props.text}</Text>)}
4444
</View>
4545
);
4646
}

components/activity-indicator/index.web.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ export default class ActivityIndicator extends React.Component<ActivityIndicator
3232
<div className={wrapClass}>
3333
<div className={`${prefixCls}-content`}>
3434
<span className={spinnerClass} />
35-
{ text && (<span className={`${prefixCls}-toast`}>{text}</span>) }
35+
{text && (<span className={`${prefixCls}-toast`}>{text}</span>)}
3636
</div>
3737
</div>
3838
);
3939
} else {
4040
return (
4141
<div className={wrapClass}>
4242
<span className={spinnerClass} />
43-
{ text && (<span className={`${prefixCls}-tip`}>{text}</span>) }
43+
{text && (<span className={`${prefixCls}-tip`}>{text}</span>)}
4444
</div>
4545
);
4646
}

components/badge/index.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
1818
children, text, size, overflowCount, dot, corner, ...restProps, // todo: hot
1919
} = this.props;
2020

21-
text = typeof text === 'number' && text > overflowCount ? `${overflowCount}+` : text;
21+
text = typeof text === 'number' && text > (overflowCount as number) ? `${overflowCount}+` : text;
2222

2323
// dot mode don't need text
2424
if (dot) {
@@ -27,14 +27,14 @@ export default class Badge extends React.Component<BadgeProps, any> {
2727

2828
const badgeCls = corner ? 'textCorner' : 'textDom';
2929
const contentDom = !dot ? (
30-
<View {...restProps} style={ [styles[badgeCls], styles[`${badgeCls}${size}`]] }>
31-
<Text style={ [styles.text] }>{text}</Text>
30+
<View {...restProps} style={[styles[badgeCls], styles[`${badgeCls}${size}`]]}>
31+
<Text style={[styles.text]}>{text}</Text>
3232
</View>
33-
) : <View {...restProps} style={ [styles.dot, styles[`dotSize${size}`] ] } />;
33+
) : <View {...restProps} style={[styles.dot, styles[`dotSize${size}`]]} />;
3434

3535
return (
3636
<View style={[ styles.wrap, style ]}>
37-
<View style={ [styles[`${badgeCls}Wrap`]] }>
37+
<View style={[styles[`${badgeCls}Wrap`]]}>
3838
{children}
3939
{(text || dot) ? contentDom : null}
4040
</View>

components/badge/index.web.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
1616
className, prefixCls,
1717
children, text, size, overflowCount, dot, corner, hot, ...restProps,
1818
} = this.props;
19-
19+
overflowCount = overflowCount as number;
2020
text = typeof text === 'number' && text > overflowCount ? `${overflowCount}+` : text;
2121

2222
// dot mode don't need text
@@ -44,7 +44,7 @@ export default class Badge extends React.Component<BadgeProps, any> {
4444
return (
4545
<span className={badgeCls}>
4646
{children}
47-
{(text || dot) ? <sup className={scrollNumberCls} {...restProps}>{text}</sup> : null}
47+
{(text || dot) && <sup className={scrollNumberCls} {...restProps}>{text}</sup>}
4848
</span>
4949
);
5050
}

components/button/demo/basic.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Button, WhiteSpace, WingBlank } from 'antd-mobile';
66

77
/* tslint:disable:no-console */
88
export default () => (
9-
<View style={{marginTop: 80}}>
9+
<View style={{ marginTop: 80 }}>
1010
<WhiteSpace />
1111
<WingBlank>
1212
<Button onClick={() => { Alert.alert( 'Button', 'button clicked' ); }}>default button</Button>

components/button/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ export default class Button extends React.Component<tsProps, any> {
9797
];
9898

9999
const underlayColor = StyleSheet.flatten(
100-
styles[activeStyle ? `${type}Highlight` : `${type}Raw`]
100+
styles[activeStyle ? `${type}Highlight` : `${type}Raw`],
101101
).backgroundColor;
102102

103103
const indicatorColor = (StyleSheet.flatten(
104-
this.state.pressIn ? styles[`${type}HighlightText`] : styles[`${type}RawText`]
104+
this.state.pressIn ? styles[`${type}HighlightText`] : styles[`${type}RawText`],
105105
) as any).color;
106106

107107
return (

components/card/CardFooter.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class CardFooter extends React.Component<CardFooterProps, any> {
3131
return (
3232
<View style={[styles.footerWrap, style]} {...restProps}>
3333
{contentDom}
34-
{ extra ? extraDom : null }
34+
{extra ? extraDom : null}
3535
</View>
3636
);
3737
}

components/card/CardFooter.web.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class CardFooter extends React.Component <CardFooterProps, any> {
2323
return (
2424
<div className={wrapCls} {...restProps}>
2525
<div className={`${prefixCls}-footer-content`}>{content}</div>
26-
{ extra && <div className={`${prefixCls}-footer-extra`}>{extra}</div> }
26+
{extra && <div className={`${prefixCls}-footer-extra`}>{extra}</div>}
2727
</div>
2828
);
2929
}

components/card/CardHeader.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export default class CardHeader extends React.Component<CardHeaderProps, any> {
3434
return (
3535
<View style={[styles.headerWrap, style]} {...restProps}>
3636
<View style={[styles.headerTitle]}>
37-
{ thumb ? <Image source={{ uri: thumb }} style={[styles.headerImage, thumbStyle]} /> : null }
37+
{thumb ? <Image source={{ uri: thumb }} style={[styles.headerImage, thumbStyle]} /> : null}
3838
{titleDom}
3939
</View>
40-
{ extra ? extraDom : null }
40+
{extra ? extraDom : null}
4141
</View>
4242
);
4343
}

components/card/CardHeader.web.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ export default class CardHeader extends React.Component <CardHeaderProps, any> {
2626
return (
2727
<div className={wrapCls} {...restProps}>
2828
<div className={`${prefixCls}-header-content`}>
29-
{ thumb ? <img style={thumbStyle} src={thumb} /> : null }
29+
{thumb ? <img style={thumbStyle} src={thumb} /> : null}
3030
{title}
3131
</div>
32-
{ extra ? <div className={`${prefixCls}-header-extra`}>{extra}</div> : null }
32+
{extra ? <div className={`${prefixCls}-header-extra`}>{extra}</div> : null}
3333
</div>
3434
);
3535
}

components/carousel/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class Carousel extends React.Component<CarouselProps, any> {
263263

264264
if (!children) {
265265
return (
266-
<Text style={{backgroundColor: 'white'}}>
266+
<Text style={{ backgroundColor: 'white' }}>
267267
You are supposed to add children inside Carousel
268268
</Text>
269269
);

components/checkbox/AgreeItem.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {View, TouchableWithoutFeedback, Text} from 'react-native';
2+
import { View, TouchableWithoutFeedback, Text } from 'react-native';
33
import Checkbox from './Checkbox';
44
import { AgreeItemPropsType } from './PropsType';
55
import AgreeItemstyle from './style/index';
@@ -16,7 +16,7 @@ export default class AgreeItem extends React.Component<AgreeItemPropsType, any>
1616
}
1717

1818
render(): JSX.Element {
19-
let {style, checkboxStyle, children, disabled, checked, defaultChecked, onChange, styles} = this.props;
19+
let { style, checkboxStyle, children, disabled, checked, defaultChecked, onChange, styles } = this.props;
2020

2121
let contentDom;
2222
if (React.isValidElement(children)) {
@@ -35,7 +35,7 @@ export default class AgreeItem extends React.Component<AgreeItemPropsType, any>
3535
defaultChecked={defaultChecked}
3636
onChange={onChange}
3737
/>
38-
<View style={{flex:1}}>
38+
<View style={{ flex: 1 }}>
3939
{contentDom}
4040
</View>
4141
</View>

components/checkbox/Checkbox.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {TouchableWithoutFeedback, Image, View, Text } from 'react-native';
2+
import { TouchableWithoutFeedback, Image, View, Text } from 'react-native';
33
import { CheckboxProps } from './PropsType';
44
import CheckboxStyle from './style/index';
55

@@ -38,12 +38,12 @@ export default class Checkbox extends React.Component<CheckboxProps, any> {
3838
});
3939
}
4040
if (this.props.onChange) {
41-
this.props.onChange({target: { checked }});
41+
this.props.onChange({ target: { checked } });
4242
}
4343
}
4444

4545
render(): JSX.Element {
46-
let {style, disabled, children, styles} = this.props;
46+
let { style, disabled, children, styles } = this.props;
4747
let checked = this.state.checked;
4848
let imgSrc;
4949
if (checked) {
@@ -64,7 +64,7 @@ export default class Checkbox extends React.Component<CheckboxProps, any> {
6464
<TouchableWithoutFeedback onPress={this.handleClick}>
6565
<View style={[styles.wrapper]}>
6666
<Image source={imgSrc} style={[styles.icon, style]} />
67-
{ typeof children === 'string' ? ( <Text style={styles.iconRight}>{this.props.children}</Text>) : children }
67+
{typeof children === 'string' ? ( <Text style={styles.iconRight}>{this.props.children}</Text>) : children}
6868
</View>
6969
</TouchableWithoutFeedback>
7070
);

components/checkbox/demo/basic.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import {View, Text} from 'react-native';
3-
import {WhiteSpace, Checkbox, List} from 'antd-mobile';
2+
import { View, Text } from 'react-native';
3+
import { WhiteSpace, Checkbox, List } from 'antd-mobile';
44
const AgreeItem = Checkbox.AgreeItem;
55
const CheckboxItem = Checkbox.CheckboxItem;
66

@@ -21,7 +21,7 @@ export default class BasicCheckboxExample extends React.Component<any, any> {
2121
<View style={{ padding: 10 }}>
2222
<Checkbox
2323
checked={this.state.checkBox1}
24-
style={{tintColor:'#f00'}}
24+
style={{ tintColor: '#f00' }}
2525
onChange={(event) => { this.setState({ checkBox1: event.target.checked }); }}
2626
/>
2727
<WhiteSpace />
@@ -37,7 +37,7 @@ export default class BasicCheckboxExample extends React.Component<any, any> {
3737
<WhiteSpace />
3838
<AgreeItem
3939
checked={this.state.agreeItem1}
40-
checkboxStyle={{tintColor:'#f00'}}
40+
checkboxStyle={{ tintColor: '#f00' }}
4141
onChange={(event) => { this.setState({ agreeItem1: event.target.checked }); }}
4242
>
4343
同意 《信用支付服务合同
@@ -47,8 +47,8 @@ export default class BasicCheckboxExample extends React.Component<any, any> {
4747
<WhiteSpace />
4848
<AgreeItem checked disabled>强制选中,不可编辑 《信用支付服务合同信用支付服务合同信用支付服务合同》</AgreeItem>
4949

50-
<List style={{marginTop: 12}}>
51-
<Text style={{marginTop: 12}}>表单多选项,普通列表中多选项</Text>
50+
<List style={{ marginTop: 12 }}>
51+
<Text style={{ marginTop: 12 }}>表单多选项,普通列表中多选项</Text>
5252
<CheckboxItem
5353
checked={this.state.checkboxItem1}
5454
onChange={(event) => { this.setState({ checkboxItem1: event.target.checked }); }}

components/date-picker/demo/popup.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class PopupExample extends React.Component<any, any> {
1919
}
2020

2121
onChange = (value) => {
22-
this.setState({value});
22+
this.setState({ value });
2323
}
2424

2525
render() {
@@ -29,8 +29,8 @@ export default class PopupExample extends React.Component<any, any> {
2929
defaultDate={defaultDate}
3030
value={this.state.value}
3131
mode="date"
32-
minDate={this.date1MinDate || (this.date1MinDate = moment('2015-08-06','YYYY-MM-DD'))}
33-
maxDate={this.date1MaxDate || (this.date1MaxDate = moment('2016-12-06','YYYY-MM-DD'))}
32+
minDate={this.date1MinDate || (this.date1MinDate = moment('2015-08-06', 'YYYY-MM-DD'))}
33+
maxDate={this.date1MaxDate || (this.date1MaxDate = moment('2016-12-06', 'YYYY-MM-DD'))}
3434
onChange={this.onChange}
3535
format={val => val.fromNow()}
3636
>

components/date-picker/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class DatePicker extends React.Component<tsPropsType, any> {
2121

2222
render() {
2323
const { props, context } = this;
24-
const {children, extra, value, defaultDate, styles} = props;
24+
const { children, extra, value, defaultDate, styles } = props;
2525
const extraProps = {
2626
extra: value ? formatFn(this, value) : extra,
2727
};

components/date-picker/utils.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function getFormatter(type) {
1313
}
1414

1515
export function formatFn(instance, value) {
16-
const {format} = instance.props;
16+
const { format } = instance.props;
1717
const type = typeof format;
1818
if (type === 'string') {
1919
return value.format(type);

components/drawer/demo/basic.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default class DrawerExample extends React.Component<any, any> {
5959
<Drawer
6060
sidebar={sidebar}
6161
{...drawerProps}
62-
ref={ d => { this.drawer = d; DrawerExample.drawer = d; } }
62+
ref={d => { this.drawer = d; DrawerExample.drawer = d; }}
6363
>
6464
<DefaultRenderer
6565
navigationState={this.props.navigationState.children[0]}
@@ -80,7 +80,7 @@ export class DrawerMain extends React.Component<any, any> {
8080
render() {
8181
return (
8282
<View style={{ flex: 1, marginTop: 114, padding: 8 }}>
83-
<Button onClick={() => this.drawer && this.drawer.openDrawer() }>打开 drawer</Button>
83+
<Button onClick={() => this.drawer && this.drawer.openDrawer()}>打开 drawer</Button>
8484
<WhiteSpace />
8585
<Button onClick={() => Actions.pop()}>返回 demo list</Button>
8686
</View>

components/drawer/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class Drawer extends React.Component<tsPropsType, any> {
2323
renderNavigationView={() => sidebar}
2424
drawerPosition={position}
2525
onDrawerOpen={() => onOpenChange(true)}
26-
onDrawerClose={() => onOpenChange(false) }
26+
onDrawerClose={() => onOpenChange(false)}
2727
{...restProps}
2828
>
2929
{children}

0 commit comments

Comments
 (0)