Skip to content

Commit 70d8809

Browse files
author
Igor Canedo
committed
removing usage of proptypes and refactoring props usage
1 parent 5e3b7cd commit 70d8809

File tree

14 files changed

+93
-85
lines changed

14 files changed

+93
-85
lines changed

.eslintrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
}
2828
],
2929
"import/imports-first": 2,
30-
"flow-vars/define-flow-type": 1,
31-
"flow-vars/use-flow-type": 1,
30+
"flowtype/define-flow-type": 1,
31+
"flowtype/use-flow-type": 1,
3232
"flowtype/require-parameter-type": 1,
3333
"flowtype/require-return-type": [
3434
1,
@@ -76,7 +76,6 @@
7676
"plugins": [
7777
"react",
7878
"react-native",
79-
"flow-vars",
8079
"flowtype"
8180
]
8281
}

index.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
* License: MIT
55
*/
66

7-
// @flow
7+
// @flow
88

9-
import React, {
10-
PropTypes,
11-
} from 'react';
9+
import React from 'react';
1210
import {
1311
View,
1412
} from 'react-native';
@@ -26,7 +24,7 @@ type RnDraftJsRenderPropsType = {
2624
customStyles?: Object,
2725
atomicHandler: Function,
2826
navigate?: Function,
29-
orderedListSeparator?: String,
27+
orderedListSeparator?: string,
3028
};
3129

3230
const RNDraftJSRender = (props: RnDraftJsRenderPropsType): any => {
@@ -41,14 +39,6 @@ const RNDraftJSRender = (props: RnDraftJsRenderPropsType): any => {
4139
);
4240
};
4341

44-
RNDraftJSRender.propTypes = {
45-
contentState: PropTypes.object.isRequired,
46-
customStyles: PropTypes.object,
47-
atomicHandler: PropTypes.func,
48-
navigate: PropTypes.func,
49-
orderedListSeparator: PropTypes.string,
50-
};
51-
5242
RNDraftJSRender.defaultProps = {
5343
customStyles: {},
5444
atomicHandler: (): any => null,

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"coverage": "jest --coverage",
99
"test-reset": "jest --updateSnapshot",
1010
"linter": "eslint .",
11+
"linter:fix": "eslint . --fix",
1112
"flow": "flow",
1213
"flow-stop": "flow stop"
1314
},
@@ -23,20 +24,19 @@
2324
"react-native": "^0.41.2"
2425
},
2526
"devDependencies": {
26-
"babel-eslint": "^7.1.1",
27-
"babel-jest": "19.0.0",
28-
"babel-preset-react-native": "1.9.1",
27+
"babel-eslint": "^7.2.3",
28+
"babel-jest": "^20.0.3",
29+
"babel-preset-react-native": "^2.1.0",
2930
"coveralls": "^2.12.0",
30-
"eslint": "^3.17.1",
31-
"eslint-config-airbnb": "^14.1.0",
32-
"eslint-plugin-flow-vars": "^0.5.0",
33-
"eslint-plugin-flowtype": "^2.30.3",
34-
"eslint-plugin-import": "^2.2.0",
35-
"eslint-plugin-jsx-a11y": "^4.0.0",
36-
"eslint-plugin-react": "^6.10.0",
37-
"eslint-plugin-react-native": "^2.3.1",
38-
"flow-bin": "^0.41.0",
39-
"jest": "19.0.2",
31+
"eslint": "^4.4.1",
32+
"eslint-config-airbnb": "^15.1.0",
33+
"eslint-plugin-flowtype": "^2.35.0",
34+
"eslint-plugin-import": "^2.7.0",
35+
"eslint-plugin-jsx-a11y": "^5.1.1",
36+
"eslint-plugin-react": "^7.2.1",
37+
"eslint-plugin-react-native": "^3.0.1",
38+
"flow-bin": "^0.53.1",
39+
"jest": "^20.0.4",
4040
"react": "^15.4.2",
4141
"react-native": "^0.41.2",
4242
"react-test-renderer": "15.4.2"

sample/index.android.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// @flow
88

9-
import React from 'react'; // eslint-disable-line no-unused-vars
9+
import React from 'react'; // eslint-disable-line no-unused-vars
1010
import {
1111
AppRegistry,
1212
} from 'react-native';

sample/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
},
1313
"dependencies": {
1414
"react": "15.4.2",
15-
"react-native": "0.42.0"
15+
"react-native": "0.41.2"
1616
},
1717
"devDependencies": {
18-
"babel-jest": "19.0.0",
19-
"babel-preset-react-native": "1.9.1",
20-
"jest": "19.0.2",
18+
"babel-jest": "^20.0.3",
19+
"babel-preset-react-native": "^2.1.0",
20+
"jest": "^20.0.4",
2121
"react-test-renderer": "15.4.2",
2222
"sync-files": "1.0.3"
2323
},

src/components/BlockQuote.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414

1515
import DraftJsText from '../components/DraftJsText';
1616

17+
import type { BlockQuotePropsType } from './defaultProps';
18+
1719
const styles = StyleSheet.create({
1820
blockquoteContainer: {
1921
borderLeftColor: '#eee',
@@ -25,7 +27,7 @@ const styles = StyleSheet.create({
2527
},
2628
});
2729

28-
const BlockQuote = (props: Object): any => {
30+
const BlockQuote = (props: BlockQuotePropsType): any => {
2931
const blockquoteCustomStyleContainer = props.customStyles ?
3032
props.customStyles.blockquoteContainer :
3133
undefined;
@@ -46,12 +48,6 @@ const BlockQuote = (props: Object): any => {
4648
</View>);
4749
};
4850

49-
BlockQuote.propTypes = {
50-
text: React.PropTypes.string.isRequired,
51-
customStyles: React.PropTypes.any,
52-
type: React.PropTypes.string.isRequired,
53-
};
54-
5551
BlockQuote.defaultProps = {
5652
customStyles: undefined,
5753
type: '',

src/components/DraftJsText.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,7 @@ import {
1414
import loadAttributes from '../loadAttributes';
1515

1616
import defaultStyles from './defaultStyles';
17-
18-
type DraftJsTextPropsType = {
19-
type: string,
20-
text: string,
21-
customStyles?: Object,
22-
inlineStyles: Array<Object>,
23-
entityRanges: Array<Object>,
24-
entityMap: Object,
25-
navigate?: Function,
26-
};
17+
import type { DraftJsTextPropsType } from './defaultProps';
2718

2819
const DraftJsText = (props: DraftJsTextPropsType): any => {
2920
let textElements = props.text;
@@ -47,12 +38,6 @@ const DraftJsText = (props: DraftJsTextPropsType): any => {
4738
return null;
4839
};
4940

50-
DraftJsText.propTypes = {
51-
text: React.PropTypes.string,
52-
customStyles: React.PropTypes.any,
53-
inlineStyles: React.PropTypes.array,
54-
};
55-
5641
DraftJsText.defaultProps = {
5742
text: '',
5843
customStyles: {},

src/components/OrderedListItem.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515

1616
import DraftJsText from '../components/DraftJsText';
1717

18+
import type { OrderedListItemPropsType } from './defaultProps';
19+
1820
const styles = StyleSheet.create({
1921
orderedListItemContainer: {
2022
flex: 1,
@@ -29,7 +31,7 @@ const styles = StyleSheet.create({
2931
},
3032
});
3133

32-
const OrderedListItem = (props: Object): any => {
34+
const OrderedListItem = (props: OrderedListItemPropsType): any => {
3335
const number = props.counter;
3436
const separator = props.separator;
3537
const orderedListItemCustomStyleContainer = props.customStyles ?
@@ -53,12 +55,6 @@ const OrderedListItem = (props: Object): any => {
5355
</View>);
5456
};
5557

56-
OrderedListItem.propTypes = {
57-
counter: React.PropTypes.number,
58-
customStyles: React.PropTypes.any,
59-
separator: React.PropTypes.string,
60-
};
61-
6258
OrderedListItem.defaultProps = {
6359
counter: 1,
6460
customStyles: {},

src/components/TextStyled.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ import {
1212
StyleSheet,
1313
} from 'react-native';
1414

15-
type TextStyledPropsType = {
16-
text: string,
17-
type: any,
18-
customStyles: any,
19-
onPress?: Function,
20-
};
15+
import type { TextStyledPropsType } from './defaultProps';
2116

2217
const styles = StyleSheet.flatten({
2318
bold: {
@@ -37,14 +32,15 @@ const styles = StyleSheet.flatten({
3732
},
3833
});
3934

40-
const getStyles = (itemType: any, customStyles: Object): any => {
35+
const getStyles = (itemType: any, customStyles?: Object): any => {
36+
if (!customStyles) return [styles[itemType]];
4137
if (typeof itemType === 'string') return [styles[itemType], customStyles[itemType]];
4238

4339
const defaultTextStyles = {};
4440
const customTextStyles = {};
4541
itemType.forEach((i: string) => {
4642
Object.assign(defaultTextStyles, styles[i]);
47-
Object.assign(customTextStyles, customStyles[i]);
43+
if (customStyles) Object.assign(customTextStyles, customStyles[i]);
4844
});
4945
const newStyles = [defaultTextStyles, customTextStyles];
5046
return newStyles;
@@ -59,11 +55,6 @@ const TextStyled = (props: TextStyledPropsType): any => {
5955
return <Text style={textStyle}>{props.text}</Text>;
6056
};
6157

62-
TextStyled.propTypes = {
63-
text: React.PropTypes.string,
64-
type: React.PropTypes.any.isRequired,
65-
};
66-
6758
TextStyled.defaultProps = {
6859
text: '',
6960
onPress: undefined,

src/components/UnorderedListItem.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414

1515
import DraftJsText from '../components/DraftJsText';
1616

17+
import type { UnorderedListItemPropsType } from './defaultProps';
18+
1719
const styles = StyleSheet.create({
1820
unorderedListItemContainer: {
1921
flex: 1,
@@ -30,7 +32,7 @@ const styles = StyleSheet.create({
3032
},
3133
});
3234

33-
const UnorderedListItem = (props: Object): any => {
35+
const UnorderedListItem = (props: UnorderedListItemPropsType): any => {
3436
const unorderedListItemCustomStyleContainer = props.customStyles ?
3537
props.customStyles.unorderedListItemContainer :
3638
undefined;
@@ -48,10 +50,6 @@ const UnorderedListItem = (props: Object): any => {
4850
</View>);
4951
};
5052

51-
UnorderedListItem.propTypes = {
52-
customStyles: React.PropTypes.any,
53-
};
54-
5553
UnorderedListItem.defaultProps = {
5654
customStyles: {},
5755
};

0 commit comments

Comments
 (0)