Skip to content

Commit 170d802

Browse files
author
Martijn Swaagman
committed
[major] flow checks working and semi integrated
1 parent f818fc6 commit 170d802

24 files changed

+1711
-690
lines changed

.flowconfig

+31-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[ignore]
22
; This flowconfig is forked by platform - the only difference between them is which suffix is ignored.
33
.*/*[.]android.js
4-
;.*/*[.]ios.js
54

65
; Ignore templates for 'react-native init'
76
.*/local-cli/templates/.*
@@ -23,32 +22,30 @@ node_modules/react-native/\.buckd/
2322
; Ignore polyfills
2423
.*/Libraries/polyfills/.*
2524

26-
; Ignore metro
27-
.*/node_modules/metro/.*
28-
29-
; Ignore "config-chain"'s test folder - it has a corrupt JSON file that's tripping flow
30-
.*/node_modules/config-chain/test/*.
31-
3225
; These should not be required directly
3326
; require from fbjs/lib instead: require('fbjs/lib/invariant')
34-
.*/node_modules/invariant/.*
3527
.*/node_modules/warning/.*
3628

29+
; Flow doesn't support platforms
30+
.*/Libraries/Utilities/HMRLoadingView.js
31+
32+
[untyped]
33+
.*/node_modules/@react-native-community/cli/.*/.*
34+
3735
[include]
3836

3937
[libs]
4038
node_modules/react-native/Libraries/react-native/react-native-interface.js
4139
node_modules/react-native/flow/
42-
node_modules/react-native/flow-github/
43-
44-
[lints]
4540

4641
[options]
4742
emoji=true
4843

4944
esproposal.optional_chaining=enable
5045
esproposal.nullish_coalescing=enable
5146

47+
module.file_ext=.ios.js
48+
module.file_ext=.js
5249
module.system=haste
5350
module.system.haste.use_name_reducers=true
5451
# keep the following in sync with server/haste/hasteImpl.js
@@ -62,17 +59,15 @@ module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
6259
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
6360
module.system.haste.paths.blacklist=.*/__tests__/.*
6461
module.system.haste.paths.blacklist=.*/__mocks__/.*
65-
module.system.haste.paths.whitelist=<PROJECT_ROOT>/js/.*
6662
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
6763
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/RNTester/.*
6864
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/IntegrationTests/.*
6965
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
66+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js
7067

7168
munge_underscores=true
7269

7370
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
74-
# Support the library import in examples
75-
module.name_mapper='^\@react-native-community/async-storage$' -> '<PROJECT_ROOT>/lib/AsyncStorage.js'
7671

7772
suppress_type=$FlowIssue
7873
suppress_type=$FlowFixMe
@@ -84,7 +79,28 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*
8479
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
8580
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
8681

82+
[lints]
83+
sketchy-null-number=warn
84+
sketchy-null-mixed=warn
85+
sketchy-number=warn
86+
untyped-type-import=warn
87+
nonstrict-import=warn
88+
deprecated-type=warn
89+
unsafe-getters-setters=warn
90+
inexact-spread=warn
91+
unnecessary-invariant=warn
92+
deprecated-call-syntax=warn
93+
signature-verification-failure=warn
94+
deprecated-utility=error
95+
8796
[strict]
97+
deprecated-type
98+
nonstrict-import
99+
sketchy-null
100+
unclear-type
101+
unsafe-getters-setters
102+
untyped-import
103+
untyped-type-import
88104

89105
[version]
90-
^0.93.0
106+
^0.95.0

.flowconfig.android

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]ios.js
4+
5+
; Ignore templates for 'react-native init'
6+
.*/local-cli/templates/.*
7+
8+
; Ignore the Dangerfile
9+
node_modules/react-native/bots/dangerfile.js
10+
11+
; Ignore "BUCK" generated dirs
12+
node_modules/react-native/\.buckd/
13+
14+
; Ignore unexpected extra "@providesModule"
15+
.*/node_modules/.*/node_modules/fbjs/.*
16+
17+
; Ignore duplicate module providers
18+
; For RN Apps installed via npm, "Libraries" folder is inside
19+
; "node_modules/react-native" but in the source repo it is in the root
20+
.*/Libraries/react-native/React.js
21+
22+
; Ignore polyfills
23+
.*/Libraries/polyfills/.*
24+
25+
; These should not be required directly
26+
; require from fbjs/lib instead: require('fbjs/lib/warning')
27+
.*/node_modules/warning/.*
28+
29+
; Flow doesn't support platforms
30+
.*/Libraries/Utilities/HMRLoadingView.js
31+
32+
[untyped]
33+
.*/node_modules/@react-native-community/cli/.*/.*
34+
35+
[include]
36+
37+
[libs]
38+
node_modules/react-native/Libraries/react-native/react-native-interface.js
39+
node_modules/react-native/flow/
40+
41+
[options]
42+
emoji=true
43+
44+
esproposal.optional_chaining=enable
45+
esproposal.nullish_coalescing=enable
46+
47+
module.file_ext=.android.js
48+
module.file_ext=.js
49+
module.system=haste
50+
module.system.haste.use_name_reducers=true
51+
# keep the following in sync with server/haste/hasteImpl.js
52+
# get basename
53+
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
54+
# strip .js or .js.flow suffix
55+
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
56+
# strip .android suffix
57+
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
58+
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
59+
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
60+
module.system.haste.paths.blacklist=.*/__tests__/.*
61+
module.system.haste.paths.blacklist=.*/__mocks__/.*
62+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
63+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/RNTester/.*
64+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/IntegrationTests/.*
65+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
66+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js
67+
68+
munge_underscores=true
69+
70+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
71+
72+
suppress_type=$FlowIssue
73+
suppress_type=$FlowFixMe
74+
suppress_type=$FlowFixMeProps
75+
suppress_type=$FlowFixMeState
76+
77+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_android\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
78+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_android\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
79+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
80+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
81+
82+
[lints]
83+
sketchy-null-number=warn
84+
sketchy-null-mixed=warn
85+
sketchy-number=warn
86+
untyped-type-import=warn
87+
nonstrict-import=warn
88+
deprecated-type=warn
89+
unsafe-getters-setters=warn
90+
inexact-spread=warn
91+
unnecessary-invariant=warn
92+
deprecated-call-syntax=warn
93+
signature-verification-failure=warn
94+
deprecated-utility=error
95+
96+
[strict]
97+
deprecated-type
98+
nonstrict-import
99+
sketchy-null
100+
unclear-type
101+
unsafe-getters-setters
102+
untyped-import
103+
untyped-type-import
104+
105+
[version]
106+
^0.95.0

android/src/main/java/com/reactcommunity/rndatetimepicker/RNConstants.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public final class RNConstants {
66
public static final String ARG_MINDATE = "minimumDate";
77
public static final String ARG_MAXDATE = "maximumDate";
88
public static final String ARG_IS24HOUR = "is24Hour";
9-
public static final String ARG_MODE = "mode";
9+
public static final String ARG_DISPLAY = "display";
1010
public static final String ACTION_DATE_SET = "dateSetAction";
1111
public static final String ACTION_TIME_SET = "timeSetAction";
1212
public static final String ACTION_DISMISSED = "dismissedAction";

android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ static DatePickerDialog createDialog(Bundle args, Context activityContext, @Null
5252
final int month = date.month();
5353
final int day = date.day();
5454

55-
RNDatePickerMode mode = RNDatePickerMode.DEFAULT;
55+
RNDatePickerDisplay display = RNDatePickerDisplay.DEFAULT;
5656
DatePickerDialog dialog = null;
5757

58-
if (args != null && args.getString(RNConstants.ARG_MODE, null) != null) {
59-
mode = RNDatePickerMode.valueOf(args.getString(RNConstants.ARG_MODE).toUpperCase(Locale.US));
58+
if (args != null && args.getString(RNConstants.ARG_DISPLAY, null) != null) {
59+
display = RNDatePickerDisplay.valueOf(args.getString(RNConstants.ARG_DISPLAY).toUpperCase(Locale.US));
6060
}
6161

6262
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
63-
switch (mode) {
63+
switch (display) {
6464
case CALENDAR:
6565
dialog = new RNDismissableDatePickerDialog(activityContext,
6666
activityContext.getResources().getIdentifier("CalendarDatePickerDialog", "style", activityContext.getPackageName()),
@@ -78,7 +78,7 @@ static DatePickerDialog createDialog(Bundle args, Context activityContext, @Null
7878
} else {
7979
dialog = new RNDismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day);
8080

81-
switch (mode) {
81+
switch (display) {
8282
case CALENDAR:
8383
dialog.getDatePicker().setCalendarViewShown(true);
8484
dialog.getDatePicker().setSpinnersShown(false);

android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void onDismiss(DialogInterface dialog) {
9090
* to select
9191
* </li>
9292
* <li>
93-
* {@code mode} To set the date picker mode to 'calendar/spinner/default'
93+
* {@code display} To set the date picker display to 'calendar/spinner/default'
9494
* </li>
9595
* </ul>
9696
*
@@ -146,8 +146,8 @@ private Bundle createFragmentArguments(ReadableMap options) {
146146
if (options.hasKey(RNConstants.ARG_MAXDATE) && !options.isNull(RNConstants.ARG_MAXDATE)) {
147147
args.putLong(RNConstants.ARG_MAXDATE, (long) options.getDouble(RNConstants.ARG_MAXDATE));
148148
}
149-
if (options.hasKey(RNConstants.ARG_MODE) && !options.isNull(RNConstants.ARG_MODE)) {
150-
args.putString(RNConstants.ARG_MODE, options.getString(RNConstants.ARG_MODE));
149+
if (options.hasKey(RNConstants.ARG_DISPLAY) && !options.isNull(RNConstants.ARG_DISPLAY)) {
150+
args.putString(RNConstants.ARG_DISPLAY, options.getString(RNConstants.ARG_DISPLAY));
151151
}
152152
return args;
153153
}

android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerMode.java renamed to android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDisplay.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
package com.reactcommunity.rndatetimepicker;
99

1010
/**
11-
* Date picker modes
11+
* Date picker display options.
1212
*/
13-
public enum RNDatePickerMode {
13+
public enum RNDatePickerDisplay {
1414
CALENDAR,
1515
SPINNER,
1616
DEFAULT

android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ static TimePickerDialog createDialog(Bundle args, Context activityContext, @Null
5050
final int minute = date.minute();
5151
boolean is24hour = DateFormat.is24HourFormat(activityContext);
5252

53-
RNTimePickerMode mode = RNTimePickerMode.DEFAULT;
54-
if (args != null && args.getString(RNConstants.ARG_MODE, null) != null) {
55-
mode = RNTimePickerMode.valueOf(args.getString(RNConstants.ARG_MODE).toUpperCase(Locale.US));
53+
RNTimePickerDisplay display = RNTimePickerDisplay.DEFAULT;
54+
if (args != null && args.getString(RNConstants.ARG_DISPLAY, null) != null) {
55+
display = RNTimePickerDisplay.valueOf(args.getString(RNConstants.ARG_DISPLAY).toUpperCase(Locale.US));
5656
}
5757

5858
if (args != null) {
5959
is24hour = args.getBoolean(RNConstants.ARG_IS24HOUR, DateFormat.is24HourFormat(activityContext));
6060
}
6161

6262
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
63-
if (mode == RNTimePickerMode.CLOCK) {
63+
if (display == RNTimePickerDisplay.CLOCK) {
6464
return new RNDismissableTimePickerDialog(
6565
activityContext,
6666
activityContext.getResources().getIdentifier(
@@ -73,7 +73,7 @@ static TimePickerDialog createDialog(Bundle args, Context activityContext, @Null
7373
minute,
7474
is24hour
7575
);
76-
} else if (mode == RNTimePickerMode.SPINNER) {
76+
} else if (display == RNTimePickerDisplay.SPINNER) {
7777
return new RNDismissableTimePickerDialog(
7878
activityContext,
7979
activityContext.getResources().getIdentifier(

android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ private Bundle createFragmentArguments(ReadableMap options) {
118118
if (options.hasKey(RNConstants.ARG_IS24HOUR) && !options.isNull(RNConstants.ARG_IS24HOUR)) {
119119
args.putBoolean(RNConstants.ARG_IS24HOUR, options.getBoolean(RNConstants.ARG_IS24HOUR));
120120
}
121-
if (options.hasKey(RNConstants.ARG_MODE) && !options.isNull(RNConstants.ARG_MODE)) {
122-
args.putString(RNConstants.ARG_MODE, options.getString(RNConstants.ARG_MODE));
121+
if (options.hasKey(RNConstants.ARG_DISPLAY) && !options.isNull(RNConstants.ARG_DISPLAY)) {
122+
args.putString(RNConstants.ARG_DISPLAY, options.getString(RNConstants.ARG_DISPLAY));
123123
}
124124
return args;
125125
}

android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerMode.java renamed to android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDisplay.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
package com.reactcommunity.rndatetimepicker;
99

10-
public enum RNTimePickerMode {
10+
/**
11+
* Date picker display options.
12+
*/
13+
public enum RNTimePickerDisplay {
1114
CLOCK,
1215
SPINNER,
1316
DEFAULT

flow-typed/npm/invariant_v2.x.x.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// flow-typed signature: 60de437d85342dea19dcd82c5a50f88a
2+
// flow-typed version: da30fe6876/invariant_v2.x.x/flow_>=v0.33.x
3+
4+
declare module invariant {
5+
declare module.exports: (condition: boolean, message: string) => void;
6+
}

ios/RNDateTimePickerManager.m

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ @implementation RCTConvert(UIDatePicker)
1818
@"time": @(UIDatePickerModeTime),
1919
@"date": @(UIDatePickerModeDate),
2020
@"datetime": @(UIDatePickerModeDateAndTime),
21-
@"countdown": @(UIDatePickerModeCountDownTimer), // not supported yet
2221
}), UIDatePickerModeTime, integerValue)
2322

2423
@end

0 commit comments

Comments
 (0)