Skip to content

Commit c78d246

Browse files
tom-unacoates-ms
authored andcommitted
Fix Flow and ESLint errors. (#14)
* Fix Flow and ESLint errors. * Fixed some warnings in code that is in the MS fork only.
1 parent e710efe commit c78d246

File tree

78 files changed

+941
-640
lines changed

Some content is hidden

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

78 files changed

+941
-640
lines changed

.flowconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
.*/Libraries/polyfills/.*
2424

2525
; Ignore metro
26-
; .*/node_modules/metro/.*
26+
.*/node_modules/metro/.*
27+
.*/node_modules/metro-config/src/configTypes.flow.js.flow
28+
29+
; Ignore rn-cli.config.js
30+
<PROJECT_ROOT>/rn-cli.config.js
2731

2832
; These should not be required directly
2933
; require from fbjs/lib instead: require('fbjs/lib/invariant')

IntegrationTests/AsyncStorageTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function testMerge() {
147147
expectEqual(JSON.parse(result), VAL_MERGE_EXPECT, 'testMerge');
148148
updateMessage('objects deeply merged\nDone!');
149149
runTestCase('multi set and get', testOptimizedMultiGet);
150-
});
150+
});
151151
});
152152
});
153153
} else {

IntegrationTests/LayoutEventsTest.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ const LayoutEventsTest = createReactClass({
5252
},
5353
animateViewLayout: function() {
5454
debug('animateViewLayout invoked');
55-
LayoutAnimation.configureNext(Platform.OS === 'macos' ? LayoutAnimation.Presets.easeInEaseOut : LayoutAnimation.Presets.spring, () => {
56-
debug('animateViewLayout done');
57-
this.checkLayout(this.addWrapText);
58-
});
55+
LayoutAnimation.configureNext(
56+
Platform.OS === 'macos'
57+
? LayoutAnimation.Presets.easeInEaseOut
58+
: LayoutAnimation.Presets.spring,
59+
() => {
60+
debug('animateViewLayout done');
61+
this.checkLayout(this.addWrapText);
62+
},
63+
);
5964
this.setState({viewStyle: {margin: 60}});
6065
},
6166
addWrapText: function() {

Libraries/Alert/Alert.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class Alert {
5555
return;
5656
}
5757
AlertIOS.alert(title, message, buttons);
58-
} else if (Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
59-
AlertMacOS.alert(title, message, buttons); // TODO(macOS ISS#2323203)
58+
} else if (Platform.OS === 'macos' /* TODO[(macOS ISS#2323203) */) {
59+
AlertMacOS.alert(title, message, buttons); // TODO](macOS ISS#2323203)
6060
} else if (Platform.OS === 'android') {
6161
AlertAndroid.alert(title, message, buttons, options);
6262
}

Libraries/Alert/AlertMacOS.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
'use strict';
1515

16-
import type { AlertType, AlertButtonStyle } from 'AlertIOS';
16+
import type {AlertType, AlertButtonStyle} from 'AlertIOS';
1717

1818
var RCTAlertManager = require('NativeModules').AlertManager;
1919

@@ -175,13 +175,11 @@ class AlertMacOS {
175175
modal?: ?boolean,
176176
critical?: ?boolean,
177177
): void {
178-
179178
var callbacks = [];
180179
var buttons = [];
181180
if (typeof callbackOrButtons === 'function') {
182181
callbacks = [callbackOrButtons];
183-
}
184-
else if (callbackOrButtons instanceof Array) {
182+
} else if (callbackOrButtons instanceof Array) {
185183
callbackOrButtons.forEach((btn, index) => {
186184
callbacks[index] = btn.onPress;
187185
if (btn.text || index < (callbackOrButtons || []).length - 1) {
@@ -192,18 +190,21 @@ class AlertMacOS {
192190
});
193191
}
194192

195-
RCTAlertManager.alertWithArgs({
196-
title: title || undefined,
197-
message: message || undefined,
198-
buttons,
199-
type: type || undefined,
200-
defaultInputs,
201-
modal: modal || undefined,
202-
critical: critical || undefined,
203-
}, (id, value) => {
204-
var cb = callbacks[id];
205-
cb && cb(value);
206-
});
193+
RCTAlertManager.alertWithArgs(
194+
{
195+
title: title || undefined,
196+
message: message || undefined,
197+
buttons,
198+
type: type || undefined,
199+
defaultInputs,
200+
modal: modal || undefined,
201+
critical: critical || undefined,
202+
},
203+
(id, value) => {
204+
var cb = callbacks[id];
205+
cb && cb(value);
206+
},
207+
);
207208
}
208209
}
209210

Libraries/Animated/src/nodes/AnimatedInterpolation.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ function interpolate(
167167

168168
function colorToRgba(input: string): string {
169169
let int32Color = normalizeColor(input);
170-
if (int32Color === null || typeof int32Color !== 'number') { // TODO(macOS ISS#2323203)
170+
if (
171+
int32Color === null ||
172+
typeof int32Color !== 'number' /* TODO(macOS ISS#2323203) */
173+
) {
171174
return input;
172175
}
173176

Libraries/Color/normalizeColor.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ export type SemanticOrDynamicColorType = {
1717
semantic?: string,
1818
dynamic?: {
1919
light: ?(string | number | SemanticOrDynamicColorType),
20-
dark: ?(string | number | SemanticOrDynamicColorType)
21-
}
20+
dark: ?(string | number | SemanticOrDynamicColorType),
21+
},
2222
}; // ]TODO(macOS ISS#2323203)
2323

24-
function normalizeColor(color: ?(string | number | SemanticOrDynamicColorType)): ?(number | SemanticOrDynamicColorType) { // TODO(macOS ISS#2323203)
24+
function normalizeColor(
25+
color: ?(
26+
| string
27+
| number
28+
| SemanticOrDynamicColorType
29+
) /* TODO(macOS ISS#2323203) */,
30+
): ?(number | SemanticOrDynamicColorType) /* TODO(macOS ISS#2323203) */ {
2531
const matchers = getMatchers();
2632
let match;
2733

@@ -32,7 +38,8 @@ function normalizeColor(color: ?(string | number | SemanticOrDynamicColorType)):
3238
return null;
3339
}
3440

35-
if (typeof color === 'object' && color !== null && Platform.OS === 'macos') { // [TODO(macOS ISS#2323203)
41+
if (typeof color === 'object' && color !== null && Platform.OS === 'macos') {
42+
// [TODO(macOS ISS#2323203)
3643
if ('semantic' in color) {
3744
// a macos semantic color
3845
return color;
@@ -42,12 +49,12 @@ function normalizeColor(color: ?(string | number | SemanticOrDynamicColorType)):
4249
const dynamicColor: SemanticOrDynamicColorType = {
4350
dynamic: {
4451
light: normalizeColor(dynamic.light),
45-
dark: normalizeColor(dynamic.dark)
46-
}
52+
dark: normalizeColor(dynamic.dark),
53+
},
4754
};
4855
return dynamicColor;
4956
}
50-
}
57+
}
5158
if (typeof color !== 'string') {
5259
return null;
5360
} // ]TODO(macOS ISS#2323203)

Libraries/Components/ActivityIndicator/ActivityIndicator.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const requireNativeComponent = require('requireNativeComponent');
1919

2020
import type {NativeComponent} from 'ReactNative';
2121
import type {ViewProps} from 'ViewPropTypes';
22+
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
2223

2324
const RCTActivityIndicator =
2425
Platform.OS === 'android'
@@ -53,7 +54,7 @@ type Props = $ReadOnly<{|
5354
*
5455
* See http://facebook.github.io/react-native/docs/activityindicator.html#color
5556
*/
56-
color?: ?string,
57+
color?: ?(string | SemanticOrDynamicColorType), // ]TODO(macOS ISS#2323203)
5758

5859
/**
5960
* Size of the indicator (default is 'small').
@@ -115,7 +116,7 @@ const ActivityIndicatorWithRef = React.forwardRef(ActivityIndicator);
115116

116117
ActivityIndicatorWithRef.defaultProps = {
117118
animating: true,
118-
color: (Platform.OS === 'ios' || Platform.OS === 'macos') ? GRAY : null, // TODO(macOS ISS#2323203)
119+
color: Platform.OS === 'ios' || Platform.OS === 'macos' ? GRAY : null, // TODO(macOS ISS#2323203)
119120
hidesWhenStopped: true,
120121
size: 'small',
121122
};

Libraries/Components/Button.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class Button extends React.Component<{
7171
*/
7272
accessibilityLabel: PropTypes.string,
7373
/**
74-
* Hint text to display blindness accessibility features
75-
*/
74+
* Hint text to display blindness accessibility features
75+
*/
7676
accessibilityHint: PropTypes.string, // TODO(OSS Candidate ISS#2710739)
7777
/**
7878
* Color of the text (iOS, macOS), or background color of the button (Android)
@@ -110,7 +110,10 @@ class Button extends React.Component<{
110110
const buttonStyles = [styles.button];
111111
const textStyles = [styles.text];
112112
if (color) {
113-
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
113+
if (
114+
Platform.OS === 'ios' ||
115+
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
116+
) {
114117
textStyles.push({color: color});
115118
} else {
116119
buttonStyles.push({backgroundColor: color});
@@ -129,11 +132,11 @@ class Button extends React.Component<{
129132
const formattedTitle =
130133
Platform.OS === 'android' ? title.toUpperCase() : title;
131134
const Touchable =
132-
(Platform.OS === 'android') // [TODO(windows ISS)
133-
? TouchableNativeFeedback
134-
: (Platform.OS === 'uwp' || Platform.OS === 'windesktop')
135-
? TouchableHighlight
136-
: TouchableOpacity; // ]TODO(windows ISS)
135+
Platform.OS === 'android' // [TODO(windows ISS)
136+
? TouchableNativeFeedback
137+
: Platform.OS === 'uwp' || Platform.OS === 'windesktop'
138+
? TouchableHighlight
139+
: TouchableOpacity; // ]TODO(windows ISS)
137140
return (
138141
<Touchable
139142
accessibilityLabel={accessibilityLabel}
@@ -164,11 +167,12 @@ const styles = StyleSheet.create({
164167
borderRadius: 2,
165168
},
166169
macos: {}, // TODO(macOS ISS#2323203)
167-
uwp: { // [TODO(windows ISS)
170+
uwp: {
171+
// [TODO(windows ISS)
168172
backgroundColor: '#2196F3',
169173
borderRadius: 2,
170174
},
171-
windesktop: {}, // ]TODO(windows ISS)
175+
windesktop: {}, // ]TODO(windows ISS)
172176
}),
173177
text: Platform.select({
174178
ios: {
@@ -184,13 +188,15 @@ const styles = StyleSheet.create({
184188
padding: 8,
185189
fontWeight: '500',
186190
},
187-
macos: { // [TODO(macOS ISS#2323203)
191+
macos: {
192+
// [TODO(macOS ISS#2323203)
188193
color: '#007AFF',
189194
textAlign: 'center',
190195
padding: 8,
191196
fontSize: 18,
192197
}, // ]TODO(macOS ISS#2323203)
193-
uwp: { // [TODO(windows ISS)
198+
uwp: {
199+
// [TODO(windows ISS)
194200
textAlign: 'center',
195201
color: 'white',
196202
padding: 8,
@@ -205,7 +211,8 @@ const styles = StyleSheet.create({
205211
backgroundColor: '#dfdfdf',
206212
},
207213
macos: {}, // TODO(macOS ISS#2323203)
208-
uwp: { // [TODO(windows ISS)
214+
uwp: {
215+
// [TODO(windows ISS)
209216
backgroundColor: '#dfdfdf',
210217
},
211218
windesktop: {}, // ]TODO(windows ISS)
@@ -214,13 +221,15 @@ const styles = StyleSheet.create({
214221
ios: {
215222
color: '#cdcdcd',
216223
},
217-
macos: { // [TODO(macOS ISS#2323203)
224+
macos: {
225+
// [TODO(macOS ISS#2323203)
218226
color: '#cdcdcd',
219227
}, // ]TODO(macOS ISS#2323203)
220228
android: {
221229
color: '#a1a1a1',
222230
},
223-
uwp: { // [TODO(windows ISS)
231+
uwp: {
232+
// [TODO(windows ISS)
224233
color: '#a1a1a1',
225234
},
226235
windesktop: {

Libraries/Components/DatePicker/DatePickerIOS.macos.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class DummyDatePickerIOS extends React.Component {
2020
render() {
2121
return (
2222
<View style={[styles.dummyDatePickerIOS, this.props.style]}>
23-
<Text style={styles.datePickerText}>DatePickerIOS is not supported on this platform!</Text>
23+
<Text style={styles.datePickerText}>
24+
DatePickerIOS is not supported on this platform!
25+
</Text>
2426
</View>
2527
);
2628
}
@@ -40,7 +42,7 @@ var styles = StyleSheet.create({
4042
datePickerText: {
4143
color: '#333333',
4244
margin: 20,
43-
}
45+
},
4446
});
4547

4648
module.exports = DummyDatePickerIOS;

Libraries/Components/DatePickerAndroid/DatePickerAndroid.macos.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
const DatePickerAndroid = {
1616
async open(options: Object): Promise<Object> {
1717
return Promise.reject({
18-
message: 'DatePickerAndroid is not supported on this platform.'
18+
message: 'DatePickerAndroid is not supported on this platform.',
1919
});
2020
},
2121
};

Libraries/Components/DatePickerMacOS/DatePickerMacOS.android.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var StyleSheet = require('StyleSheet');
1414
var Text = require('Text');
1515
var View = require('View');
1616

17-
class dummyDatePickerMacOS extends React.Component {
17+
class DummyDatePickerMacOS extends React.Component {
1818
render() {
1919
return (
2020
<View style={[styles.dummyDatePickerMacOS, this.props.style]}>
@@ -38,7 +38,7 @@ var styles = StyleSheet.create({
3838
datePickerText: {
3939
color: '#333333',
4040
margin: 20,
41-
}
41+
},
4242
});
4343

4444
module.exports = DummyDatePickerMacOS;

Libraries/Components/DatePickerMacOS/DatePickerMacOS.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var styles = StyleSheet.create({
3838
datePickerText: {
3939
color: '#333333',
4040
margin: 20,
41-
}
41+
},
4242
});
4343

4444
module.exports = DummyDatePickerMacOS;

Libraries/Components/DatePickerMacOS/DatePickerMacOS.macos.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const DatePickerMacOS = createReactClass({
147147
/>
148148
</View>
149149
);
150-
}
150+
},
151151
});
152152

153153
const RCTDatePickerMacOS = requireNativeComponent('RCTDatePicker' /* TODO refactor as class that extends React.Component<Props>, {

Libraries/Components/Picker/Picker.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ class Picker extends React.Component<{
150150
};
151151

152152
render() {
153-
if (Platform.OS === 'ios' || Platform.OS === 'macos') { // TODO(macOS ISS#2323203)
153+
if (
154+
Platform.OS === 'ios' ||
155+
Platform.OS === 'macos' /* TODO(macOS ISS#2323203) */
156+
) {
154157
// $FlowFixMe found when converting React.createClass to ES6
155158
return <PickerIOS {...this.props}>{this.props.children}</PickerIOS>;
156159
} else if (Platform.OS === 'android') {

Libraries/Components/Picker/PickerIOS.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import type {SyntheticEvent} from 'CoreEventTypes';
2424
import type {ColorValue} from 'StyleSheetTypes';
2525
import type {ViewProps} from 'ViewPropTypes';
2626
import type {TextStyleProp} from 'StyleSheet';
27-
import type {SemanticOrDynamicColorType} from 'normalizeColor' // ]TODO(macOS ISS#2323203)
27+
import type {SemanticOrDynamicColorType} from 'normalizeColor'; // ]TODO(macOS ISS#2323203)
2828

2929
type PickerIOSChangeEvent = SyntheticEvent<
3030
$ReadOnly<{|

0 commit comments

Comments
 (0)