Skip to content

Commit fd7ee80

Browse files
authored
Fix Flow check for macos (#212)
* Initial changes for macos flow check * Fixed all macos flow errors * Cleaned up AccessibiltInfo stub * Cleanup * Added diff comments
1 parent 5b3c1c0 commit fd7ee80

File tree

15 files changed

+344
-7
lines changed

15 files changed

+344
-7
lines changed

.ado/templates/apple-job-javascript.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ steps:
1313
- script: 'yarn test-ci'
1414
displayName: 'yarn test-ci'
1515

16-
- script: 'yarn flow'
17-
displayName: 'yarn flow'
16+
- script: 'yarn flow-check-ios'
17+
displayName: 'yarn flow-check-ios'
18+
19+
- script: 'yarn flow-check-macos'
20+
displayName: 'yarn flow-check-macos'
21+
22+
- script: 'yarn flow-check-android'
23+
displayName: 'yarn flow-check-android'
1824

1925
- script: 'yarn lint'
2026
displayName: 'yarn lint'

.flowconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[ignore]
22
; We fork some components by platform
33
.*/*[.]android.js
4+
; TODO(macOS ISS#2323203):
5+
.*/*[.]macos.js
46

57
; Ignore templates for 'react-native init'
68
<PROJECT_ROOT>/template/.*
@@ -60,6 +62,8 @@ module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' ->
6062
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
6163
# strip .ios suffix
6264
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
65+
# TODO(macOS ISS#2323203):
66+
module.system.haste.name_reducers='^\(.*\)\.macos$' -> '\1'
6367
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
6468
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
6569
module.system.haste.paths.blacklist=.*/__tests__/.*

.flowconfig.android

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[ignore]
22
; We fork some components by platform
33
.*/*[.]ios.js
4+
; TODO(macOS ISS#2323203):
45
.*/*[.]macos.js
56

67
; Ignore templates for 'react-native init'
@@ -23,6 +24,9 @@
2324
; Ignore polyfills
2425
.*/Libraries/polyfills/.*
2526

27+
; TODO(macOS ISS#2323203): Ignore metro.config.js
28+
<PROJECT_ROOT>/metro.config.js
29+
2630
; Ignore files that have a base platform file and an android file
2731
<PROJECT_ROOT>/Libraries/Image/Image.js
2832
<PROJECT_ROOT>/Libraries/Network/RCTNetworking.js
@@ -68,6 +72,8 @@ module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
6872
# strip .android suffix
6973
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
7074
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
75+
# TODO(macOS ISS#2323203):
76+
module.system.haste.name_reducers='^\(.*\)\.macos$' -> '\1'
7177
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
7278
module.system.haste.paths.blacklist=.*/__tests__/.*
7379
module.system.haste.paths.blacklist=.*/__mocks__/.*

.flowconfig.macos

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
[ignore]
2+
; TODO(macOS ISS#2323203)
3+
; We fork some components by platform
4+
.*/*[.]ios.js
5+
.*/*[.]android.js
6+
7+
; Ignore templates for 'react-native init'
8+
<PROJECT_ROOT>/template/.*
9+
10+
; Ignore the Dangerfile
11+
<PROJECT_ROOT>/bots/dangerfile.js
12+
13+
; Ignore "BUCK" generated dirs
14+
<PROJECT_ROOT>/\.buckd/
15+
16+
; Ignore unexpected extra "@providesModule"
17+
.*/node_modules/.*/node_modules/fbjs/.*
18+
19+
; Ignore duplicate module providers
20+
; For RN Apps installed via npm, "Libraries" folder is inside
21+
; "node_modules/react-native" but in the source repo it is in the root
22+
.*/Libraries/react-native/React.js
23+
24+
; Ignore polyfills
25+
.*/Libraries/polyfills/.*
26+
27+
; Ignore metro.config.js
28+
<PROJECT_ROOT>/metro.config.js
29+
30+
; These should not be required directly
31+
; require from fbjs/lib instead: require('fbjs/lib/warning')
32+
.*/node_modules/warning/.*
33+
34+
; Flow doesn't support platforms
35+
.*/Libraries/Utilities/HMRLoadingView.js
36+
37+
[untyped]
38+
.*/node_modules/@react-native-community/cli/.*/.*
39+
40+
[include]
41+
42+
[libs]
43+
Libraries/react-native/react-native-interface.js
44+
flow/
45+
46+
[options]
47+
emoji=true
48+
49+
esproposal.optional_chaining=enable
50+
esproposal.nullish_coalescing=enable
51+
52+
module.file_ext=.js
53+
module.file_ext=.json
54+
module.file_ext=.macos.js
55+
56+
module.system=haste
57+
module.system.haste.use_name_reducers=true
58+
# keep the following in sync with server/haste/hasteImpl.js
59+
# get basename
60+
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
61+
# strip .js or .js.flow suffix
62+
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
63+
# strip .macos suffix
64+
module.system.haste.name_reducers='^\(.*\)\.macos$' -> '\1'
65+
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
66+
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
67+
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
68+
module.system.haste.paths.blacklist=.*/__tests__/.*
69+
module.system.haste.paths.blacklist=.*/__mocks__/.*
70+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/Libraries/.*
71+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/RNTester/.*
72+
module.system.haste.paths.whitelist=<PROJECT_ROOT>/IntegrationTests/.*
73+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/react-native/react-native-implementation.js
74+
module.system.haste.paths.blacklist=<PROJECT_ROOT>/Libraries/Animated/src/polyfills/.*
75+
76+
munge_underscores=true
77+
78+
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'
79+
80+
suppress_type=$FlowIssue
81+
suppress_type=$FlowFixMe
82+
suppress_type=$FlowFixMeProps
83+
suppress_type=$FlowFixMeState
84+
85+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
86+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
87+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
88+
89+
[lints]
90+
sketchy-null-number=warn
91+
sketchy-null-mixed=warn
92+
sketchy-number=warn
93+
untyped-type-import=warn
94+
nonstrict-import=warn
95+
deprecated-type=warn
96+
unsafe-getters-setters=warn
97+
inexact-spread=warn
98+
unnecessary-invariant=warn
99+
signature-verification-failure=warn
100+
deprecated-utility=error
101+
102+
[strict]
103+
deprecated-type
104+
nonstrict-import
105+
sketchy-null
106+
unclear-type
107+
unsafe-getters-setters
108+
untyped-import
109+
untyped-type-import
110+
111+
[version]
112+
^0.98.0
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @flow
9+
*/
10+
11+
// TODO(macOS ISS#2323203)
12+
13+
'use strict';
14+
15+
const warning = require('fbjs/lib/warning');
16+
17+
type ChangeEventName = $Keys<{}>;
18+
19+
const AccessibilityInfo = {
20+
/**
21+
* iOS only
22+
*/
23+
isBoldTextEnabled: function(): Promise<boolean> {
24+
return Promise.resolve(false);
25+
},
26+
27+
/**
28+
* iOS only
29+
*/
30+
isGrayscaleEnabled: function(): Promise<boolean> {
31+
return Promise.resolve(false);
32+
},
33+
34+
/**
35+
* iOS only
36+
*/
37+
isInvertColorsEnabled: function(): Promise<boolean> {
38+
return Promise.resolve(false);
39+
},
40+
41+
/**
42+
* Android and iOS only
43+
*/
44+
isReduceMotionEnabled: function(): Promise<boolean> {
45+
return Promise.resolve(false);
46+
},
47+
48+
/**
49+
* iOS only
50+
*/
51+
isReduceTransparencyEnabled: function(): Promise<boolean> {
52+
return Promise.resolve(false);
53+
},
54+
55+
/**
56+
* Android and iOS only
57+
*/
58+
isScreenReaderEnabled: function(): Promise<boolean> {
59+
return Promise.resolve(false);
60+
},
61+
62+
/**
63+
* Deprecated
64+
*
65+
* Same as `isScreenReaderEnabled`
66+
*/
67+
get fetch() {
68+
return this.isScreenReaderEnabled;
69+
},
70+
71+
addEventListener: function(
72+
eventName: ChangeEventName,
73+
handler: Function,
74+
): void {
75+
warning(false, 'AccessibilityInfo is not supported on this platform.');
76+
},
77+
78+
removeEventListener: function(
79+
eventName: ChangeEventName,
80+
handler: Function,
81+
): void {
82+
warning(false, 'AccessibilityInfo is not supported on this platform.');
83+
},
84+
85+
/**
86+
* Set accessibility focus to a react component.
87+
*
88+
* See http://facebook.github.io/react-native/docs/accessibilityinfo.html#setaccessibilityfocus
89+
*/
90+
setAccessibilityFocus: function(reactTag: number): void {
91+
warning(false, 'AccessibilityInfo is not supported on this platform.');
92+
},
93+
94+
/**
95+
* Post a string to be announced by the screen reader.
96+
*
97+
* See http://facebook.github.io/react-native/docs/accessibilityinfo.html#announceforaccessibility
98+
*/
99+
announceForAccessibility: function(announcement: string): void {
100+
warning(false, 'AccessibilityInfo is not supported on this platform.');
101+
},
102+
};
103+
104+
module.exports = AccessibilityInfo;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/**
2-
* Copyright (c) 2015-present, Facebook, Inc.
2+
* Copyright (c) Facebook, Inc. and its affiliates.
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @flow
87
* @format
98
*/
109

1110
// TODO(macOS ISS#2323203)
1211

1312
'use strict';
1413

15-
module.exports = require('View');
14+
module.exports = require('../UnimplementedViews/UnimplementedView');

Libraries/Components/Picker/PickerIOS.macos.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* This is a controlled component version of RCTPickerIOS
99
*
1010
* @format
11-
* @flow
1211
*/
1312

1413
// TODO(macOS ISS#2323203)

Libraries/Components/SafeAreaView/SafeAreaView.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ let exported;
3131
* limitation of the screen, such as rounded corners or camera notches (aka
3232
* sensor housing area on iPhone X).
3333
*/
34-
if (Platform.OS === 'android') {
34+
if (Platform.OS !== 'ios') {
35+
// TODO(macOS ISS#2323203)
3536
const SafeAreaView = (
3637
props: Props,
3738
forwardedRef?: ?React.Ref<typeof View>,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @flow strict-local
9+
*/
10+
11+
// TODO(macOS ISS#2323203)
12+
13+
'use strict';
14+
15+
const NativeEventEmitter = require('../../EventEmitter/NativeEventEmitter');
16+
const {StatusBarManager} = require('../../BatchedBridge/NativeModules');
17+
18+
/**
19+
* Use `StatusBar` for mutating the status bar.
20+
*/
21+
class StatusBarIOS extends NativeEventEmitter {}
22+
23+
module.exports = new StatusBarIOS(StatusBarManager);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @flow strict-local
9+
*/
10+
11+
// TODO(macOS ISS#2323203)
12+
13+
'use strict';
14+
15+
import type {
16+
TimePickerOptions,
17+
TimePickerResult,
18+
} from './TimePickerAndroidTypes';
19+
20+
const TimePickerAndroid = {
21+
async open(options: TimePickerOptions): Promise<TimePickerResult> {
22+
return Promise.reject({
23+
message: 'TimePickerAndroid is not supported on this platform.',
24+
});
25+
},
26+
};
27+
28+
module.exports = TimePickerAndroid;

0 commit comments

Comments
 (0)