Skip to content

Commit 46919e9

Browse files
committed
Merge branch 'master' into muhammad/arch-64-fb-submit-master
* master: Fix NullPointerException when emiting event using UIManagerModule Fixed concurrency issue in remote debugger Fix ReactImagePropertyTest SoLoader failures (facebook#19607) Remove unused include. (facebook#19548) Update Danger token (facebook#19606) Modified deepFreezeAndThrowOnMutationInDev to use Object.prototype.ha… (facebook#19598) Change error message on interpolation (facebook#19571) Bump Prettier to 1.13.4 on xplat Fix/security issues (facebook#19373) Add open source Flow declaration for Metro module Use correct library reference for libfishhook.a in RCTWebSocket (facebook#19579) Enable proguard for Fabric in release builds Fix events not working after closing and navigating back to Fabric screen in FB4A
2 parents b0851f7 + 291c01f commit 46919e9

Some content is hidden

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

49 files changed

+184
-95
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,9 @@ jobs:
567567
- run:
568568
name: Analyze Pull Request
569569
command: |
570-
# DANGER_GITHUB_API_TOKEN=Facebook-Open-Source-Bot public_repo access token
570+
# DANGER_GITHUB_API_TOKEN=React-Linter public_repo access token
571571
if [ -n "$CIRCLE_PR_NUMBER" ]; then
572-
cd bots && DANGER_GITHUB_API_TOKEN="b186c9a82bab3b08ec80""c0818117619eec6f281a" yarn danger
572+
cd bots && DANGER_GITHUB_API_TOKEN="80aa64c50f38a267e9ba""575d41d528f9c234edb8" yarn danger
573573
else
574574
echo "Skipping pull request analysis."
575575
fi

Libraries/ART/ReactNativeART.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ function insertOffsetsIntoArray(stops, targetArray, atIndex, multi, reverse) {
297297
let i = 0;
298298
if ('length' in stops) {
299299
while (i < stops.length) {
300-
offsetNumber = i / (stops.length - 1) * multi;
300+
offsetNumber = (i / (stops.length - 1)) * multi;
301301
targetArray[atIndex + i] = reverse ? 1 - offsetNumber : offsetNumber;
302302
i++;
303303
}
@@ -530,7 +530,7 @@ function LinearGradient(stops, x1, y1, x2, y2) {
530530
const type = LINEAR_GRADIENT;
531531

532532
if (arguments.length < 5) {
533-
const angle = (x1 == null ? 270 : x1) * Math.PI / 180;
533+
const angle = ((x1 == null ? 270 : x1) * Math.PI) / 180;
534534

535535
let x = Math.cos(angle);
536536
let y = -Math.sin(angle);

Libraries/Animated/src/Easing.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Easing {
131131
* http://easings.net/#easeInSine
132132
*/
133133
static sin(t: number) {
134-
return 1 - Math.cos(t * Math.PI / 2);
134+
return 1 - Math.cos((t * Math.PI) / 2);
135135
}
136136

137137
/**
@@ -164,7 +164,7 @@ class Easing {
164164
*/
165165
static elastic(bounciness: number = 1): (t: number) => number {
166166
const p = bounciness * Math.PI;
167-
return t => 1 - Math.pow(Math.cos(t * Math.PI / 2), 3) * Math.cos(t * p);
167+
return t => 1 - Math.pow(Math.cos((t * Math.PI) / 2), 3) * Math.cos(t * p);
168168
}
169169

170170
/**

Libraries/Animated/src/__tests__/Easing-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe('Easing', () => {
8181

8282
function sampleEasingFunction(easing) {
8383
const DURATION = 300;
84-
const tickCount = Math.round(DURATION * 60 / 1000);
84+
const tickCount = Math.round((DURATION * 60) / 1000);
8585
const samples = [];
8686
for (let i = 0; i <= tickCount; i++) {
8787
samples.push(easing(i / tickCount));

Libraries/Animated/src/animations/DecayAnimation.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ class DecayAnimation extends Animation {
8181

8282
const value =
8383
this._fromValue +
84-
this._velocity /
85-
(1 - this._deceleration) *
84+
(this._velocity / (1 - this._deceleration)) *
8685
(1 - Math.exp(-(1 - this._deceleration) * (now - this._startTime)));
8786

8887
this._onUpdate(value);

Libraries/Animated/src/animations/SpringAnimation.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,15 @@ class SpringAnimation extends Animation {
266266
position =
267267
this._toValue -
268268
envelope *
269-
((v0 + zeta * omega0 * x0) / omega1 * Math.sin(omega1 * t) +
269+
(((v0 + zeta * omega0 * x0) / omega1) * Math.sin(omega1 * t) +
270270
x0 * Math.cos(omega1 * t));
271271
// This looks crazy -- it's actually just the derivative of the
272272
// oscillation function
273273
velocity =
274274
zeta *
275275
omega0 *
276276
envelope *
277-
(Math.sin(omega1 * t) * (v0 + zeta * omega0 * x0) / omega1 +
277+
((Math.sin(omega1 * t) * (v0 + zeta * omega0 * x0)) / omega1 +
278278
x0 * Math.cos(omega1 * t)) -
279279
envelope *
280280
(Math.cos(omega1 * t) * (v0 + zeta * omega0 * x0) -

Libraries/Animated/src/nodes/AnimatedInterpolation.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function checkValidInputRange(arr: Array<number>) {
285285
* mean this implicit string conversion, you can do something like
286286
* String(myThing)
287287
*/
288-
'inputRange must be monotonically increasing ' + arr,
288+
'inputRange must be monotonically non-decreasing ' + arr,
289289
);
290290
}
291291
}
@@ -358,7 +358,7 @@ class AnimatedInterpolation extends AnimatedWithChildren {
358358
}
359359
if (/deg$/.test(value)) {
360360
const degrees = parseFloat(value) || 0;
361-
const radians = degrees * Math.PI / 180.0;
361+
const radians = (degrees * Math.PI) / 180.0;
362362
return radians;
363363
} else {
364364
// Assume radians

Libraries/Animated/src/nodes/AnimatedModulo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AnimatedModulo extends AnimatedWithChildren {
3232

3333
__getValue(): number {
3434
return (
35-
(this._a.__getValue() % this._modulus + this._modulus) % this._modulus
35+
((this._a.__getValue() % this._modulus) + this._modulus) % this._modulus
3636
);
3737
}
3838

Libraries/Color/normalizeColor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function parse255(str: string): number {
188188

189189
function parse360(str: string): number {
190190
const int = parseFloat(str);
191-
return ((int % 360 + 360) % 360) / 360;
191+
return (((int % 360) + 360) % 360) / 360;
192192
}
193193

194194
function parse1(str: string): number {

Libraries/Components/Keyboard/KeyboardAvoidingView.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
171171
return (
172172
<View
173173
ref={viewRef}
174-
style={StyleSheet.compose(style, heightStyle)}
174+
style={StyleSheet.compose(
175+
style,
176+
heightStyle,
177+
)}
175178
onLayout={this._onLayout}
176179
{...props}>
177180
{children}
@@ -186,9 +189,12 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
186189
onLayout={this._onLayout}
187190
{...props}>
188191
<View
189-
style={StyleSheet.compose(contentContainerStyle, {
190-
bottom: bottomHeight,
191-
})}>
192+
style={StyleSheet.compose(
193+
contentContainerStyle,
194+
{
195+
bottom: bottomHeight,
196+
},
197+
)}>
192198
{children}
193199
</View>
194200
</View>
@@ -198,7 +204,10 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
198204
return (
199205
<View
200206
ref={viewRef}
201-
style={StyleSheet.compose(style, {paddingBottom: bottomHeight})}
207+
style={StyleSheet.compose(
208+
style,
209+
{paddingBottom: bottomHeight},
210+
)}
202211
onLayout={this._onLayout}
203212
{...props}>
204213
{children}

Libraries/Components/Slider/Slider.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ const Slider = (
199199
forwardedRef?: ?React.Ref<'RCTActivityIndicatorView'>,
200200
|}>,
201201
) => {
202-
const style = StyleSheet.compose(styles.slider, props.style);
202+
const style = StyleSheet.compose(
203+
styles.slider,
204+
props.style,
205+
);
203206

204207
const onValueChange =
205208
props.onValueChange &&

Libraries/Components/Switch/Switch.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ class Switch extends React.Component<Props> {
134134
: this.props.tintColor,
135135
}
136136
: {
137-
style: StyleSheet.compose(styles.rctSwitchIOS, this.props.style),
137+
style: StyleSheet.compose(
138+
styles.rctSwitchIOS,
139+
this.props.style,
140+
),
138141
};
139142

140143
return (

Libraries/Lists/FlatList.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,11 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
614614
'Expected array of items with numColumns > 1',
615615
);
616616
return (
617-
<View style={StyleSheet.compose(styles.row, columnWrapperStyle)}>
617+
<View
618+
style={StyleSheet.compose(
619+
styles.row,
620+
columnWrapperStyle,
621+
)}>
618622
{item.map((it, kk) => {
619623
const element = renderItem({
620624
item: it,

Libraries/Lists/VirtualizedList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
13691369
/* $FlowFixMe(>=0.63.0 site=react_native_fb) This comment suppresses an
13701370
* error found when Flow v0.63 was deployed. To see the error delete
13711371
* this comment and run Flow. */
1372-
this.props.onEndReachedThreshold * visibleLength / 2;
1372+
(this.props.onEndReachedThreshold * visibleLength) / 2;
13731373
// Mark as high priority if we're close to the start of the first item
13741374
// But only if there are items before the first rendered item
13751375
if (first > 0) {

Libraries/Lists/VirtualizedSectionList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ class ItemWithSeparator extends React.Component<
457457
static getDerivedStateFromProps(
458458
props: ItemWithSeparatorProps,
459459
prevState: ItemWithSeparatorState,
460-
): ?ItemWithSeparatorState {
460+
): ?ItemWithSeparatorState {
461461
return {
462462
separatorProps: {
463463
...prevState.separatorProps,

Libraries/ReactNative/YellowBox.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,14 @@ class YellowBox extends React.Component<
424424
];
425425
return (
426426
<View style={inspector ? styles.fullScreen : listStyle}>
427-
{!inspector && rows.length > 0 && (
428-
<TouchableHighlight
429-
style={styles.dismissAllContainer}
430-
onPress={() => this.dismissWarning(null)}>
431-
<Text style={styles.dismissAll}>Dismiss All</Text>
432-
</TouchableHighlight>
433-
)}
427+
{!inspector &&
428+
rows.length > 0 && (
429+
<TouchableHighlight
430+
style={styles.dismissAllContainer}
431+
onPress={() => this.dismissWarning(null)}>
432+
<Text style={styles.dismissAll}>Dismiss All</Text>
433+
</TouchableHighlight>
434+
)}
434435
<ScrollView style={listStyle} scrollsToTop={false}>
435436
{rows}
436437
</ScrollView>

Libraries/StyleSheet/processTransform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function _multiplyTransform(
133133
*/
134134
function _convertToRadians(value: string): number {
135135
const floatValue = parseFloat(value);
136-
return value.indexOf('rad') > -1 ? floatValue : floatValue * Math.PI / 180;
136+
return value.indexOf('rad') > -1 ? floatValue : (floatValue * Math.PI) / 180;
137137
}
138138

139139
function _validateTransforms(transform: Array<Object>): void {

Libraries/Utilities/MatrixMath.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ const MatrixMath = {
719719
0,
720720
0,
721721
MatrixMath.roundTo3Places(
722-
Math.atan2(row[0][1], row[0][0]) * 180 / Math.PI,
722+
(Math.atan2(row[0][1], row[0][0]) * 180) / Math.PI,
723723
),
724724
];
725725
} else {

Libraries/Utilities/__tests__/MatrixMath-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
const MatrixMath = require('MatrixMath');
1414

1515
function degreesToRadians(degrees) {
16-
return degrees * Math.PI / 180;
16+
return (degrees * Math.PI) / 180;
1717
}
1818

1919
function convertZeroes(degrees) {

Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ describe('deepFreezeAndThrowOnMutationInDev', function() {
2626
expect(() => deepFreezeAndThrowOnMutationInDev()).not.toThrow();
2727
});
2828

29+
it('should not throw on object without prototype', () => {
30+
__DEV__ = true;
31+
var o = Object.create(null);
32+
o.key = 'Value';
33+
expect(() => deepFreezeAndThrowOnMutationInDev(o)).not.toThrow();
34+
});
35+
2936
it('should throw on mutation in dev with strict', () => {
3037
'use strict';
3138
__DEV__ = true;

Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,17 @@ function deepFreezeAndThrowOnMutationInDev<T: Object>(object: T): T {
3939
}
4040

4141
const keys = Object.keys(object);
42+
const hasOwnProperty = Object.prototype.hasOwnProperty;
4243

4344
for (var i = 0; i < keys.length; i++) {
4445
var key = keys[i];
45-
if (object.hasOwnProperty(key)) {
46-
object.__defineGetter__(key, identity.bind(null, object[key]));
47-
object.__defineSetter__(key, throwOnImmutableMutation.bind(null, key));
46+
if (hasOwnProperty.call(object, key)) {
47+
Object.defineProperty(object, key, {
48+
get: identity.bind(null, object[key]),
49+
});
50+
Object.defineProperty(object, key, {
51+
set: throwOnImmutableMutation.bind(null, key),
52+
});
4853
}
4954
}
5055

@@ -53,7 +58,7 @@ function deepFreezeAndThrowOnMutationInDev<T: Object>(object: T): T {
5358

5459
for (var i = 0; i < keys.length; i++) {
5560
var key = keys[i];
56-
if (object.hasOwnProperty(key)) {
61+
if (hasOwnProperty.call(object, key)) {
5762
deepFreezeAndThrowOnMutationInDev(object[key]);
5863
}
5964
}

Libraries/WebSocket/RCTWebSocket.xcodeproj/project.pbxproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
1338BBE01B04ACC80064A9C9 /* RCTSRWebSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 1338BBDD1B04ACC80064A9C9 /* RCTSRWebSocket.m */; };
1111
1338BBE11B04ACC80064A9C9 /* RCTWebSocketExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = 1338BBDF1B04ACC80064A9C9 /* RCTWebSocketExecutor.m */; };
12-
13526A521F362F7F0008EF00 /* libfishhook.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13526A511F362F7F0008EF00 /* libfishhook.a */; };
12+
2D3ABDC220C7206E00DF56E9 /* libfishhook.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DBE0D001F3B181A0099AA32 /* libfishhook.a */; };
1313
2D3B5F3D1D9B165B00451313 /* RCTSRWebSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 1338BBDD1B04ACC80064A9C9 /* RCTSRWebSocket.m */; };
1414
2D3B5F3E1D9B165B00451313 /* RCTWebSocketExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = 1338BBDF1B04ACC80064A9C9 /* RCTWebSocketExecutor.m */; };
1515
2D3B5F401D9B165B00451313 /* RCTWebSocketModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C86DF7B1ADF695F0047B81A /* RCTWebSocketModule.m */; };
@@ -87,7 +87,7 @@
8787
isa = PBXFrameworksBuildPhase;
8888
buildActionMask = 2147483647;
8989
files = (
90-
13526A521F362F7F0008EF00 /* libfishhook.a in Frameworks */,
90+
2D3ABDC220C7206E00DF56E9 /* libfishhook.a in Frameworks */,
9191
);
9292
runOnlyForDeploymentPostprocessing = 0;
9393
};
@@ -435,7 +435,7 @@
435435
EXECUTABLE_PREFIX = lib;
436436
GCC_PREPROCESSOR_DEFINITIONS = (
437437
"DEBUG=1",
438-
"RCT_METRO_PORT=${RCT_METRO_PORT}",
438+
"RCT_METRO_PORT=${RCT_METRO_PORT}",
439439
"$(inherited)",
440440
);
441441
GCC_TREAT_WARNINGS_AS_ERRORS = NO;

Libraries/WebSocket/WebSocket.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ class WebSocket extends EventTarget(...WEBSOCKET_EVENTS) {
145145
this._eventEmitter = new NativeEventEmitter(WebSocketModule);
146146
this._socketId = nextWebSocketId++;
147147
this._registerEvents();
148-
WebSocketModule.connect(url, protocols, {headers}, this._socketId);
148+
WebSocketModule.connect(
149+
url,
150+
protocols,
151+
{headers},
152+
this._socketId,
153+
);
149154
}
150155

151156
get binaryType(): ?BinaryType {

RNTester/js/AlertExample.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ class SimpleAlertExampleBlock extends React.Component {
121121
class AlertExample extends React.Component {
122122
static title = 'Alert';
123123

124-
static description = 'Alerts display a concise and informative message ' +
125-
'and prompt the user to make a decision.';
124+
static description =
125+
'Alerts display a concise and informative message ' +
126+
'and prompt the user to make a decision.';
126127

127128
render() {
128129
return (

RNTester/js/AnimatedGratuitousApp/AnExApp.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ class Circle extends React.Component<any, any> {
193193

194194
class AnExApp extends React.Component<any, any> {
195195
static title = 'Animated - Gratuitous App';
196-
static description = 'Bunch of Animations - tap a circle to ' +
197-
'open a view with more animations, or longPress and drag to reorder circles.';
196+
static description =
197+
'Bunch of Animations - tap a circle to ' +
198+
'open a view with more animations, or longPress and drag to reorder circles.';
198199

199200
_onMove: (position: Point) => void;
200201
constructor(props: any): void {

RNTester/js/DatePickerIOSExample.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DatePickerExample extends React.Component<
2020
> {
2121
static defaultProps = {
2222
date: new Date(),
23-
timeZoneOffsetInHours: -1 * new Date().getTimezoneOffset() / 60,
23+
timeZoneOffsetInHours: (-1 * new Date().getTimezoneOffset()) / 60,
2424
};
2525

2626
state = {

RNTester/js/ImageExample.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ var NetworkImageExample = createReactClass({
158158
onProgress={e =>
159159
this.setState({
160160
progress: Math.round(
161-
100 * e.nativeEvent.loaded / e.nativeEvent.total,
161+
(100 * e.nativeEvent.loaded) / e.nativeEvent.total,
162162
),
163163
})
164164
}

0 commit comments

Comments
 (0)