diff --git a/Libraries/ART/ReactNativeART.js b/Libraries/ART/ReactNativeART.js index 465ddc6b13f21b..760b5ff809de40 100644 --- a/Libraries/ART/ReactNativeART.js +++ b/Libraries/ART/ReactNativeART.js @@ -297,7 +297,7 @@ function insertOffsetsIntoArray(stops, targetArray, atIndex, multi, reverse) { let i = 0; if ('length' in stops) { while (i < stops.length) { - offsetNumber = i / (stops.length - 1) * multi; + offsetNumber = (i / (stops.length - 1)) * multi; targetArray[atIndex + i] = reverse ? 1 - offsetNumber : offsetNumber; i++; } @@ -530,7 +530,7 @@ function LinearGradient(stops, x1, y1, x2, y2) { const type = LINEAR_GRADIENT; if (arguments.length < 5) { - const angle = (x1 == null ? 270 : x1) * Math.PI / 180; + const angle = ((x1 == null ? 270 : x1) * Math.PI) / 180; let x = Math.cos(angle); let y = -Math.sin(angle); diff --git a/Libraries/Animated/src/Easing.js b/Libraries/Animated/src/Easing.js index c5e54b24723ee9..94fb865882c040 100644 --- a/Libraries/Animated/src/Easing.js +++ b/Libraries/Animated/src/Easing.js @@ -131,7 +131,7 @@ class Easing { * http://easings.net/#easeInSine */ static sin(t: number) { - return 1 - Math.cos(t * Math.PI / 2); + return 1 - Math.cos((t * Math.PI) / 2); } /** @@ -164,7 +164,7 @@ class Easing { */ static elastic(bounciness: number = 1): (t: number) => number { const p = bounciness * Math.PI; - return t => 1 - Math.pow(Math.cos(t * Math.PI / 2), 3) * Math.cos(t * p); + return t => 1 - Math.pow(Math.cos((t * Math.PI) / 2), 3) * Math.cos(t * p); } /** diff --git a/Libraries/Animated/src/__tests__/Easing-test.js b/Libraries/Animated/src/__tests__/Easing-test.js index 1e2a3a2f4a7ce6..0284f3f0b697ef 100644 --- a/Libraries/Animated/src/__tests__/Easing-test.js +++ b/Libraries/Animated/src/__tests__/Easing-test.js @@ -81,7 +81,7 @@ describe('Easing', () => { function sampleEasingFunction(easing) { const DURATION = 300; - const tickCount = Math.round(DURATION * 60 / 1000); + const tickCount = Math.round((DURATION * 60) / 1000); const samples = []; for (let i = 0; i <= tickCount; i++) { samples.push(easing(i / tickCount)); diff --git a/Libraries/Animated/src/animations/DecayAnimation.js b/Libraries/Animated/src/animations/DecayAnimation.js index 78f6e2b7cc8524..a6fe05bb3f6343 100644 --- a/Libraries/Animated/src/animations/DecayAnimation.js +++ b/Libraries/Animated/src/animations/DecayAnimation.js @@ -81,8 +81,7 @@ class DecayAnimation extends Animation { const value = this._fromValue + - this._velocity / - (1 - this._deceleration) * + (this._velocity / (1 - this._deceleration)) * (1 - Math.exp(-(1 - this._deceleration) * (now - this._startTime))); this._onUpdate(value); diff --git a/Libraries/Animated/src/animations/SpringAnimation.js b/Libraries/Animated/src/animations/SpringAnimation.js index 2bc610eed752b7..a0f38d3b024e5c 100644 --- a/Libraries/Animated/src/animations/SpringAnimation.js +++ b/Libraries/Animated/src/animations/SpringAnimation.js @@ -266,7 +266,7 @@ class SpringAnimation extends Animation { position = this._toValue - envelope * - ((v0 + zeta * omega0 * x0) / omega1 * Math.sin(omega1 * t) + + (((v0 + zeta * omega0 * x0) / omega1) * Math.sin(omega1 * t) + x0 * Math.cos(omega1 * t)); // This looks crazy -- it's actually just the derivative of the // oscillation function @@ -274,7 +274,7 @@ class SpringAnimation extends Animation { zeta * omega0 * envelope * - (Math.sin(omega1 * t) * (v0 + zeta * omega0 * x0) / omega1 + + ((Math.sin(omega1 * t) * (v0 + zeta * omega0 * x0)) / omega1 + x0 * Math.cos(omega1 * t)) - envelope * (Math.cos(omega1 * t) * (v0 + zeta * omega0 * x0) - diff --git a/Libraries/Animated/src/nodes/AnimatedInterpolation.js b/Libraries/Animated/src/nodes/AnimatedInterpolation.js index e8f9823c20e4f4..067efbca731f9c 100644 --- a/Libraries/Animated/src/nodes/AnimatedInterpolation.js +++ b/Libraries/Animated/src/nodes/AnimatedInterpolation.js @@ -358,7 +358,7 @@ class AnimatedInterpolation extends AnimatedWithChildren { } if (/deg$/.test(value)) { const degrees = parseFloat(value) || 0; - const radians = degrees * Math.PI / 180.0; + const radians = (degrees * Math.PI) / 180.0; return radians; } else { // Assume radians diff --git a/Libraries/Animated/src/nodes/AnimatedModulo.js b/Libraries/Animated/src/nodes/AnimatedModulo.js index 6699ded50a658a..a3968566e9a2c4 100644 --- a/Libraries/Animated/src/nodes/AnimatedModulo.js +++ b/Libraries/Animated/src/nodes/AnimatedModulo.js @@ -32,7 +32,7 @@ class AnimatedModulo extends AnimatedWithChildren { __getValue(): number { return ( - (this._a.__getValue() % this._modulus + this._modulus) % this._modulus + ((this._a.__getValue() % this._modulus) + this._modulus) % this._modulus ); } diff --git a/Libraries/Color/normalizeColor.js b/Libraries/Color/normalizeColor.js index 690090b8c9ca0c..edede79ee6e267 100755 --- a/Libraries/Color/normalizeColor.js +++ b/Libraries/Color/normalizeColor.js @@ -188,7 +188,7 @@ function parse255(str: string): number { function parse360(str: string): number { const int = parseFloat(str); - return ((int % 360 + 360) % 360) / 360; + return (((int % 360) + 360) % 360) / 360; } function parse1(str: string): number { diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 104fabd0f53af5..4973fd4a0a3805 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -171,7 +171,10 @@ class KeyboardAvoidingView extends React.Component { return ( {children} @@ -186,9 +189,12 @@ class KeyboardAvoidingView extends React.Component { onLayout={this._onLayout} {...props}> + style={StyleSheet.compose( + contentContainerStyle, + { + bottom: bottomHeight, + }, + )}> {children} @@ -198,7 +204,10 @@ class KeyboardAvoidingView extends React.Component { return ( {children} diff --git a/Libraries/Components/Slider/Slider.js b/Libraries/Components/Slider/Slider.js index a7998ef28bfc33..aacfb14f34cb47 100644 --- a/Libraries/Components/Slider/Slider.js +++ b/Libraries/Components/Slider/Slider.js @@ -199,7 +199,10 @@ const Slider = ( forwardedRef?: ?React.Ref<'RCTActivityIndicatorView'>, |}>, ) => { - const style = StyleSheet.compose(styles.slider, props.style); + const style = StyleSheet.compose( + styles.slider, + props.style, + ); const onValueChange = props.onValueChange && diff --git a/Libraries/Components/Switch/Switch.js b/Libraries/Components/Switch/Switch.js index c1d38619a6acc5..39ccd9a1de16e2 100644 --- a/Libraries/Components/Switch/Switch.js +++ b/Libraries/Components/Switch/Switch.js @@ -134,7 +134,10 @@ class Switch extends React.Component { : this.props.tintColor, } : { - style: StyleSheet.compose(styles.rctSwitchIOS, this.props.style), + style: StyleSheet.compose( + styles.rctSwitchIOS, + this.props.style, + ), }; return ( diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index c9b1b94c9104d3..cfa4ae85808824 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -614,7 +614,11 @@ class FlatList extends React.PureComponent, void> { 'Expected array of items with numColumns > 1', ); return ( - + {item.map((it, kk) => { const element = renderItem({ item: it, diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 004599e8d76c1d..56364823f06d49 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -1369,7 +1369,7 @@ class VirtualizedList extends React.PureComponent { /* $FlowFixMe(>=0.63.0 site=react_native_fb) This comment suppresses an * error found when Flow v0.63 was deployed. To see the error delete * this comment and run Flow. */ - this.props.onEndReachedThreshold * visibleLength / 2; + (this.props.onEndReachedThreshold * visibleLength) / 2; // Mark as high priority if we're close to the start of the first item // But only if there are items before the first rendered item if (first > 0) { diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 63c7d9ecdcb66d..616d976bbe12ef 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -457,7 +457,7 @@ class ItemWithSeparator extends React.Component< static getDerivedStateFromProps( props: ItemWithSeparatorProps, prevState: ItemWithSeparatorState, - ): ?ItemWithSeparatorState { + ): ?ItemWithSeparatorState { return { separatorProps: { ...prevState.separatorProps, diff --git a/Libraries/ReactNative/YellowBox.js b/Libraries/ReactNative/YellowBox.js index 5ad6311b73b638..01a4bd82dee617 100644 --- a/Libraries/ReactNative/YellowBox.js +++ b/Libraries/ReactNative/YellowBox.js @@ -424,13 +424,14 @@ class YellowBox extends React.Component< ]; return ( - {!inspector && rows.length > 0 && ( - this.dismissWarning(null)}> - Dismiss All - - )} + {!inspector && + rows.length > 0 && ( + this.dismissWarning(null)}> + Dismiss All + + )} {rows} diff --git a/Libraries/StyleSheet/processTransform.js b/Libraries/StyleSheet/processTransform.js index 9bcfd4f4b65e22..e9076493c2890e 100644 --- a/Libraries/StyleSheet/processTransform.js +++ b/Libraries/StyleSheet/processTransform.js @@ -133,7 +133,7 @@ function _multiplyTransform( */ function _convertToRadians(value: string): number { const floatValue = parseFloat(value); - return value.indexOf('rad') > -1 ? floatValue : floatValue * Math.PI / 180; + return value.indexOf('rad') > -1 ? floatValue : (floatValue * Math.PI) / 180; } function _validateTransforms(transform: Array): void { diff --git a/Libraries/Utilities/MatrixMath.js b/Libraries/Utilities/MatrixMath.js index 6a523fa4a4a453..bb91c1d329181b 100755 --- a/Libraries/Utilities/MatrixMath.js +++ b/Libraries/Utilities/MatrixMath.js @@ -719,7 +719,7 @@ const MatrixMath = { 0, 0, MatrixMath.roundTo3Places( - Math.atan2(row[0][1], row[0][0]) * 180 / Math.PI, + (Math.atan2(row[0][1], row[0][0]) * 180) / Math.PI, ), ]; } else { diff --git a/Libraries/Utilities/__tests__/MatrixMath-test.js b/Libraries/Utilities/__tests__/MatrixMath-test.js index 8a779d3676bf09..e70fbed91477e0 100644 --- a/Libraries/Utilities/__tests__/MatrixMath-test.js +++ b/Libraries/Utilities/__tests__/MatrixMath-test.js @@ -13,7 +13,7 @@ const MatrixMath = require('MatrixMath'); function degreesToRadians(degrees) { - return degrees * Math.PI / 180; + return (degrees * Math.PI) / 180; } function convertZeroes(degrees) { diff --git a/Libraries/WebSocket/WebSocket.js b/Libraries/WebSocket/WebSocket.js index 578d55e55d9c29..bef05b0d70e8cb 100644 --- a/Libraries/WebSocket/WebSocket.js +++ b/Libraries/WebSocket/WebSocket.js @@ -145,7 +145,12 @@ class WebSocket extends EventTarget(...WEBSOCKET_EVENTS) { this._eventEmitter = new NativeEventEmitter(WebSocketModule); this._socketId = nextWebSocketId++; this._registerEvents(); - WebSocketModule.connect(url, protocols, {headers}, this._socketId); + WebSocketModule.connect( + url, + protocols, + {headers}, + this._socketId, + ); } get binaryType(): ?BinaryType { diff --git a/RNTester/js/AlertExample.js b/RNTester/js/AlertExample.js index 02382e769ebba1..b573356919d898 100644 --- a/RNTester/js/AlertExample.js +++ b/RNTester/js/AlertExample.js @@ -121,8 +121,9 @@ class SimpleAlertExampleBlock extends React.Component { class AlertExample extends React.Component { static title = 'Alert'; - static description = 'Alerts display a concise and informative message ' + - 'and prompt the user to make a decision.'; + static description = + 'Alerts display a concise and informative message ' + + 'and prompt the user to make a decision.'; render() { return ( diff --git a/RNTester/js/AnimatedGratuitousApp/AnExApp.js b/RNTester/js/AnimatedGratuitousApp/AnExApp.js index 1ade55e2ffc8a9..5131f9641ca5d6 100644 --- a/RNTester/js/AnimatedGratuitousApp/AnExApp.js +++ b/RNTester/js/AnimatedGratuitousApp/AnExApp.js @@ -193,8 +193,9 @@ class Circle extends React.Component { class AnExApp extends React.Component { static title = 'Animated - Gratuitous App'; - static description = 'Bunch of Animations - tap a circle to ' + - 'open a view with more animations, or longPress and drag to reorder circles.'; + static description = + 'Bunch of Animations - tap a circle to ' + + 'open a view with more animations, or longPress and drag to reorder circles.'; _onMove: (position: Point) => void; constructor(props: any): void { diff --git a/RNTester/js/DatePickerIOSExample.js b/RNTester/js/DatePickerIOSExample.js index 5bd76259742ef4..ec338471d6937a 100644 --- a/RNTester/js/DatePickerIOSExample.js +++ b/RNTester/js/DatePickerIOSExample.js @@ -20,7 +20,7 @@ class DatePickerExample extends React.Component< > { static defaultProps = { date: new Date(), - timeZoneOffsetInHours: -1 * new Date().getTimezoneOffset() / 60, + timeZoneOffsetInHours: (-1 * new Date().getTimezoneOffset()) / 60, }; state = { diff --git a/RNTester/js/ImageExample.js b/RNTester/js/ImageExample.js index 2125e2669e7267..5465b6608117ef 100644 --- a/RNTester/js/ImageExample.js +++ b/RNTester/js/ImageExample.js @@ -158,7 +158,7 @@ var NetworkImageExample = createReactClass({ onProgress={e => this.setState({ progress: Math.round( - 100 * e.nativeEvent.loaded / e.nativeEvent.total, + (100 * e.nativeEvent.loaded) / e.nativeEvent.total, ), }) } diff --git a/RNTester/js/InputAccessoryViewExample.js b/RNTester/js/InputAccessoryViewExample.js index 45b63e20d9f5da..a848b961436e4e 100644 --- a/RNTester/js/InputAccessoryViewExample.js +++ b/RNTester/js/InputAccessoryViewExample.js @@ -60,7 +60,8 @@ class TextInputBar extends React.PureComponent<*, *> { class InputAccessoryViewExample extends React.Component<*> { static title = ''; - static description = 'Example showing how to use an InputAccessoryView to build an iMessage-like sticky text input'; + static description = + 'Example showing how to use an InputAccessoryView to build an iMessage-like sticky text input'; render() { return ( diff --git a/RNTester/js/KeyboardAvoidingViewExample.js b/RNTester/js/KeyboardAvoidingViewExample.js index 2e51ed842016e9..0e86e432d79f58 100644 --- a/RNTester/js/KeyboardAvoidingViewExample.js +++ b/RNTester/js/KeyboardAvoidingViewExample.js @@ -27,7 +27,8 @@ const RNTesterPage = require('./RNTesterPage'); class KeyboardAvoidingViewExample extends React.Component { static title = ''; - static description = 'Base component for views that automatically adjust their height or position to move out of the way of the keyboard.'; + static description = + 'Base component for views that automatically adjust their height or position to move out of the way of the keyboard.'; state = { behavior: 'padding', diff --git a/RNTester/js/ListExampleShared.js b/RNTester/js/ListExampleShared.js index 0edb7fe181ad88..905985b52b28af 100644 --- a/RNTester/js/ListExampleShared.js +++ b/RNTester/js/ListExampleShared.js @@ -38,7 +38,7 @@ function genItemData(count: number, start: number = 0): Array { const itemHash = Math.abs(hashCode('Item ' + ii)); dataBlob.push({ title: 'Item ' + ii, - text: LOREM_IPSUM.substr(0, itemHash % 301 + 20), + text: LOREM_IPSUM.substr(0, (itemHash % 301) + 20), key: String(ii), pressed: false, }); diff --git a/RNTester/js/ListViewExample.js b/RNTester/js/ListViewExample.js index 9e008dd400b713..a274c353949f59 100644 --- a/RNTester/js/ListViewExample.js +++ b/RNTester/js/ListViewExample.js @@ -70,7 +70,7 @@ var ListViewSimpleExample = createReactClass({ - {rowData + ' - ' + LOREM_IPSUM.substr(0, rowHash % 301 + 10)} + {rowData + ' - ' + LOREM_IPSUM.substr(0, (rowHash % 301) + 10)} diff --git a/RNTester/js/MaskedViewExample.js b/RNTester/js/MaskedViewExample.js index 081496b6f1b6d4..b944fbc16f7366 100644 --- a/RNTester/js/MaskedViewExample.js +++ b/RNTester/js/MaskedViewExample.js @@ -24,7 +24,8 @@ const { class MaskedViewExample extends React.Component<{}, $FlowFixMeState> { static title = ''; - static description = 'Renders the child view with a mask specified in the `renderMask` prop.'; + static description = + 'Renders the child view with a mask specified in the `renderMask` prop.'; state = { alternateChildren: true, diff --git a/RNTester/js/PickerExample.js b/RNTester/js/PickerExample.js index 6026ac74eb4da4..0fd21fc7de32ea 100644 --- a/RNTester/js/PickerExample.js +++ b/RNTester/js/PickerExample.js @@ -22,7 +22,8 @@ const Item = Picker.Item; class PickerExample extends React.Component<{}, $FlowFixMeState> { static title = ''; - static description = 'Provides multiple options to choose from, using either a dropdown menu or a dialog.'; + static description = + 'Provides multiple options to choose from, using either a dropdown menu or a dialog.'; state = { selected1: 'key1', diff --git a/RNTester/js/RTLExample.js b/RNTester/js/RTLExample.js index b833adfcbe3c27..bab56a1d36919a 100644 --- a/RNTester/js/RTLExample.js +++ b/RNTester/js/RTLExample.js @@ -373,7 +373,8 @@ const BorderExample = withRTLState(({isRTL, setRTL}) => { class RTLExample extends React.Component { static title = 'RTLExample'; - static description = 'Examples to show how to apply components to RTL layout.'; + static description = + 'Examples to show how to apply components to RTL layout.'; _panResponder: Object; diff --git a/RNTester/js/ScrollViewSimpleExample.js b/RNTester/js/ScrollViewSimpleExample.js index 85c4147470d2b5..b7d95b2fb2f929 100644 --- a/RNTester/js/ScrollViewSimpleExample.js +++ b/RNTester/js/ScrollViewSimpleExample.js @@ -18,7 +18,8 @@ var NUM_ITEMS = 20; class ScrollViewSimpleExample extends React.Component<{}> { static title = ''; - static description = 'Component that enables scrolling through child components.'; + static description = + 'Component that enables scrolling through child components.'; makeItems = (nItems: number, styles): Array => { var items = []; diff --git a/RNTester/js/SwipeableListViewExample.js b/RNTester/js/SwipeableListViewExample.js index 1fec55d93e43fa..ee359ed1fcf6d9 100644 --- a/RNTester/js/SwipeableListViewExample.js +++ b/RNTester/js/SwipeableListViewExample.js @@ -94,7 +94,7 @@ var SwipeableListViewSimpleExample = createReactClass({ - {rowData.id + ' - ' + LOREM_IPSUM.substr(0, rowHash % 301 + 10)} + {rowData.id + ' - ' + LOREM_IPSUM.substr(0, (rowHash % 301) + 10)} diff --git a/RNTester/js/ToastAndroidExample.android.js b/RNTester/js/ToastAndroidExample.android.js index 7274fa969cf13a..80ea97715ba30b 100644 --- a/RNTester/js/ToastAndroidExample.android.js +++ b/RNTester/js/ToastAndroidExample.android.js @@ -19,7 +19,8 @@ var RNTesterPage = require('RNTesterPage'); class ToastExample extends React.Component<{}, $FlowFixMeState> { static title = 'Toast Example'; - static description = 'Example that demonstrates the use of an Android Toast to provide feedback.'; + static description = + 'Example that demonstrates the use of an Android Toast to provide feedback.'; state = {}; render() { diff --git a/RNTester/js/ViewPagerAndroidExample.android.js b/RNTester/js/ViewPagerAndroidExample.android.js index 1eb60ad3d6c681..f4aaca4a098411 100644 --- a/RNTester/js/ViewPagerAndroidExample.android.js +++ b/RNTester/js/ViewPagerAndroidExample.android.js @@ -81,7 +81,7 @@ class ProgressBar extends React.Component { render() { var fractionalPosition = this.props.progress.position + this.props.progress.offset; - var progressBarSize = fractionalPosition / (PAGES - 1) * this.props.size; + var progressBarSize = (fractionalPosition / (PAGES - 1)) * this.props.size; return ( @@ -92,7 +92,8 @@ class ProgressBar extends React.Component { class ViewPagerAndroidExample extends React.Component { static title = ''; - static description = 'Container that allows to flip left and right between child views.'; + static description = + 'Container that allows to flip left and right between child views.'; state = { page: 0, diff --git a/local-cli/bundle/saveAssets.js b/local-cli/bundle/saveAssets.js index b069c332b48d0a..0961ed7d525d00 100644 --- a/local-cli/bundle/saveAssets.js +++ b/local-cli/bundle/saveAssets.js @@ -75,8 +75,7 @@ function copy(src, dest, callback) { if (err) { return callback(err); } - fs - .createReadStream(src) + fs.createReadStream(src) .pipe(fs.createWriteStream(dest)) .on('finish', callback); }); diff --git a/local-cli/link/android/patches/makeBuildPatch.js b/local-cli/link/android/patches/makeBuildPatch.js index 1ee9fb7d5fc65e..dfaab8f6998bfe 100644 --- a/local-cli/link/android/patches/makeBuildPatch.js +++ b/local-cli/link/android/patches/makeBuildPatch.js @@ -18,6 +18,6 @@ module.exports = function makeBuildPatch(name) { return { installPattern, pattern: /[^ \t]dependencies {(\r\n|\n)/, - patch: ` compile project(':${normalizedProjectName}')\n` + patch: ` compile project(':${normalizedProjectName}')\n`, }; }; diff --git a/package.json b/package.json index 9eb0e2bb55602f..f36d371e663014 100644 --- a/package.json +++ b/package.json @@ -215,7 +215,7 @@ "flow-bin": "^0.73.0", "jest": "23.1.0", "jest-junit": "4.0.0", - "prettier": "1.12.1", + "prettier": "1.13.4", "react": "16.3.2", "react-test-renderer": "16.3.2", "shelljs": "^0.7.8",