From 0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Tue, 24 Mar 2020 21:35:58 -0700 Subject: [PATCH] Back out "Upgrade Prettier from 1.17 to 2.0.2." Differential Revision: D20639755 fbshipit-source-id: 5028563f9cf0527a30b4259daac50cdc03934bfd --- IntegrationTests/AccessibilityManagerTest.js | 2 +- IntegrationTests/AsyncStorageTest.js | 19 ++- IntegrationTests/ImageCachePolicyTest.js | 2 +- IntegrationTests/IntegrationTestsApp.js | 4 +- IntegrationTests/LayoutEventsTest.js | 6 +- IntegrationTests/LoggingTestModule.js | 14 +- .../RCTRootViewIntegrationTestApp.js | 4 +- IntegrationTests/SyncMethodTest.js | 2 +- IntegrationTests/TimersTest.js | 2 +- IntegrationTests/WebSocketTest.js | 10 +- Libraries/Alert/Alert.js | 2 +- Libraries/Alert/RCTAlertManager.android.js | 2 +- Libraries/Animated/release/gulpfile.js | 16 +-- Libraries/Animated/src/AnimatedEvent.js | 10 +- .../Animated/src/AnimatedImplementation.js | 106 +++++++------- Libraries/Animated/src/AnimatedMock.js | 18 +-- Libraries/Animated/src/Easing.js | 9 +- .../Animated/src/NativeAnimatedHelper.js | 45 +++--- .../src/__tests__/AnimatedMock-test.js | 4 +- .../src/__tests__/AnimatedNative-test.js | 88 ++++-------- .../Animated/src/__tests__/Easing-test.js | 4 +- .../Animated/src/__tests__/bezier-test.js | 56 ++++---- .../Animated/src/createAnimatedComponent.js | 4 +- .../src/nodes/AnimatedInterpolation.js | 8 +- Libraries/Animated/src/nodes/AnimatedNode.js | 2 +- .../Animated/src/nodes/AnimatedTransform.js | 12 +- Libraries/Animated/src/nodes/AnimatedValue.js | 6 +- .../src/polyfills/InteractionManager.js | 4 +- Libraries/Animated/src/polyfills/Set.js | 4 +- .../Animated/src/polyfills/flattenStyle.js | 2 +- Libraries/AppState/AppState.js | 8 +- Libraries/BatchedBridge/MessageQueue.js | 6 +- Libraries/BatchedBridge/NativeModules.js | 4 +- .../__mocks__/MessageQueueTestModule.js | 4 +- .../__tests__/MessageQueue-test.js | 24 +--- .../__tests__/NativeModules-test.js | 22 +-- Libraries/Blob/BlobManager.js | 4 +- Libraries/Blob/FileReader.js | 6 +- Libraries/Blob/URL.js | 6 +- Libraries/Blob/__tests__/Blob-test.js | 2 +- Libraries/Blob/__tests__/BlobManager-test.js | 2 +- Libraries/Blob/__tests__/File-test.js | 10 +- Libraries/Blob/__tests__/FileReader-test.js | 2 +- Libraries/Blob/__tests__/URL-test.js | 2 +- .../AccessibilityInfo.android.js | 24 ++-- .../AccessibilityInfo.ios.js | 20 +-- .../ActivityIndicator/ActivityIndicator.js | 5 +- .../Components/AppleTV/TVEventHandler.js | 2 +- .../Components/CheckBox/CheckBox.android.js | 2 +- .../DatePicker/DatePickerIOS.ios.js | 2 +- .../DrawerLayoutAndroid.android.js | 4 +- Libraries/Components/Keyboard/Keyboard.js | 2 +- .../Keyboard/KeyboardAvoidingView.js | 21 ++- .../Keyboard/__tests__/Keyboard-test.js | 2 +- .../Picker/PickerAndroid.android.js | 7 +- Libraries/Components/Picker/PickerIOS.ios.js | 8 +- Libraries/Components/ScrollResponder.js | 64 ++++----- Libraries/Components/ScrollView/ScrollView.js | 16 +-- .../ScrollView/ScrollViewStickyHeader.js | 2 +- Libraries/Components/Slider/Slider.js | 5 +- Libraries/Components/Sound/SoundManager.js | 2 +- Libraries/Components/StatusBar/StatusBar.js | 4 +- Libraries/Components/TextInput/TextInput.js | 2 +- .../TextInput/__tests__/TextInput-test.js | 8 +- .../ToastAndroid/ToastAndroid.android.js | 6 +- .../ToastAndroid/ToastAndroid.ios.js | 6 +- .../Touchable/BoundingDimensions.js | 4 +- Libraries/Components/Touchable/PooledClass.js | 12 +- Libraries/Components/Touchable/Position.js | 2 +- Libraries/Components/Touchable/Touchable.js | 52 +++---- .../Components/Touchable/TouchableBounce.js | 18 +-- .../Touchable/TouchableHighlight.js | 18 +-- .../Touchable/TouchableNativeFeedback.js | 12 +- .../Components/Touchable/TouchableOpacity.js | 14 +- .../Touchable/TouchableWithoutFeedback.js | 6 +- .../Touchable/ensurePositiveDelayProps.js | 2 +- .../__tests__/parseErrorStack-test.js | 8 +- Libraries/Core/Devtools/parseErrorStack.js | 2 +- Libraries/Core/ExceptionsManager.js | 6 +- Libraries/Core/Timers/JSTimers.js | 38 +++-- .../Core/Timers/__tests__/JSTimers-test.js | 134 +++++++++--------- Libraries/Core/__mocks__/ErrorUtils.js | 2 +- .../Core/__tests__/ExceptionsManager-test.js | 12 +- .../__tests__/ReactNativeVersionCheck-test.js | 2 +- Libraries/Core/setUpAlert.js | 2 +- Libraries/Core/setUpDeveloperTools.js | 4 +- Libraries/Core/setUpTimers.js | 2 +- .../DeprecatedColorPropType.js | 2 +- .../DeprecatedStyleSheetPropType.js | 2 +- .../DeprecatedTransformPropTypes.js | 4 +- Libraries/HeapCapture/HeapCapture.js | 2 +- Libraries/Image/Image.android.js | 10 +- Libraries/Image/Image.ios.js | 6 +- Libraries/Image/ImageBackground.js | 2 +- Libraries/Image/ImagePickerIOS.js | 12 +- .../__tests__/resolveAssetSource-test.js | 4 +- Libraries/Inspector/ElementProperties.js | 4 +- Libraries/Inspector/Inspector.js | 6 +- Libraries/Inspector/InspectorPanel.js | 2 +- Libraries/Inspector/NetworkOverlay.js | 4 +- Libraries/Inspector/StyleInspector.js | 4 +- .../Interaction/BridgeSpyStallHandler.js | 8 +- Libraries/Interaction/FrameRateLogger.js | 4 +- Libraries/Interaction/InteractionManager.js | 8 +- Libraries/Interaction/InteractionMixin.js | 10 +- Libraries/Interaction/JSEventLoopWatchdog.js | 12 +- Libraries/Interaction/TaskQueue.js | 12 +- Libraries/Interaction/TouchHistoryMath.js | 14 +- .../__tests__/InteractionManager-test.js | 14 +- .../Interaction/__tests__/TaskQueue-test.js | 6 +- Libraries/LayoutAnimation/LayoutAnimation.js | 4 +- Libraries/Lists/FillRateHelper.js | 6 +- Libraries/Lists/FlatList.js | 16 ++- Libraries/Lists/SectionList.js | 4 +- Libraries/Lists/ViewabilityHelper.js | 4 +- Libraries/Lists/VirtualizedList.js | 57 ++++---- Libraries/Lists/VirtualizedSectionList.js | 12 +- .../Lists/__flowtests__/FlatList-flowtest.js | 2 +- .../Lists/__tests__/FillRateHelper-test.js | 14 +- Libraries/Lists/__tests__/FlatList-test.js | 4 +- Libraries/Lists/__tests__/SectionList-test.js | 28 ++-- .../Lists/__tests__/ViewabilityHelper-test.js | 33 ++--- .../Lists/__tests__/VirtualizeUtils-test.js | 34 ++--- .../Lists/__tests__/VirtualizedList-test.js | 50 +++---- .../__tests__/VirtualizedSectionList-test.js | 30 ++-- Libraries/LogBox/Data/LogBoxData.js | 12 +- Libraries/LogBox/Data/LogBoxLog.js | 4 +- .../LogBox/Data/__tests__/LogBoxData-test.js | 12 +- .../LogBox/Data/__tests__/LogBoxLog-test.js | 18 +-- .../__tests__/LogBoxSymbolication-test.js | 6 +- Libraries/LogBox/Data/parseLogBoxLog.js | 4 +- Libraries/LogBox/LogBox.js | 10 +- .../LogBox/LogBoxNotificationContainer.js | 4 +- Libraries/LogBox/UI/AnsiHighlight.js | 4 +- Libraries/LogBox/UI/LogBoxMessage.js | 2 +- .../LogBoxInspectorStackFrames-test.js | 8 +- Libraries/Modal/Modal.js | 4 +- Libraries/Network/RCTNetworking.android.js | 2 +- Libraries/Network/XHRInterceptor.js | 6 +- Libraries/Network/XMLHttpRequest.js | 16 +-- Libraries/Network/__tests__/FormData-test.js | 6 +- .../Network/__tests__/XMLHttpRequest-test.js | 24 ++-- Libraries/Performance/PureComponentDebug.js | 8 +- Libraries/Performance/SamplingProfiler.js | 2 +- Libraries/Pressability/Pressability.js | 8 +- .../__tests__/Pressability-test.js | 6 +- Libraries/Promise.js | 2 +- .../PushNotificationIOS.js | 12 +- Libraries/ReactNative/AppContainer.js | 6 +- Libraries/ReactNative/AppRegistry.js | 10 +- Libraries/ReactNative/PaperUIManager.js | 12 +- Libraries/ReactNative/queryLayoutByID.js | 2 +- .../shims/ReactNativeViewConfigRegistry.js | 4 +- .../shims/createReactNativeComponentClass.js | 2 +- Libraries/Settings/Settings.ios.js | 4 +- Libraries/Share/Share.js | 2 +- Libraries/Storage/AsyncStorage.js | 48 +++---- Libraries/StyleSheet/StyleSheetValidation.js | 2 +- .../__flowtests__/StyleSheet-flowtest.js | 40 ++++-- .../__tests__/normalizeColor-test.js | 28 ++-- .../StyleSheet/__tests__/processColor-test.js | 4 +- .../__tests__/processColorArray-test.js | 4 +- .../__tests__/setNormalizedColorAlpha-test.js | 10 +- Libraries/StyleSheet/processTransform.js | 4 +- Libraries/StyleSheet/splitLayoutProps.js | 2 +- Libraries/Text/Text.js | 2 +- Libraries/Utilities/BackHandler.android.js | 8 +- Libraries/Utilities/BackHandler.ios.js | 6 +- Libraries/Utilities/DevSettings.js | 2 +- Libraries/Utilities/HMRClient.js | 8 +- Libraries/Utilities/JSDevSupportModule.js | 2 +- Libraries/Utilities/MatrixMath.js | 38 ++--- Libraries/Utilities/ReactNativeTestTools.js | 10 +- Libraries/Utilities/SceneTracker.js | 4 +- Libraries/Utilities/__mocks__/BackHandler.js | 6 +- Libraries/Utilities/__mocks__/PixelRatio.js | 4 +- .../Utilities/__tests__/MatrixMath-test.js | 8 +- .../Utilities/__tests__/SceneTracker-test.js | 6 +- .../__tests__/buildStyleInterpolator-test.js | 54 +++---- .../__tests__/codegenNativeComponent-test.js | 4 +- .../deepFreezeAndThrowOnMutationInDev-test.js | 2 +- .../__tests__/mapWithSeparator-test.js | 16 +-- .../__tests__/setAndForwardRef-test.js | 4 +- .../Utilities/__tests__/stringifySafe-test.js | 2 +- Libraries/Utilities/buildStyleInterpolator.js | 18 +-- Libraries/Utilities/codegenNativeCommands.js | 2 +- Libraries/Utilities/codegenNativeComponent.js | 5 +- .../Utilities/createPerformanceLogger.js | 2 +- .../differ/__tests__/deepDiffer-test.js | 26 +--- .../differ/__tests__/matricesDiffer-test.js | 2 +- Libraries/Utilities/differ/deepDiffer.js | 2 +- Libraries/Utilities/differ/insetsDiffer.js | 2 +- Libraries/Utilities/differ/matricesDiffer.js | 2 +- Libraries/Utilities/differ/pointsDiffer.js | 2 +- Libraries/Utilities/differ/sizesDiffer.js | 2 +- Libraries/Utilities/logError.js | 2 +- Libraries/Utilities/mergeIntoFast.js | 2 +- Libraries/Utilities/stringifySafe.js | 4 +- Libraries/Utilities/truncate.js | 2 +- Libraries/Utilities/useColorScheme.js | 2 +- .../verifyComponentAttributeEquivalence.js | 4 +- Libraries/Vibration/Vibration.js | 4 +- Libraries/WebSocket/WebSocket.js | 10 +- Libraries/WebSocket/WebSocketInterceptor.js | 18 +-- .../WebSocket/__tests__/WebSocket-test.js | 2 +- .../ReactNativeTypes-flowtest.js | 2 +- Libraries/polyfills/Object.es7.js | 6 +- .../polyfills/__tests__/Object.es7-test.js | 10 +- Libraries/polyfills/console.js | 50 +++---- Libraries/vendor/emitter/EventEmitter.js | 2 +- .../RNTesterUnitTestsBundle.js | 2 +- RNTester/e2e/e2e-helpers.js | 2 +- RNTester/e2e/test-init.js | 2 +- RNTester/js/RNTesterApp.android.js | 10 +- RNTester/js/RNTesterApp.ios.js | 6 +- RNTester/js/components/ListExampleShared.js | 4 +- RNTester/js/components/RNTesterBlock.js | 4 +- .../js/components/RNTesterExampleFilter.js | 8 +- RNTester/js/components/RNTesterExampleList.js | 8 +- RNTester/js/components/RNTesterPage.js | 2 +- .../js/components/RNTesterSettingSwitchRow.js | 2 +- RNTester/js/components/RNTesterTitle.js | 2 +- RNTester/js/components/TextLegend.js | 12 +- RNTester/js/components/createExamplePage.js | 2 +- .../Accessibility/AccessibilityExample.js | 16 +-- .../Accessibility/AccessibilityIOSExample.js | 6 +- .../ActionSheetIOS/ActionSheetIOSExample.js | 20 +-- .../js/examples/Animated/AnimatedExample.js | 16 +-- .../Animated/AnimatedGratuitousApp/AnExApp.js | 8 +- .../AnimatedGratuitousApp/AnExChained.js | 2 +- .../js/examples/AppState/AppStateExample.js | 2 +- .../examples/Appearance/AppearanceExample.js | 18 +-- .../AsyncStorage/AsyncStorageExample.js | 8 +- RNTester/js/examples/Button/ButtonExample.js | 14 +- .../js/examples/CheckBox/CheckBoxExample.js | 12 +- .../DatePicker/DatePickerAndroidExample.js | 2 +- .../DatePicker/DatePickerIOSExample.js | 8 +- .../examples/Dimensions/DimensionsExample.js | 2 +- .../js/examples/FlatList/FlatListExample.js | 16 +-- RNTester/js/examples/Image/ImageExample.js | 74 +++++----- .../InputAccessoryViewExample.js | 4 +- .../JSResponderHandlerExample.js | 2 +- .../KeyboardAvoidingViewExample.js | 2 +- .../examples/Layout/LayoutAnimationExample.js | 12 +- .../js/examples/Layout/LayoutEventsExample.js | 2 +- RNTester/js/examples/Layout/LayoutExample.js | 2 +- .../js/examples/Linking/LinkingExample.js | 4 +- .../examples/MaskedView/MaskedViewExample.js | 10 +- RNTester/js/examples/Modal/ModalExample.js | 8 +- .../MultiColumn/MultiColumnExample.js | 10 +- .../NativeAnimationsExample.js | 54 +++---- .../NewAppScreen/NewAppScreenExample.js | 2 +- .../PanResponder/PanResponderExample.js | 4 +- RNTester/js/examples/Picker/PickerExample.js | 28 ++-- .../js/examples/Picker/PickerIOSExample.js | 14 +- .../PointerEvents/PointerEventsExample.js | 6 +- .../js/examples/Pressable/PressableExample.js | 28 ++-- .../ProgressBarAndroidExample.android.js | 2 +- .../ProgressViewIOS/ProgressViewIOSExample.js | 2 +- .../PushNotificationIOSExample.js | 4 +- RNTester/js/examples/RTL/RTLExample.js | 32 ++--- .../RefreshControl/RefreshControlExample.js | 4 +- .../SafeAreaView/SafeAreaViewExample.js | 6 +- .../ScrollView/ScrollViewAnimatedExample.js | 2 +- .../examples/ScrollView/ScrollViewExample.js | 28 ++-- .../ScrollView/ScrollViewSimpleExample.js | 2 +- .../SectionList/SectionListExample.js | 12 +- .../SegmentedControlIOSExample.js | 4 +- RNTester/js/examples/Share/ShareExample.js | 4 +- RNTester/js/examples/Slider/SliderExample.js | 6 +- .../js/examples/Snapshot/SnapshotExample.js | 4 +- RNTester/js/examples/Switch/SwitchExample.js | 22 ++- .../TVEventHandler/TVEventHandlerExample.js | 2 +- .../js/examples/Text/TextExample.android.js | 2 +- RNTester/js/examples/Text/TextExample.ios.js | 66 ++++----- .../TextInput/TextInputExample.android.js | 34 ++--- .../TextInput/TextInputExample.ios.js | 64 ++++----- .../TextInput/TextInputSharedExamples.js | 58 ++++---- RNTester/js/examples/Timer/TimerExample.js | 18 +-- .../ToastAndroidExample.android.js | 2 +- .../js/examples/Touchable/TouchableExample.js | 30 ++-- .../TurboModule/SampleTurboModuleExample.js | 14 +- .../TurboModule/TurboModuleExample.js | 2 +- RNTester/js/examples/View/ViewExample.js | 2 +- .../js/examples/WebSocket/WebSocketExample.js | 14 +- .../examples/XHR/XHRExampleAbortController.js | 6 +- .../js/examples/XHR/XHRExampleBinaryUpload.js | 4 +- .../js/examples/XHR/XHRExampleDownload.js | 18 +-- RNTester/js/examples/XHR/XHRExampleFetch.js | 6 +- RNTester/js/utils/RNTesterList.android.js | 2 +- RNTester/js/utils/RNTesterList.ios.js | 2 +- RNTester/js/utils/RNTesterStatePersister.js | 7 +- ReactAndroid/src/androidTest/js/Asserts.js | 4 +- .../js/CatalystRootViewTestModule.js | 2 +- .../js/DatePickerDialogTestModule.js | 2 +- .../src/androidTest/js/ImageErrorTestApp.js | 2 +- .../src/androidTest/js/LayoutEventsTestApp.js | 4 +- .../androidTest/js/MeasureLayoutTestModule.js | 48 +++---- .../js/MultitouchHandlingTestAppModule.js | 10 +- .../androidTest/js/PickerAndroidTestModule.js | 8 +- .../androidTest/js/ProgressBarTestModule.js | 2 +- .../androidTest/js/ScrollViewTestModule.js | 10 +- .../src/androidTest/js/ShareTestModule.js | 2 +- .../js/SubviewsClippingTestModule.js | 12 +- .../js/SwipeRefreshLayoutTestModule.js | 2 +- .../src/androidTest/js/TestJSLocaleModule.js | 4 +- .../js/TestJSToJavaParametersModule.js | 34 ++--- .../js/TestJavaToJSArgumentsModule.js | 20 +-- .../js/TestJavaToJSReturnValuesModule.js | 4 +- .../src/androidTest/js/TextInputTestModule.js | 8 +- .../js/TouchBubblingTestAppModule.js | 2 +- .../androidTest/js/ViewRenderingTestModule.js | 10 +- .../tools/msggen/src/HeaderWriter.js | 2 +- .../inspector/tools/msggen/src/Property.js | 4 +- .../inspector/tools/msggen/src/index.js | 10 +- bots/code-analysis-bot.js | 42 +++--- bots/datastore.js | 10 +- bots/report-bundle-size.js | 2 +- flow/jest.js | 6 +- jest/mockComponent.js | 4 +- jest/setup.js | 24 ++-- package.json | 2 +- .../__tests__/index-test.js | 4 +- .../babel-plugin-inline-view-configs/index.js | 4 +- .../package.json | 2 +- .../yarn.lock | 8 +- .../src/SchemaValidator.js | 4 +- .../src/__tests__/SchemaValidator-test.js | 2 +- .../src/cli/parser/parser.js | 2 +- .../src/cli/verify_with_old_codegen.js | 10 +- .../src/generators/components/CppHelpers.js | 7 +- .../GenerateComponentDescriptorH.js | 4 +- .../components/GenerateComponentHObjCpp.js | 10 +- .../components/GenerateEventEmitterCpp.js | 8 +- .../components/GenerateEventEmitterH.js | 14 +- .../generators/components/GeneratePropsCpp.js | 19 ++- .../generators/components/GeneratePropsH.js | 65 +++++---- .../components/GeneratePropsJavaDelegate.js | 35 +++-- .../components/GeneratePropsJavaInterface.js | 21 +-- .../components/GenerateShadowNodeCpp.js | 4 +- .../components/GenerateShadowNodeH.js | 4 +- .../generators/components/GenerateTests.js | 11 +- .../components/GenerateViewConfigJs.js | 31 ++-- .../src/generators/components/JavaHelpers.js | 4 +- .../GenerateComponentDescriptorH-test.js | 2 +- .../GenerateComponentHObjCpp-test.js | 2 +- .../__tests__/GenerateEventEmitterCpp-test.js | 2 +- .../__tests__/GenerateEventEmitterH-test.js | 2 +- .../__tests__/GeneratePropsCpp-test.js | 2 +- .../__tests__/GeneratePropsH-test.js | 2 +- .../GeneratePropsJavaDelegate-test.js | 2 +- .../GeneratePropsJavaInterface-test.js | 2 +- .../__tests__/GenerateShadowNodeCpp-test.js | 2 +- .../__tests__/GenerateShadowNodeH-test.js | 2 +- .../__tests__/GenerateTests-test.js | 2 +- .../__tests__/GenerateViewConfigJs-test.js | 2 +- .../generators/modules/GenerateModuleCpp.js | 6 +- .../src/generators/modules/GenerateModuleH.js | 16 ++- .../modules/GenerateModuleHObjCpp.js | 18 ++- .../generators/modules/GenerateModuleMm.js | 12 +- .../modules/ObjCppUtils/GenerateStructs.js | 10 +- .../GenerateStructsForConstants.js | 4 +- .../generators/modules/ObjCppUtils/Utils.js | 8 +- .../__tests__/GenerateModuleCpp-test.js | 2 +- .../modules/__tests__/GenerateModuleH-test.js | 2 +- .../__tests__/GenerateModuleHObjCpp-test.js | 2 +- .../__tests__/GenerateModuleMm-test.js | 2 +- .../modules/__tests__/GenerateStructs-test.js | 2 +- .../__tests__/component-parser-test.js | 6 +- .../src/parsers/flow/components/commands.js | 6 +- .../src/parsers/flow/components/events.js | 6 +- .../src/parsers/flow/components/extends.js | 6 +- .../src/parsers/flow/components/index.js | 16 ++- .../src/parsers/flow/components/options.js | 2 +- .../src/parsers/flow/components/props.js | 26 ++-- .../src/parsers/flow/index.js | 6 +- .../modules/__tests__/module-parser-test.js | 6 +- .../src/parsers/flow/modules/index.js | 4 +- .../src/parsers/flow/modules/methods.js | 12 +- scripts/android-e2e-test.js | 25 ++-- scripts/publish-npm.js | 16 +-- .../run-android-ci-instrumentation-tests.js | 12 +- yarn.lock | 8 +- 383 files changed, 2072 insertions(+), 2051 deletions(-) diff --git a/IntegrationTests/AccessibilityManagerTest.js b/IntegrationTests/AccessibilityManagerTest.js index 48942004acb..dd155cec22c 100644 --- a/IntegrationTests/AccessibilityManagerTest.js +++ b/IntegrationTests/AccessibilityManagerTest.js @@ -39,7 +39,7 @@ class AccessibilityManagerTest extends React.Component<{...}> { accessibilityExtraExtraLarge: 11.0, accessibilityExtraExtraExtraLarge: 12.0, }); - RCTDeviceEventEmitter.addListener('didUpdateDimensions', (update) => { + RCTDeviceEventEmitter.addListener('didUpdateDimensions', update => { TestModule.markTestPassed(update.window.fontScale === 4.0); }); } diff --git a/IntegrationTests/AsyncStorageTest.js b/IntegrationTests/AsyncStorageTest.js index e5a1badfd5e..e33cedfdd82 100644 --- a/IntegrationTests/AsyncStorageTest.js +++ b/IntegrationTests/AsyncStorageTest.js @@ -66,7 +66,7 @@ function expectAsyncNoError(place, err) { } function testSetAndGet() { - AsyncStorage.setItem(KEY_1, VAL_1, (err1) => { + AsyncStorage.setItem(KEY_1, VAL_1, err1 => { expectAsyncNoError('testSetAndGet/setItem', err1); AsyncStorage.getItem(KEY_1, (err2, result) => { expectAsyncNoError('testSetAndGet/getItem', err2); @@ -109,7 +109,7 @@ function testRemoveItem() { 'Missing KEY_1 or KEY_2 in ' + '(' + result + ')', ); updateMessage('testRemoveItem - add two items'); - AsyncStorage.removeItem(KEY_1, (err2) => { + AsyncStorage.removeItem(KEY_1, err2 => { expectAsyncNoError('testRemoveItem/removeItem', err2); updateMessage('delete successful '); AsyncStorage.getItem(KEY_1, (err3, result2) => { @@ -137,9 +137,9 @@ function testRemoveItem() { } function testMerge() { - AsyncStorage.setItem(KEY_MERGE, JSON.stringify(VAL_MERGE_1), (err1) => { + AsyncStorage.setItem(KEY_MERGE, JSON.stringify(VAL_MERGE_1), err1 => { expectAsyncNoError('testMerge/setItem', err1); - AsyncStorage.mergeItem(KEY_MERGE, JSON.stringify(VAL_MERGE_2), (err2) => { + AsyncStorage.mergeItem(KEY_MERGE, JSON.stringify(VAL_MERGE_2), err2 => { expectAsyncNoError('testMerge/mergeItem', err2); AsyncStorage.getItem(KEY_MERGE, (err3, result) => { expectAsyncNoError('testMerge/setItem', err3); @@ -152,14 +152,11 @@ function testMerge() { } function testOptimizedMultiGet() { - let batch = [ - [KEY_1, VAL_1], - [KEY_2, VAL_2], - ]; + let batch = [[KEY_1, VAL_1], [KEY_2, VAL_2]]; let keys = batch.map(([key, value]) => key); - AsyncStorage.multiSet(batch, (err1) => { + AsyncStorage.multiSet(batch, err1 => { // yes, twice on purpose - [1, 2].forEach((i) => { + [1, 2].forEach(i => { expectAsyncNoError(`${i} testOptimizedMultiGet/multiSet`, err1); AsyncStorage.multiGet(keys, (err2, result) => { expectAsyncNoError(`${i} testOptimizedMultiGet/multiGet`, err2); @@ -185,7 +182,7 @@ class AsyncStorageTest extends React.Component<{...}, $FlowFixMeState> { this.setState({done: true}, () => { TestModule.markTestCompleted(); }); - updateMessage = (msg) => { + updateMessage = msg => { this.setState({messages: this.state.messages.concat('\n' + msg)}); DEBUG && console.log(msg); }; diff --git a/IntegrationTests/ImageCachePolicyTest.js b/IntegrationTests/ImageCachePolicyTest.js index 600634b88ba..03857091072 100644 --- a/IntegrationTests/ImageCachePolicyTest.js +++ b/IntegrationTests/ImageCachePolicyTest.js @@ -40,7 +40,7 @@ class ImageCachePolicyTest extends React.Component { state: $FlowFixMe | {...} = {}; shouldComponentUpdate(nextProps: Props, nextState: State): boolean { - const results: Array = TESTS.map((x) => nextState[x]); + const results: Array = TESTS.map(x => nextState[x]); if (!results.includes(undefined)) { const result: boolean = results.reduce( diff --git a/IntegrationTests/IntegrationTestsApp.js b/IntegrationTests/IntegrationTestsApp.js index 5894a1bf439..1e52877b7b9 100644 --- a/IntegrationTests/IntegrationTestsApp.js +++ b/IntegrationTests/IntegrationTestsApp.js @@ -43,7 +43,7 @@ TESTS.forEach( /* $FlowFixMe(>=0.54.0 site=react_native_fb,react_native_oss) This comment * suppresses an error found when Flow v0.54 was deployed. To see the error * delete this comment and run Flow. */ - (test) => AppRegistry.registerComponent(test.displayName, () => test), + test => AppRegistry.registerComponent(test.displayName, () => test), ); // Modules required for integration tests @@ -76,7 +76,7 @@ class IntegrationTestsApp extends React.Component<{...}, $FlowFixMeState> { - {TESTS.map((test) => [ + {TESTS.map(test => [ this.setState({test})} /* $FlowFixMe(>=0.115.0 site=react_native_fb) This comment diff --git a/IntegrationTests/LayoutEventsTest.js b/IntegrationTests/LayoutEventsTest.js index d144d0f9ce9..c86592a600b 100644 --- a/IntegrationTests/LayoutEventsTest.js +++ b/IntegrationTests/LayoutEventsTest.js @@ -141,13 +141,13 @@ class LayoutEventsTest extends React.Component { return ( { + ref={ref => { this._view = ref; }} onLayout={this.onViewLayout} style={viewStyle}> { + ref={ref => { this._img = ref; }} onLayout={this.onImageLayout} @@ -155,7 +155,7 @@ class LayoutEventsTest extends React.Component { source={{uri: 'uie_thumb_big.png'}} /> { + ref={ref => { this._txt = ref; }} onLayout={this.onTextLayout} diff --git a/IntegrationTests/LoggingTestModule.js b/IntegrationTests/LoggingTestModule.js index e69457d8250..6eab2d7337f 100644 --- a/IntegrationTests/LoggingTestModule.js +++ b/IntegrationTests/LoggingTestModule.js @@ -15,24 +15,24 @@ const warning = require('fbjs/lib/warning'); const invariant = require('invariant'); const LoggingTestModule = { - logToConsole: function (str) { + logToConsole: function(str) { console.log(str); }, - logToConsoleAfterWait: function (str, timeout_ms) { - setTimeout(function () { + logToConsoleAfterWait: function(str, timeout_ms) { + setTimeout(function() { console.log(str); }, timeout_ms); }, - warning: function (str) { + warning: function(str) { warning(false, str); }, - invariant: function (str) { + invariant: function(str) { invariant(false, str); }, - logErrorToConsole: function (str) { + logErrorToConsole: function(str) { console.error(str); }, - throwError: function (str) { + throwError: function(str) { throw new Error(str); }, }; diff --git a/IntegrationTests/RCTRootViewIntegrationTestApp.js b/IntegrationTests/RCTRootViewIntegrationTestApp.js index 89aeadbc3e9..2466b637858 100644 --- a/IntegrationTests/RCTRootViewIntegrationTestApp.js +++ b/IntegrationTests/RCTRootViewIntegrationTestApp.js @@ -28,7 +28,7 @@ const TESTS = [ require('./SizeFlexibilityUpdateTest'), ]; -TESTS.forEach((test) => +TESTS.forEach(test => AppRegistry.registerComponent(test.displayName, () => test), ); @@ -54,7 +54,7 @@ class RCTRootViewIntegrationTestApp extends React.Component { - {TESTS.map((test) => [ + {TESTS.map(test => [ this.setState({test})} style={styles.row}> diff --git a/IntegrationTests/SyncMethodTest.js b/IntegrationTests/SyncMethodTest.js index 3b8105c66d0..077884256d2 100644 --- a/IntegrationTests/SyncMethodTest.js +++ b/IntegrationTests/SyncMethodTest.js @@ -27,7 +27,7 @@ class SyncMethodTest extends React.Component<{...}> { throw new Error('Something wrong with methodThatReturnsNil sync method'); } let response; - RNTesterTestModule.methodThatCallsCallbackWithString('test', (echo) => { + RNTesterTestModule.methodThatCallsCallbackWithString('test', echo => { response = echo; }); requestAnimationFrame(() => { diff --git a/IntegrationTests/TimersTest.js b/IntegrationTests/TimersTest.js index 8528718e154..8550c6f00ee 100644 --- a/IntegrationTests/TimersTest.js +++ b/IntegrationTests/TimersTest.js @@ -153,7 +153,7 @@ class TimersTest extends React.Component { fails.push(this.setTimeout(() => this._fail('testClearMulti-4'), 0)); fails.push(this.setTimeout(() => this._fail('testClearMulti-5'), 10)); - fails.forEach((timeout) => this.clearTimeout(timeout)); + fails.forEach(timeout => this.clearTimeout(timeout)); this.setTimeout(() => this.clearTimeout(delayClear), 20); this.setTimeout(this.testOrdering, 50); diff --git a/IntegrationTests/WebSocketTest.js b/IntegrationTests/WebSocketTest.js index dd6c7d0021e..3435feabb11 100644 --- a/IntegrationTests/WebSocketTest.js +++ b/IntegrationTests/WebSocketTest.js @@ -45,7 +45,7 @@ class WebSocketTest extends React.Component<{...}, State> { _waitFor = (condition: any, timeout: any, callback: any) => { let remaining = timeout; - const timeoutFunction = function () { + const timeoutFunction = function() { if (condition()) { callback(true); return; @@ -62,7 +62,7 @@ class WebSocketTest extends React.Component<{...}, State> { _connect = () => { const socket = new WebSocket(this.state.url); - WS_EVENTS.forEach((ev) => socket.addEventListener(ev, this._onSocketEvent)); + WS_EVENTS.forEach(ev => socket.addEventListener(ev, this._onSocketEvent)); this.setState({ socket, socketState: socket.readyState, @@ -116,7 +116,7 @@ class WebSocketTest extends React.Component<{...}, State> { testConnect: () => void = () => { this._connect(); - this._waitFor(this._socketIsConnected, 5, (connectSucceeded) => { + this._waitFor(this._socketIsConnected, 5, connectSucceeded => { if (!connectSucceeded) { TestModule.markTestPassed(false); return; @@ -127,7 +127,7 @@ class WebSocketTest extends React.Component<{...}, State> { testSendAndReceive: () => void = () => { this._sendTestMessage(); - this._waitFor(this._receivedTestExpectedResponse, 5, (messageReceived) => { + this._waitFor(this._receivedTestExpectedResponse, 5, messageReceived => { if (!messageReceived) { TestModule.markTestPassed(false); return; @@ -138,7 +138,7 @@ class WebSocketTest extends React.Component<{...}, State> { testDisconnect: () => void = () => { this._disconnect(); - this._waitFor(this._socketIsDisconnected, 5, (disconnectSucceeded) => { + this._waitFor(this._socketIsDisconnected, 5, disconnectSucceeded => { TestModule.markTestPassed(disconnectSucceeded); }); }; diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index bd739d52d6a..e6aead18643 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -97,7 +97,7 @@ class Alert { options && options.onDismiss && options.onDismiss(); } }; - const onError = (errorMessage) => console.warn(errorMessage); + const onError = errorMessage => console.warn(errorMessage); NativeDialogManagerAndroid.showAlert(config, onError, onAction); } } diff --git a/Libraries/Alert/RCTAlertManager.android.js b/Libraries/Alert/RCTAlertManager.android.js index b3654ba093e..43f49a94e50 100644 --- a/Libraries/Alert/RCTAlertManager.android.js +++ b/Libraries/Alert/RCTAlertManager.android.js @@ -14,7 +14,7 @@ import NativeDialogManagerAndroid from '../NativeModules/specs/NativeDialogManag function emptyCallback() {} module.exports = { - alertWithArgs: function (args, callback) { + alertWithArgs: function(args, callback) { // TODO(5998984): Polyfill it correctly with DialogManagerAndroid if (!NativeDialogManagerAndroid) { return; diff --git a/Libraries/Animated/release/gulpfile.js b/Libraries/Animated/release/gulpfile.js index e84102976dd..291f3236303 100644 --- a/Libraries/Animated/release/gulpfile.js +++ b/Libraries/Animated/release/gulpfile.js @@ -46,7 +46,7 @@ var babelOpts = { }), }; -var buildDist = function (opts) { +var buildDist = function(opts) { var webpackOpts = { debug: opts.debug, externals: { @@ -80,7 +80,7 @@ var buildDist = function (opts) { }), ); } - return webpackStream(webpackOpts, null, function (err, stats) { + return webpackStream(webpackOpts, null, function(err, stats) { if (err) { throw new gulpUtil.PluginError('webpack', err); } @@ -101,11 +101,11 @@ var paths = { ], }; -gulp.task('clean', function (cb) { +gulp.task('clean', function(cb) { del([paths.dist, paths.lib], cb); }); -gulp.task('modules', function () { +gulp.task('modules', function() { return gulp .src(paths.src, {cwd: '../'}) .pipe(babel(babelOpts)) @@ -113,7 +113,7 @@ gulp.task('modules', function () { .pipe(gulp.dest(paths.lib)); }); -gulp.task('dist', ['modules'], function () { +gulp.task('dist', ['modules'], function() { var distOpts = { debug: true, output: 'animated.js', @@ -130,7 +130,7 @@ gulp.task('dist', ['modules'], function () { .pipe(gulp.dest(paths.dist)); }); -gulp.task('dist:min', ['modules'], function () { +gulp.task('dist:min', ['modules'], function() { var distOpts = { debug: false, output: 'animated.min.js', @@ -146,10 +146,10 @@ gulp.task('dist:min', ['modules'], function () { .pipe(gulp.dest(paths.dist)); }); -gulp.task('watch', function () { +gulp.task('watch', function() { gulp.watch(paths.src, ['modules']); }); -gulp.task('default', function (cb) { +gulp.task('default', function(cb) { runSequence('clean', 'modules', ['dist', 'dist:min'], cb); }); diff --git a/Libraries/Animated/src/AnimatedEvent.js b/Libraries/Animated/src/AnimatedEvent.js index 61fbefc91f5..91eb29ce413 100644 --- a/Libraries/Animated/src/AnimatedEvent.js +++ b/Libraries/Animated/src/AnimatedEvent.js @@ -58,7 +58,7 @@ function attachNativeEvent( const viewTag = ReactNative.findNodeHandle(viewRef); if (viewTag != null) { - eventMappings.forEach((mapping) => { + eventMappings.forEach(mapping => { NativeAnimatedHelper.API.addAnimatedEventToView( viewTag, eventName, @@ -70,7 +70,7 @@ function attachNativeEvent( return { detach() { if (viewTag != null) { - eventMappings.forEach((mapping) => { + eventMappings.forEach(mapping => { NativeAnimatedHelper.API.removeAnimatedEventFromView( viewTag, eventName, @@ -155,9 +155,7 @@ class AnimatedEvent { } __removeListener(callback: Function): void { - this._listeners = this._listeners.filter( - (listener) => listener !== callback, - ); + this._listeners = this._listeners.filter(listener => listener !== callback); } __attach(viewRef: any, eventName: string) { @@ -228,7 +226,7 @@ class AnimatedEvent { } _callListeners(...args: any) { - this._listeners.forEach((listener) => listener(...args)); + this._listeners.forEach(listener => listener(...args)); } } diff --git a/Libraries/Animated/src/AnimatedImplementation.js b/Libraries/Animated/src/AnimatedImplementation.js index 4fdd8c5394d..5045ed398ff 100644 --- a/Libraries/Animated/src/AnimatedImplementation.js +++ b/Libraries/Animated/src/AnimatedImplementation.js @@ -49,39 +49,39 @@ export type CompositeAnimation = { ... }; -const add = function ( +const add = function( a: AnimatedNode | number, b: AnimatedNode | number, ): AnimatedAddition { return new AnimatedAddition(a, b); }; -const subtract = function ( +const subtract = function( a: AnimatedNode | number, b: AnimatedNode | number, ): AnimatedSubtraction { return new AnimatedSubtraction(a, b); }; -const divide = function ( +const divide = function( a: AnimatedNode | number, b: AnimatedNode | number, ): AnimatedDivision { return new AnimatedDivision(a, b); }; -const multiply = function ( +const multiply = function( a: AnimatedNode | number, b: AnimatedNode | number, ): AnimatedMultiplication { return new AnimatedMultiplication(a, b); }; -const modulo = function (a: AnimatedNode, modulus: number): AnimatedModulo { +const modulo = function(a: AnimatedNode, modulus: number): AnimatedModulo { return new AnimatedModulo(a, modulus); }; -const diffClamp = function ( +const diffClamp = function( a: AnimatedNode, min: number, max: number, @@ -89,7 +89,7 @@ const diffClamp = function ( return new AnimatedDiffClamp(a, min, max); }; -const _combineCallbacks = function ( +const _combineCallbacks = function( callback: ?EndCallback, config: {...AnimationConfig, ...}, ) { @@ -103,7 +103,7 @@ const _combineCallbacks = function ( } }; -const maybeVectorAnim = function ( +const maybeVectorAnim = function( value: AnimatedValue | AnimatedValueXY, config: Object, anim: (value: AnimatedValue, config: Object) => CompositeAnimation, @@ -127,11 +127,11 @@ const maybeVectorAnim = function ( return null; }; -const spring = function ( +const spring = function( value: AnimatedValue | AnimatedValueXY, config: SpringAnimationConfig, ): CompositeAnimation { - const start = function ( + const start = function( animatedValue: AnimatedValue | AnimatedValueXY, configuration: SpringAnimationConfig, callback?: ?EndCallback, @@ -156,35 +156,35 @@ const spring = function ( }; return ( maybeVectorAnim(value, config, spring) || { - start: function (callback?: ?EndCallback): void { + start: function(callback?: ?EndCallback): void { start(value, config, callback); }, - stop: function (): void { + stop: function(): void { value.stopAnimation(); }, - reset: function (): void { + reset: function(): void { value.resetAnimation(); }, - _startNativeLoop: function (iterations?: number): void { + _startNativeLoop: function(iterations?: number): void { const singleConfig = {...config, iterations}; start(value, singleConfig); }, - _isUsingNativeDriver: function (): boolean { + _isUsingNativeDriver: function(): boolean { return config.useNativeDriver || false; }, } ); }; -const timing = function ( +const timing = function( value: AnimatedValue | AnimatedValueXY, config: TimingAnimationConfig, ): CompositeAnimation { - const start = function ( + const start = function( animatedValue: AnimatedValue | AnimatedValueXY, configuration: TimingAnimationConfig, callback?: ?EndCallback, @@ -210,35 +210,35 @@ const timing = function ( return ( maybeVectorAnim(value, config, timing) || { - start: function (callback?: ?EndCallback): void { + start: function(callback?: ?EndCallback): void { start(value, config, callback); }, - stop: function (): void { + stop: function(): void { value.stopAnimation(); }, - reset: function (): void { + reset: function(): void { value.resetAnimation(); }, - _startNativeLoop: function (iterations?: number): void { + _startNativeLoop: function(iterations?: number): void { const singleConfig = {...config, iterations}; start(value, singleConfig); }, - _isUsingNativeDriver: function (): boolean { + _isUsingNativeDriver: function(): boolean { return config.useNativeDriver || false; }, } ); }; -const decay = function ( +const decay = function( value: AnimatedValue | AnimatedValueXY, config: DecayAnimationConfig, ): CompositeAnimation { - const start = function ( + const start = function( animatedValue: AnimatedValue | AnimatedValueXY, configuration: DecayAnimationConfig, callback?: ?EndCallback, @@ -252,37 +252,37 @@ const decay = function ( return ( maybeVectorAnim(value, config, decay) || { - start: function (callback?: ?EndCallback): void { + start: function(callback?: ?EndCallback): void { start(value, config, callback); }, - stop: function (): void { + stop: function(): void { value.stopAnimation(); }, - reset: function (): void { + reset: function(): void { value.resetAnimation(); }, - _startNativeLoop: function (iterations?: number): void { + _startNativeLoop: function(iterations?: number): void { const singleConfig = {...config, iterations}; start(value, singleConfig); }, - _isUsingNativeDriver: function (): boolean { + _isUsingNativeDriver: function(): boolean { return config.useNativeDriver || false; }, } ); }; -const sequence = function ( +const sequence = function( animations: Array, ): CompositeAnimation { let current = 0; return { - start: function (callback?: ?EndCallback) { - const onComplete = function (result) { + start: function(callback?: ?EndCallback) { + const onComplete = function(result) { if (!result.finished) { callback && callback(result); return; @@ -305,13 +305,13 @@ const sequence = function ( } }, - stop: function () { + stop: function() { if (current < animations.length) { animations[current].stop(); } }, - reset: function () { + reset: function() { animations.forEach((animation, idx) => { if (idx <= current) { animation.reset(); @@ -320,13 +320,13 @@ const sequence = function ( current = 0; }, - _startNativeLoop: function () { + _startNativeLoop: function() { throw new Error( 'Loops run using the native driver cannot contain Animated.sequence animations', ); }, - _isUsingNativeDriver: function (): boolean { + _isUsingNativeDriver: function(): boolean { return false; }, }; @@ -337,7 +337,7 @@ type ParallelConfig = { stopTogether?: boolean, ... }; -const parallel = function ( +const parallel = function( animations: Array, config?: ?ParallelConfig, ): CompositeAnimation { @@ -347,14 +347,14 @@ const parallel = function ( const stopTogether = !(config && config.stopTogether === false); const result = { - start: function (callback?: ?EndCallback) { + start: function(callback?: ?EndCallback) { if (doneCount === animations.length) { callback && callback({finished: true}); return; } animations.forEach((animation, idx) => { - const cb = function (endResult) { + const cb = function(endResult) { hasEnded[idx] = true; doneCount++; if (doneCount === animations.length) { @@ -376,14 +376,14 @@ const parallel = function ( }); }, - stop: function (): void { + stop: function(): void { animations.forEach((animation, idx) => { !hasEnded[idx] && animation.stop(); hasEnded[idx] = true; }); }, - reset: function (): void { + reset: function(): void { animations.forEach((animation, idx) => { animation.reset(); hasEnded[idx] = false; @@ -391,13 +391,13 @@ const parallel = function ( }); }, - _startNativeLoop: function () { + _startNativeLoop: function() { throw new Error( 'Loops run using the native driver cannot contain Animated.parallel animations', ); }, - _isUsingNativeDriver: function (): boolean { + _isUsingNativeDriver: function(): boolean { return false; }, }; @@ -405,7 +405,7 @@ const parallel = function ( return result; }; -const delay = function (time: number): CompositeAnimation { +const delay = function(time: number): CompositeAnimation { // Would be nice to make a specialized implementation return timing(new AnimatedValue(0), { toValue: 0, @@ -415,7 +415,7 @@ const delay = function (time: number): CompositeAnimation { }); }; -const stagger = function ( +const stagger = function( time: number, animations: Array, ): CompositeAnimation { @@ -432,15 +432,15 @@ type LoopAnimationConfig = { ... }; -const loop = function ( +const loop = function( animation: CompositeAnimation, {iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = {}, ): CompositeAnimation { let isFinished = false; let iterationsSoFar = 0; return { - start: function (callback?: ?EndCallback) { - const restart = function (result: EndResult = {finished: true}): void { + start: function(callback?: ?EndCallback) { + const restart = function(result: EndResult = {finished: true}): void { if ( isFinished || iterationsSoFar === iterations || @@ -464,24 +464,24 @@ const loop = function ( } }, - stop: function (): void { + stop: function(): void { isFinished = true; animation.stop(); }, - reset: function (): void { + reset: function(): void { iterationsSoFar = 0; isFinished = false; animation.reset(); }, - _startNativeLoop: function () { + _startNativeLoop: function() { throw new Error( 'Loops run using the native driver cannot contain Animated.loop animations', ); }, - _isUsingNativeDriver: function (): boolean { + _isUsingNativeDriver: function(): boolean { return animation._isUsingNativeDriver(); }, }; @@ -513,7 +513,7 @@ function unforkEvent( } } -const event = function ( +const event = function( argMapping: $ReadOnlyArray, config: EventConfig, ): any { diff --git a/Libraries/Animated/src/AnimatedMock.js b/Libraries/Animated/src/AnimatedMock.js index 1e16110b7d0..eecfbb884ec 100644 --- a/Libraries/Animated/src/AnimatedMock.js +++ b/Libraries/Animated/src/AnimatedMock.js @@ -50,7 +50,7 @@ const emptyAnimation = { }, }; -const spring = function ( +const spring = function( value: AnimatedValue | AnimatedValueXY, config: SpringAnimationConfig, ): CompositeAnimation { @@ -64,7 +64,7 @@ const spring = function ( }; }; -const timing = function ( +const timing = function( value: AnimatedValue | AnimatedValueXY, config: TimingAnimationConfig, ): CompositeAnimation { @@ -78,32 +78,32 @@ const timing = function ( }; }; -const decay = function ( +const decay = function( value: AnimatedValue | AnimatedValueXY, config: DecayAnimationConfig, ): CompositeAnimation { return emptyAnimation; }; -const sequence = function ( +const sequence = function( animations: Array, ): CompositeAnimation { return emptyAnimation; }; type ParallelConfig = {stopTogether?: boolean, ...}; -const parallel = function ( +const parallel = function( animations: Array, config?: ?ParallelConfig, ): CompositeAnimation { return emptyAnimation; }; -const delay = function (time: number): CompositeAnimation { +const delay = function(time: number): CompositeAnimation { return emptyAnimation; }; -const stagger = function ( +const stagger = function( time: number, animations: Array, ): CompositeAnimation { @@ -116,14 +116,14 @@ type LoopAnimationConfig = { ... }; -const loop = function ( +const loop = function( animation: CompositeAnimation, {iterations = -1}: LoopAnimationConfig = {}, ): CompositeAnimation { return emptyAnimation; }; -const event = function (argMapping: Array, config: EventConfig): any { +const event = function(argMapping: Array, config: EventConfig): any { return null; }; diff --git a/Libraries/Animated/src/Easing.js b/Libraries/Animated/src/Easing.js index 3503d1e59dc..253a3e785aa 100644 --- a/Libraries/Animated/src/Easing.js +++ b/Libraries/Animated/src/Easing.js @@ -164,8 +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); } /** @@ -177,7 +176,7 @@ class Easing { * - http://tiny.cc/back_default (s = 1.70158, default) */ static back(s: number = 1.70158): (t: number) => number { - return (t) => t * t * ((s + 1) * t - s); + return t => t * t * ((s + 1) * t - s); } /** @@ -232,7 +231,7 @@ class Easing { * Runs an easing function backwards. */ static out(easing: (t: number) => number): (t: number) => number { - return (t) => 1 - easing(1 - t); + return t => 1 - easing(1 - t); } /** @@ -241,7 +240,7 @@ class Easing { * duration. */ static inOut(easing: (t: number) => number): (t: number) => number { - return (t) => { + return t => { if (t < 0.5) { return easing(t * 2) / 2; } diff --git a/Libraries/Animated/src/NativeAnimatedHelper.js b/Libraries/Animated/src/NativeAnimatedHelper.js index 6b50f968af2..f21066bb07f 100644 --- a/Libraries/Animated/src/NativeAnimatedHelper.js +++ b/Libraries/Animated/src/NativeAnimatedHelper.js @@ -35,10 +35,10 @@ let queue = []; * the native module methods */ const API = { - enableQueue: function (): void { + enableQueue: function(): void { queueConnections = true; }, - disableQueue: function (): void { + disableQueue: function(): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); queueConnections = false; for (let q = 0, l = queue.length; q < l; q++) { @@ -47,19 +47,19 @@ const API = { } queue.length = 0; }, - createAnimatedNode: function (tag: number, config: AnimatedNodeConfig): void { + createAnimatedNode: function(tag: number, config: AnimatedNodeConfig): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.createAnimatedNode(tag, config); }, - startListeningToAnimatedNodeValue: function (tag: number) { + startListeningToAnimatedNodeValue: function(tag: number) { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.startListeningToAnimatedNodeValue(tag); }, - stopListeningToAnimatedNodeValue: function (tag: number) { + stopListeningToAnimatedNodeValue: function(tag: number) { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.stopListeningToAnimatedNodeValue(tag); }, - connectAnimatedNodes: function (parentTag: number, childTag: number): void { + connectAnimatedNodes: function(parentTag: number, childTag: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); if (queueConnections) { queue.push([parentTag, childTag]); @@ -67,14 +67,11 @@ const API = { } NativeAnimatedModule.connectAnimatedNodes(parentTag, childTag); }, - disconnectAnimatedNodes: function ( - parentTag: number, - childTag: number, - ): void { + disconnectAnimatedNodes: function(parentTag: number, childTag: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.disconnectAnimatedNodes(parentTag, childTag); }, - startAnimatingNode: function ( + startAnimatingNode: function( animationId: number, nodeTag: number, config: AnimatingNodeConfig, @@ -88,49 +85,49 @@ const API = { endCallback, ); }, - stopAnimation: function (animationId: number) { + stopAnimation: function(animationId: number) { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.stopAnimation(animationId); }, - setAnimatedNodeValue: function (nodeTag: number, value: number): void { + setAnimatedNodeValue: function(nodeTag: number, value: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.setAnimatedNodeValue(nodeTag, value); }, - setAnimatedNodeOffset: function (nodeTag: number, offset: number): void { + setAnimatedNodeOffset: function(nodeTag: number, offset: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.setAnimatedNodeOffset(nodeTag, offset); }, - flattenAnimatedNodeOffset: function (nodeTag: number): void { + flattenAnimatedNodeOffset: function(nodeTag: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.flattenAnimatedNodeOffset(nodeTag); }, - extractAnimatedNodeOffset: function (nodeTag: number): void { + extractAnimatedNodeOffset: function(nodeTag: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.extractAnimatedNodeOffset(nodeTag); }, - connectAnimatedNodeToView: function (nodeTag: number, viewTag: number): void { + connectAnimatedNodeToView: function(nodeTag: number, viewTag: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.connectAnimatedNodeToView(nodeTag, viewTag); }, - disconnectAnimatedNodeFromView: function ( + disconnectAnimatedNodeFromView: function( nodeTag: number, viewTag: number, ): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.disconnectAnimatedNodeFromView(nodeTag, viewTag); }, - restoreDefaultValues: function (nodeTag: number): void { + restoreDefaultValues: function(nodeTag: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); // Backwards compat with older native runtimes, can be removed later. if (NativeAnimatedModule.restoreDefaultValues != null) { NativeAnimatedModule.restoreDefaultValues(nodeTag); } }, - dropAnimatedNode: function (tag: number): void { + dropAnimatedNode: function(tag: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); NativeAnimatedModule.dropAnimatedNode(tag); }, - addAnimatedEventToView: function ( + addAnimatedEventToView: function( viewTag: number, eventName: string, eventMapping: EventMapping, @@ -235,10 +232,12 @@ function validateTransform( }, >, ): void { - configs.forEach((config) => { + configs.forEach(config => { if (!TRANSFORM_WHITELIST.hasOwnProperty(config.property)) { throw new Error( - `Property '${config.property}' is not supported by native animated module`, + `Property '${ + config.property + }' is not supported by native animated module`, ); } }); diff --git a/Libraries/Animated/src/__tests__/AnimatedMock-test.js b/Libraries/Animated/src/__tests__/AnimatedMock-test.js index a7e325748f1..8ba4e998b36 100644 --- a/Libraries/Animated/src/__tests__/AnimatedMock-test.js +++ b/Libraries/Animated/src/__tests__/AnimatedMock-test.js @@ -19,8 +19,8 @@ describe('Animated Mock', () => { Object.keys(AnimatedImplementation), ); }); - it('matches implementation params', (done) => { - Object.keys(AnimatedImplementation).forEach((key) => { + it('matches implementation params', done => { + Object.keys(AnimatedImplementation).forEach(key => { if (AnimatedImplementation[key].length !== AnimatedMock[key].length) { done( new Error( diff --git a/Libraries/Animated/src/__tests__/AnimatedNative-test.js b/Libraries/Animated/src/__tests__/AnimatedNative-test.js index 40eff3b024c..89024cdb883 100644 --- a/Libraries/Animated/src/__tests__/AnimatedNative-test.js +++ b/Libraries/Animated/src/__tests__/AnimatedNative-test.js @@ -346,30 +346,22 @@ describe('Native Animated', () => { {type: 'addition', input: expect.any(Array)}, ); const additionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - (call) => call[1].type === 'addition', + call => call[1].type === 'addition', ); expect(additionCalls.length).toBe(1); const additionCall = additionCalls[0]; const additionNodeTag = additionCall[0]; const additionConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( - (call) => call[1] === additionNodeTag, + call => call[1] === additionNodeTag, ); expect(additionConnectionCalls.length).toBe(2); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( additionCall[1].input[0], - { - type: 'value', - value: 1, - offset: 0, - }, + {type: 'value', value: 1, offset: 0}, ); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( additionCall[1].input[1], - { - type: 'value', - value: 2, - offset: 0, - }, + {type: 'value', value: 2, offset: 0}, ); }); @@ -388,30 +380,22 @@ describe('Native Animated', () => { {type: 'subtraction', input: expect.any(Array)}, ); const subtractionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - (call) => call[1].type === 'subtraction', + call => call[1].type === 'subtraction', ); expect(subtractionCalls.length).toBe(1); const subtractionCall = subtractionCalls[0]; const subtractionNodeTag = subtractionCall[0]; const subtractionConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( - (call) => call[1] === subtractionNodeTag, + call => call[1] === subtractionNodeTag, ); expect(subtractionConnectionCalls.length).toBe(2); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( subtractionCall[1].input[0], - { - type: 'value', - value: 2, - offset: 0, - }, + {type: 'value', value: 2, offset: 0}, ); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( subtractionCall[1].input[1], - { - type: 'value', - value: 1, - offset: 0, - }, + {type: 'value', value: 1, offset: 0}, ); }); @@ -430,30 +414,22 @@ describe('Native Animated', () => { {type: 'multiplication', input: expect.any(Array)}, ); const multiplicationCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - (call) => call[1].type === 'multiplication', + call => call[1].type === 'multiplication', ); expect(multiplicationCalls.length).toBe(1); const multiplicationCall = multiplicationCalls[0]; const multiplicationNodeTag = multiplicationCall[0]; const multiplicationConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( - (call) => call[1] === multiplicationNodeTag, + call => call[1] === multiplicationNodeTag, ); expect(multiplicationConnectionCalls.length).toBe(2); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( multiplicationCall[1].input[0], - { - type: 'value', - value: 2, - offset: 0, - }, + {type: 'value', value: 2, offset: 0}, ); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( multiplicationCall[1].input[1], - { - type: 'value', - value: 1, - offset: 0, - }, + {type: 'value', value: 1, offset: 0}, ); }); @@ -472,30 +448,22 @@ describe('Native Animated', () => { {type: 'division', input: expect.any(Array)}, ); const divisionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - (call) => call[1].type === 'division', + call => call[1].type === 'division', ); expect(divisionCalls.length).toBe(1); const divisionCall = divisionCalls[0]; const divisionNodeTag = divisionCall[0]; const divisionConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( - (call) => call[1] === divisionNodeTag, + call => call[1] === divisionNodeTag, ); expect(divisionConnectionCalls.length).toBe(2); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( divisionCall[1].input[0], - { - type: 'value', - value: 4, - offset: 0, - }, + {type: 'value', value: 4, offset: 0}, ); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( divisionCall[1].input[1], - { - type: 'value', - value: 2, - offset: 0, - }, + {type: 'value', value: 2, offset: 0}, ); }); @@ -512,22 +480,18 @@ describe('Native Animated', () => { {type: 'modulus', modulus: 4, input: expect.any(Number)}, ); const moduloCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - (call) => call[1].type === 'modulus', + call => call[1].type === 'modulus', ); expect(moduloCalls.length).toBe(1); const moduloCall = moduloCalls[0]; const moduloNodeTag = moduloCall[0]; const moduloConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( - (call) => call[1] === moduloNodeTag, + call => call[1] === moduloNodeTag, ); expect(moduloConnectionCalls.length).toBe(1); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( moduloCall[1].input, - { - type: 'value', - value: 4, - offset: 0, - }, + {type: 'value', value: 4, offset: 0}, ); }); @@ -561,10 +525,10 @@ describe('Native Animated', () => { }, ); const interpolationNodeTag = NativeAnimatedModule.createAnimatedNode.mock.calls.find( - (call) => call[1].type === 'interpolation', + call => call[1].type === 'interpolation', )[0]; const valueNodeTag = NativeAnimatedModule.createAnimatedNode.mock.calls.find( - (call) => call[1].type === 'value', + call => call[1].type === 'value', )[0]; expect(NativeAnimatedModule.connectAnimatedNodes).toBeCalledWith( valueNodeTag, @@ -613,22 +577,18 @@ describe('Native Animated', () => { {type: 'diffclamp', input: expect.any(Number), max: 20, min: 0}, ); const diffClampCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - (call) => call[1].type === 'diffclamp', + call => call[1].type === 'diffclamp', ); expect(diffClampCalls.length).toBe(1); const diffClampCall = diffClampCalls[0]; const diffClampNodeTag = diffClampCall[0]; const diffClampConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( - (call) => call[1] === diffClampNodeTag, + call => call[1] === diffClampNodeTag, ); expect(diffClampConnectionCalls.length).toBe(1); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( diffClampCall[1].input, - { - type: 'value', - value: 2, - offset: 0, - }, + {type: 'value', value: 2, offset: 0}, ); }); diff --git a/Libraries/Animated/src/__tests__/Easing-test.js b/Libraries/Animated/src/__tests__/Easing-test.js index 088c0ca7829..409b1a7c3a8 100644 --- a/Libraries/Animated/src/__tests__/Easing-test.js +++ b/Libraries/Animated/src/__tests__/Easing-test.js @@ -449,8 +449,8 @@ describe('Easing', () => { ], }; - Object.keys(Samples).forEach(function (type) { - it('should ease ' + type, function () { + Object.keys(Samples).forEach(function(type) { + it('should ease ' + type, function() { const [modeName, easingName, isFunction] = type.split('_'); let easing = Easing[easingName]; if (isFunction !== undefined) { diff --git a/Libraries/Animated/src/__tests__/bezier-test.js b/Libraries/Animated/src/__tests__/bezier-test.js index 846edc12828..e7be582a524 100644 --- a/Libraries/Animated/src/__tests__/bezier-test.js +++ b/Libraries/Animated/src/__tests__/bezier-test.js @@ -19,7 +19,7 @@ const bezier = require('../bezier'); -const identity = function (x) { +const identity = function(x) { return x; }; @@ -28,7 +28,7 @@ function assertClose(a, b, precision = 3) { } function makeAssertCloseWithPrecision(precision) { - return function (a, b) { + return function(a, b) { assertClose(a, b, precision); }; } @@ -44,43 +44,43 @@ function allEquals(be1, be2, samples, assertion) { } function repeat(n) { - return function (f) { + return function(f) { for (let i = 0; i < n; ++i) { f(); } }; } -describe('bezier', function () { - it('should be a function', function () { +describe('bezier', function() { + it('should be a function', function() { expect(typeof bezier === 'function').toBe(true); }); - it('should creates an object', function () { + it('should creates an object', function() { expect(typeof bezier(0, 0, 1, 1) === 'function').toBe(true); }); - it('should fail with wrong arguments', function () { - expect(function () { + it('should fail with wrong arguments', function() { + expect(function() { bezier(0.5, 0.5, -5, 0.5); }).toThrow(); - expect(function () { + expect(function() { bezier(0.5, 0.5, 5, 0.5); }).toThrow(); - expect(function () { + expect(function() { bezier(-2, 0.5, 0.5, 0.5); }).toThrow(); - expect(function () { + expect(function() { bezier(2, 0.5, 0.5, 0.5); }).toThrow(); }); - describe('linear curves', function () { - it('should be linear', function () { + describe('linear curves', function() { + it('should be linear', function() { allEquals(bezier(0, 0, 1, 1), bezier(1, 1, 0, 0), 100); allEquals(bezier(0, 0, 1, 1), identity, 100); }); }); - describe('common properties', function () { - it('should be the right value at extremes', function () { - repeat(10)(function () { + describe('common properties', function() { + it('should be the right value at extremes', function() { + repeat(10)(function() { const a = Math.random(), b = 2 * Math.random() - 0.5, c = Math.random(), @@ -91,24 +91,24 @@ describe('bezier', function () { }); }); - it('should approach the projected value of its x=y projected curve', function () { - repeat(10)(function () { + it('should approach the projected value of its x=y projected curve', function() { + repeat(10)(function() { const a = Math.random(), b = Math.random(), c = Math.random(), d = Math.random(); const easing = bezier(a, b, c, d); const projected = bezier(b, a, d, c); - const composed = function (x) { + const composed = function(x) { return projected(easing(x)); }; allEquals(identity, composed, 100, makeAssertCloseWithPrecision(2)); }); }); }); - describe('two same instances', function () { - it('should be strictly equals', function () { - repeat(10)(function () { + describe('two same instances', function() { + it('should be strictly equals', function() { + repeat(10)(function() { const a = Math.random(), b = 2 * Math.random() - 0.5, c = Math.random(), @@ -117,9 +117,9 @@ describe('bezier', function () { }); }); }); - describe('symmetric curves', function () { - it('should have a central value y~=0.5 at x=0.5', function () { - repeat(10)(function () { + describe('symmetric curves', function() { + it('should have a central value y~=0.5 at x=0.5', function() { + repeat(10)(function() { const a = Math.random(), b = 2 * Math.random() - 0.5, c = 1 - a, @@ -128,14 +128,14 @@ describe('bezier', function () { assertClose(easing(0.5), 0.5, 2); }); }); - it('should be symmetrical', function () { - repeat(10)(function () { + it('should be symmetrical', function() { + repeat(10)(function() { const a = Math.random(), b = 2 * Math.random() - 0.5, c = 1 - a, d = 1 - b; const easing = bezier(a, b, c, d); - const sym = function (x) { + const sym = function(x) { return 1 - easing(1 - x); }; allEquals(easing, sym, 100, makeAssertCloseWithPrecision(2)); diff --git a/Libraries/Animated/src/createAnimatedComponent.js b/Libraries/Animated/src/createAnimatedComponent.js index 7e7266713d9..099e71c8faa 100644 --- a/Libraries/Animated/src/createAnimatedComponent.js +++ b/Libraries/Animated/src/createAnimatedComponent.js @@ -56,7 +56,7 @@ function createAnimatedComponent( } _detachNativeEvents() { - this._eventDetachers.forEach((remove) => remove()); + this._eventDetachers.forEach(remove => remove()); this._eventDetachers = []; } @@ -140,7 +140,7 @@ function createAnimatedComponent( _setComponentRef = setAndForwardRef({ getForwardedRef: () => this.props.forwardedRef, - setLocalRef: (ref) => { + setLocalRef: ref => { this._prevComponent = this._component; this._component = ref; diff --git a/Libraries/Animated/src/nodes/AnimatedInterpolation.js b/Libraries/Animated/src/nodes/AnimatedInterpolation.js index 5b4d538cbe9..a32bb9c2a7c 100644 --- a/Libraries/Animated/src/nodes/AnimatedInterpolation.js +++ b/Libraries/Animated/src/nodes/AnimatedInterpolation.js @@ -30,7 +30,7 @@ export type InterpolationConfigType = { extrapolateRight?: ExtrapolateType, }; -const linear = (t) => t; +const linear = t => t; /** * Very handy helper to map input ranges to output ranges with an easing @@ -75,7 +75,7 @@ function createInterpolation( extrapolateRight = config.extrapolate; } - return (input) => { + return input => { invariant( typeof input === 'number', 'Cannot interpolation an input which is not a number', @@ -209,7 +209,7 @@ function createInterpolationFromStringOutputRange( * guard against this possibility. */ const outputRanges = outputRange[0].match(stringShapeRegex).map(() => []); - outputRange.forEach((value) => { + outputRange.forEach(value => { /* $FlowFixMe(>=0.18.0): `value.match()` can return `null`. Need to guard * against this possibility. */ @@ -233,7 +233,7 @@ function createInterpolationFromStringOutputRange( // round the opacity (4th column). const shouldRound = isRgbOrRgba(outputRange[0]); - return (input) => { + return input => { let i = 0; // 'rgba(0, 100, 200, 0)' // -> diff --git a/Libraries/Animated/src/nodes/AnimatedNode.js b/Libraries/Animated/src/nodes/AnimatedNode.js index a3f92481332..7371d49fd5b 100644 --- a/Libraries/Animated/src/nodes/AnimatedNode.js +++ b/Libraries/Animated/src/nodes/AnimatedNode.js @@ -121,7 +121,7 @@ class AnimatedNode { NativeAnimatedAPI.startListeningToAnimatedNodeValue(this.__getNativeTag()); this.__nativeAnimatedValueListener = NativeAnimatedHelper.nativeEventEmitter.addListener( 'onAnimatedValueUpdate', - (data) => { + data => { if (data.tag !== this.__getNativeTag()) { return; } diff --git a/Libraries/Animated/src/nodes/AnimatedTransform.js b/Libraries/Animated/src/nodes/AnimatedTransform.js index 0bdbd65bd29..8c2dd25852f 100644 --- a/Libraries/Animated/src/nodes/AnimatedTransform.js +++ b/Libraries/Animated/src/nodes/AnimatedTransform.js @@ -23,7 +23,7 @@ class AnimatedTransform extends AnimatedWithChildren { } __makeNative() { - this._transforms.forEach((transform) => { + this._transforms.forEach(transform => { for (const key in transform) { const value = transform[key]; if (value instanceof AnimatedNode) { @@ -35,7 +35,7 @@ class AnimatedTransform extends AnimatedWithChildren { } __getValue(): $ReadOnlyArray { - return this._transforms.map((transform) => { + return this._transforms.map(transform => { const result = {}; for (const key in transform) { const value = transform[key]; @@ -50,7 +50,7 @@ class AnimatedTransform extends AnimatedWithChildren { } __getAnimatedValue(): $ReadOnlyArray { - return this._transforms.map((transform) => { + return this._transforms.map(transform => { const result = {}; for (const key in transform) { const value = transform[key]; @@ -66,7 +66,7 @@ class AnimatedTransform extends AnimatedWithChildren { } __attach(): void { - this._transforms.forEach((transform) => { + this._transforms.forEach(transform => { for (const key in transform) { const value = transform[key]; if (value instanceof AnimatedNode) { @@ -77,7 +77,7 @@ class AnimatedTransform extends AnimatedWithChildren { } __detach(): void { - this._transforms.forEach((transform) => { + this._transforms.forEach(transform => { for (const key in transform) { const value = transform[key]; if (value instanceof AnimatedNode) { @@ -91,7 +91,7 @@ class AnimatedTransform extends AnimatedWithChildren { __getNativeConfig(): any { const transConfigs = []; - this._transforms.forEach((transform) => { + this._transforms.forEach(transform => { for (const key in transform) { const value = transform[key]; if (value instanceof AnimatedNode) { diff --git a/Libraries/Animated/src/nodes/AnimatedValue.js b/Libraries/Animated/src/nodes/AnimatedValue.js index f83fbf0c98e..7306fc77b94 100644 --- a/Libraries/Animated/src/nodes/AnimatedValue.js +++ b/Libraries/Animated/src/nodes/AnimatedValue.js @@ -57,7 +57,7 @@ function _flush(rootNode: AnimatedValue): void { } findAnimatedStyles(rootNode); /* $FlowFixMe */ - animatedStyles.forEach((animatedStyle) => animatedStyle.update()); + animatedStyles.forEach(animatedStyle => animatedStyle.update()); } /** @@ -208,12 +208,12 @@ class AnimatedValue extends AnimatedWithChildren { this._animation = animation; animation.start( this._value, - (value) => { + value => { // Natively driven animations will never call into that callback, therefore we can always // pass flush = true to allow the updated value to propagate to native with setNativeProps this._updateValue(value, true /* flush */); }, - (result) => { + result => { this._animation = null; if (handle !== null) { InteractionManager.clearInteractionHandle(handle); diff --git a/Libraries/Animated/src/polyfills/InteractionManager.js b/Libraries/Animated/src/polyfills/InteractionManager.js index 9e68781767e..c2247c762a3 100644 --- a/Libraries/Animated/src/polyfills/InteractionManager.js +++ b/Libraries/Animated/src/polyfills/InteractionManager.js @@ -10,6 +10,6 @@ 'use strict'; module.exports = { - createInteractionHandle: function () {}, - clearInteractionHandle: function () {}, + createInteractionHandle: function() {}, + clearInteractionHandle: function() {}, }; diff --git a/Libraries/Animated/src/polyfills/Set.js b/Libraries/Animated/src/polyfills/Set.js index d64df222090..39205b8f9f9 100644 --- a/Libraries/Animated/src/polyfills/Set.js +++ b/Libraries/Animated/src/polyfills/Set.js @@ -13,13 +13,13 @@ function SetPolyfill() { this._cache = []; } -SetPolyfill.prototype.add = function (e) { +SetPolyfill.prototype.add = function(e) { if (this._cache.indexOf(e) === -1) { this._cache.push(e); } }; -SetPolyfill.prototype.forEach = function (cb) { +SetPolyfill.prototype.forEach = function(cb) { this._cache.forEach(cb); }; diff --git a/Libraries/Animated/src/polyfills/flattenStyle.js b/Libraries/Animated/src/polyfills/flattenStyle.js index 63d9483e2a2..b50057af284 100644 --- a/Libraries/Animated/src/polyfills/flattenStyle.js +++ b/Libraries/Animated/src/polyfills/flattenStyle.js @@ -8,6 +8,6 @@ */ 'use strict'; -module.exports = function (style) { +module.exports = function(style) { return style; }; diff --git a/Libraries/AppState/AppState.js b/Libraries/AppState/AppState.js index c00936f6038..b5fb59bd9fd 100644 --- a/Libraries/AppState/AppState.js +++ b/Libraries/AppState/AppState.js @@ -47,7 +47,7 @@ class AppState extends NativeEventEmitter { // prop is up to date, we have to register an observer that updates it // whenever the state changes, even if nobody cares. We should just // deprecate the `currentState` property and get rid of this. - this.addListener('appStateDidChange', (appStateData) => { + this.addListener('appStateDidChange', appStateData => { eventUpdated = true; this.currentState = appStateData.app_state; }); @@ -55,7 +55,7 @@ class AppState extends NativeEventEmitter { // TODO: see above - this request just populates the value of `currentState` // when the module is first initialized. Would be better to get rid of the // prop and expose `getCurrentAppState` method directly. - NativeAppState.getCurrentAppState((appStateData) => { + NativeAppState.getCurrentAppState(appStateData => { // It's possible that the state will have changed here & listeners need to be notified if (!eventUpdated && this.currentState !== appStateData.app_state) { this.currentState = appStateData.app_state; @@ -86,7 +86,7 @@ class AppState extends NativeEventEmitter { case 'change': { this._eventHandlers[type].set( handler, - this.addListener('appStateDidChange', (appStateData) => { + this.addListener('appStateDidChange', appStateData => { handler(appStateData.app_state); }), ); @@ -104,7 +104,7 @@ class AppState extends NativeEventEmitter { case 'focus': { this._eventHandlers[type].set( handler, - this.addListener('appStateFocusChange', (hasFocus) => { + this.addListener('appStateFocusChange', hasFocus => { if (type === 'blur' && !hasFocus) { handler(); } diff --git a/Libraries/BatchedBridge/MessageQueue.js b/Libraries/BatchedBridge/MessageQueue.js index 79cbb8f19e2..3756b083fbd 100644 --- a/Libraries/BatchedBridge/MessageQueue.js +++ b/Libraries/BatchedBridge/MessageQueue.js @@ -86,7 +86,7 @@ class MessageQueue { static spy(spyOrToggle: boolean | ((data: SpyData) => void)) { if (spyOrToggle === true) { - MessageQueue.prototype.__spy = (info) => { + MessageQueue.prototype.__spy = info => { console.log( `${info.type === TO_JS ? 'N->JS' : 'JS->N'} : ` + `${info.module ? info.module + '.' : ''}${info.method}` + @@ -148,7 +148,7 @@ class MessageQueue { this._lazyCallableModules[name] = () => module; } - registerLazyCallableModule(name: string, factory: (void) => Object) { + registerLazyCallableModule(name: string, factory: void => Object) { let module: Object; let getValue: ?(void) => Object = factory; this._lazyCallableModules[name] = () => { @@ -253,7 +253,7 @@ class MessageQueue { // folly-convertible. As a special case, if a prop value is a // function it is permitted here, and special-cased in the // conversion. - const isValidArgument = (val) => { + const isValidArgument = val => { const t = typeof val; if ( t === 'undefined' || diff --git a/Libraries/BatchedBridge/NativeModules.js b/Libraries/BatchedBridge/NativeModules.js index cf77b10cc4e..541012582c0 100644 --- a/Libraries/BatchedBridge/NativeModules.js +++ b/Libraries/BatchedBridge/NativeModules.js @@ -106,8 +106,8 @@ function genMethod(moduleID: number, methodID: number, type: MethodType) { moduleID, methodID, args, - (data) => resolve(data), - (errorData) => + data => resolve(data), + errorData => reject(updateErrorWithErrorData(errorData, enqueueingFrameError)), ); }); diff --git a/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js b/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js index d0e5477822e..667799a42f4 100644 --- a/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js +++ b/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js @@ -15,8 +15,8 @@ * cases. */ const MessageQueueTestModule = { - testHook1: function () {}, - testHook2: function () {}, + testHook1: function() {}, + testHook2: function() {}, }; module.exports = MessageQueueTestModule; diff --git a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js index fe57b0d2459..42abd597dd8 100644 --- a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js +++ b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js @@ -30,8 +30,8 @@ const assertQueue = (flushedQueue, index, moduleID, methodID, params) => { // // [ ] Local modules that throw exceptions are gracefully caught. In that case // local callbacks stored by IDs are cleaned up. -describe('MessageQueue', function () { - beforeEach(function () { +describe('MessageQueue', function() { + beforeEach(function() { jest.resetModules(); MessageQueue = require('../MessageQueue'); MessageQueueTestModule = require('../__mocks__/MessageQueueTestModule'); @@ -81,25 +81,13 @@ describe('MessageQueue', function () { }); it('should throw when calling the same callback twice', () => { - queue.enqueueNativeCall( - 0, - 1, - [], - () => {}, - () => {}, - ); + queue.enqueueNativeCall(0, 1, [], () => {}, () => {}); queue.__invokeCallback(1, []); expect(() => queue.__invokeCallback(1, [])).toThrow(); }); it('should throw when calling both success and failure callback', () => { - queue.enqueueNativeCall( - 0, - 1, - [], - () => {}, - () => {}, - ); + queue.enqueueNativeCall(0, 1, [], () => {}, () => {}); queue.__invokeCallback(1, []); expect(() => queue.__invokeCallback(0, [])).toThrow(); }); @@ -140,7 +128,7 @@ describe('MessageQueue', function () { it('should check if the global error handler is not overridden by the DebuggerInternal object', () => { const dummyModule = { - dummy: function () {}, + dummy: function() {}, }; const name = 'emptyModuleName'; const factory = jest.fn(() => dummyModule); @@ -152,7 +140,7 @@ describe('MessageQueue', function () { it('should check if the global error handler is overridden by the DebuggerInternal object', () => { const dummyModule = { - dummy: function () {}, + dummy: function() {}, }; const name = 'emptyModuleName'; const factory = jest.fn(() => dummyModule); diff --git a/Libraries/BatchedBridge/__tests__/NativeModules-test.js b/Libraries/BatchedBridge/__tests__/NativeModules-test.js index 35f1c43764a..bedff6127d9 100644 --- a/Libraries/BatchedBridge/__tests__/NativeModules-test.js +++ b/Libraries/BatchedBridge/__tests__/NativeModules-test.js @@ -38,8 +38,8 @@ const assertQueue = (flushedQueue, index, moduleID, methodID, params) => { // success callbacks are cleaned up. // // [ ] Remote invocation throws if not supplying an error callback. -describe('MessageQueue', function () { - beforeEach(function () { +describe('MessageQueue', function() { + beforeEach(function() { jest.resetModules(); global.__fbBatchedBridgeConfig = require('../__mocks__/MessageQueueTestConfig'); @@ -55,7 +55,7 @@ describe('MessageQueue', function () { assertQueue(flushedQueue, 0, 0, 0, ['foo']); }); - it('should make round trip and clear memory', function () { + it('should make round trip and clear memory', function() { const onFail = jest.fn(); const onSucc = jest.fn(); @@ -101,7 +101,7 @@ describe('MessageQueue', function () { // Handle the first remote invocation by signaling failure. BatchedBridge.__invokeCallback(firstFailCBID, ['firstFailure']); // The failure callback was already invoked, the success is no longer valid - expect(function () { + expect(function() { BatchedBridge.__invokeCallback(firstSuccCBID, ['firstSucc']); }).toThrow(); expect(onFail.mock.calls.length).toBe(1); @@ -110,14 +110,14 @@ describe('MessageQueue', function () { // Handle the second remote invocation by signaling success. BatchedBridge.__invokeCallback(secondSuccCBID, ['secondSucc']); // The success callback was already invoked, the fail cb is no longer valid - expect(function () { + expect(function() { BatchedBridge.__invokeCallback(secondFailCBID, ['secondFail']); }).toThrow(); expect(onFail.mock.calls.length).toBe(1); expect(onSucc.mock.calls.length).toBe(1); }); - it('promise-returning methods (type=promise)', async function () { + it('promise-returning methods (type=promise)', async function() { // Perform communication const promise1 = NativeModules.RemoteModule1.promiseReturningMethod( 'paloAlto', @@ -162,7 +162,7 @@ describe('MessageQueue', function () { // Handle the first remote invocation by signaling failure. BatchedBridge.__invokeCallback(firstFailCBID, [{message: 'firstFailure'}]); // The failure callback was already invoked, the success is no longer valid - expect(function () { + expect(function() { BatchedBridge.__invokeCallback(firstSuccCBID, ['firstSucc']); }).toThrow(); await expect(promise1).rejects.toBeInstanceOf(Error); @@ -171,18 +171,18 @@ describe('MessageQueue', function () { // Handle the second remote invocation by signaling success. BatchedBridge.__invokeCallback(secondSuccCBID, ['secondSucc']); // The success callback was already invoked, the fail cb is no longer valid - expect(function () { + expect(function() { BatchedBridge.__invokeCallback(secondFailCBID, ['secondFail']); }).toThrow(); await promise2; }); describe('sync methods', () => { - afterEach(function () { + afterEach(function() { delete global.nativeCallSyncHook; }); - it('throwing an exception', function () { + it('throwing an exception', function() { global.nativeCallSyncHook = jest.fn(() => { throw new Error('firstFailure'); }); @@ -206,7 +206,7 @@ describe('MessageQueue', function () { }); }); - it('returning a value', function () { + it('returning a value', function() { global.nativeCallSyncHook = jest.fn(() => { return 'secondSucc'; }); diff --git a/Libraries/Blob/BlobManager.js b/Libraries/Blob/BlobManager.js index da32f4b4efc..e12512392a3 100644 --- a/Libraries/Blob/BlobManager.js +++ b/Libraries/Blob/BlobManager.js @@ -25,7 +25,7 @@ import invariant from 'invariant'; * http://stackoverflow.com/questions/105034 */ function uuidv4(): string { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { const r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8; return v.toString(16); @@ -66,7 +66,7 @@ class BlobManager { invariant(NativeBlobModule, 'NativeBlobModule is available.'); const blobId = uuidv4(); - const items = parts.map((part) => { + const items = parts.map(part => { if ( part instanceof ArrayBuffer || (global.ArrayBufferView && part instanceof global.ArrayBufferView) diff --git a/Libraries/Blob/FileReader.js b/Libraries/Blob/FileReader.js index 93e31533821..15a8b44d0bb 100644 --- a/Libraries/Blob/FileReader.js +++ b/Libraries/Blob/FileReader.js @@ -62,7 +62,7 @@ class FileReader extends (EventTarget(...READER_EVENTS): any) { } _clearSubscriptions(): void { - this._subscriptions.forEach((sub) => sub.remove()); + this._subscriptions.forEach(sub => sub.remove()); this._subscriptions = []; } @@ -102,7 +102,7 @@ class FileReader extends (EventTarget(...READER_EVENTS): any) { this._result = text; this._setReadyState(DONE); }, - (error) => { + error => { if (this._aborted) { return; } @@ -129,7 +129,7 @@ class FileReader extends (EventTarget(...READER_EVENTS): any) { this._result = text; this._setReadyState(DONE); }, - (error) => { + error => { if (this._aborted) { return; } diff --git a/Libraries/Blob/URL.js b/Libraries/Blob/URL.js index 18e70460e21..f2b6f7f277c 100644 --- a/Libraries/Blob/URL.js +++ b/Libraries/Blob/URL.js @@ -58,7 +58,7 @@ export class URLSearchParams { constructor(params: any) { if (typeof params === 'object') { - Object.keys(params).forEach((key) => this.append(key, params[key])); + Object.keys(params).forEach(key => this.append(key, params[key])); } } @@ -119,7 +119,9 @@ export class URL { if (BLOB_URL_PREFIX === null) { throw new Error('Cannot create URL for blob!'); } - return `${BLOB_URL_PREFIX}${blob.data.blobId}?offset=${blob.data.offset}&size=${blob.size}`; + return `${BLOB_URL_PREFIX}${blob.data.blobId}?offset=${ + blob.data.offset + }&size=${blob.size}`; } static revokeObjectURL(url: string) { diff --git a/Libraries/Blob/__tests__/Blob-test.js b/Libraries/Blob/__tests__/Blob-test.js index 0ec3d8904d8..42aea6f05e5 100644 --- a/Libraries/Blob/__tests__/Blob-test.js +++ b/Libraries/Blob/__tests__/Blob-test.js @@ -16,7 +16,7 @@ jest.setMock('../../BatchedBridge/NativeModules', { const Blob = require('../Blob'); -describe('Blob', function () { +describe('Blob', function() { it('should create empty blob', () => { const blob = new Blob(); expect(blob).toBeInstanceOf(Blob); diff --git a/Libraries/Blob/__tests__/BlobManager-test.js b/Libraries/Blob/__tests__/BlobManager-test.js index bc788cdbf61..e711e68f956 100644 --- a/Libraries/Blob/__tests__/BlobManager-test.js +++ b/Libraries/Blob/__tests__/BlobManager-test.js @@ -17,7 +17,7 @@ jest.setMock('../../BatchedBridge/NativeModules', { const Blob = require('../Blob'); const BlobManager = require('../BlobManager'); -describe('BlobManager', function () { +describe('BlobManager', function() { it('should create blob from parts', () => { const blob = BlobManager.createFromParts([], {type: 'text/html'}); expect(blob).toBeInstanceOf(Blob); diff --git a/Libraries/Blob/__tests__/File-test.js b/Libraries/Blob/__tests__/File-test.js index ee097235e22..eefbe2864ed 100644 --- a/Libraries/Blob/__tests__/File-test.js +++ b/Libraries/Blob/__tests__/File-test.js @@ -17,8 +17,8 @@ jest.setMock('../../BatchedBridge/NativeModules', { const Blob = require('../Blob'); const File = require('../File'); -describe('babel 7 smoke test', function () { - it('should be able to extend a class with native name', function () { +describe('babel 7 smoke test', function() { + it('should be able to extend a class with native name', function() { let called = false; class Array { constructor() { @@ -40,14 +40,14 @@ describe('babel 7 smoke test', function () { }); }); -describe('Blob', function () { - it('regression caused by circular dep && babel 7', function () { +describe('Blob', function() { + it('regression caused by circular dep && babel 7', function() { const blob = new Blob([], {type: 'image/jpeg'}); expect(blob).toBeInstanceOf(Blob); }); }); -describe('File', function () { +describe('File', function() { it('should create empty file', () => { const file = new File([], 'test.jpg'); expect(file).toBeInstanceOf(File); diff --git a/Libraries/Blob/__tests__/FileReader-test.js b/Libraries/Blob/__tests__/FileReader-test.js index 3ccf4924242..4e73df3c569 100644 --- a/Libraries/Blob/__tests__/FileReader-test.js +++ b/Libraries/Blob/__tests__/FileReader-test.js @@ -18,7 +18,7 @@ jest.unmock('event-target-shim').setMock('../../BatchedBridge/NativeModules', { const Blob = require('../Blob'); const FileReader = require('../FileReader'); -describe('FileReader', function () { +describe('FileReader', function() { it('should read blob as text', async () => { const e = await new Promise((resolve, reject) => { const reader = new FileReader(); diff --git a/Libraries/Blob/__tests__/URL-test.js b/Libraries/Blob/__tests__/URL-test.js index fa7e234385e..713ceeea0ef 100644 --- a/Libraries/Blob/__tests__/URL-test.js +++ b/Libraries/Blob/__tests__/URL-test.js @@ -12,7 +12,7 @@ const URL = require('../URL').URL; -describe('URL', function () { +describe('URL', function() { it('should pass Mozilla Dev Network examples', () => { const a = new URL('/', 'https://developer.mozilla.org'); expect(a.href).toBe('https://developer.mozilla.org/'); diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js index c27fdadc33a..7d7e92a444b 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.android.js @@ -41,25 +41,25 @@ const AccessibilityInfo = { /** * iOS only */ - isBoldTextEnabled: function (): Promise { + isBoldTextEnabled: function(): Promise { return Promise.resolve(false); }, /** * iOS only */ - isGrayscaleEnabled: function (): Promise { + isGrayscaleEnabled: function(): Promise { return Promise.resolve(false); }, /** * iOS only */ - isInvertColorsEnabled: function (): Promise { + isInvertColorsEnabled: function(): Promise { return Promise.resolve(false); }, - isReduceMotionEnabled: function (): Promise { + isReduceMotionEnabled: function(): Promise { return new Promise((resolve, reject) => { if (NativeAccessibilityInfo) { NativeAccessibilityInfo.isReduceMotionEnabled(resolve); @@ -72,11 +72,11 @@ const AccessibilityInfo = { /** * iOS only */ - isReduceTransparencyEnabled: function (): Promise { + isReduceTransparencyEnabled: function(): Promise { return Promise.resolve(false); }, - isScreenReaderEnabled: function (): Promise { + isScreenReaderEnabled: function(): Promise { return new Promise((resolve, reject) => { if (NativeAccessibilityInfo) { NativeAccessibilityInfo.isTouchExplorationEnabled(resolve); @@ -98,7 +98,7 @@ const AccessibilityInfo = { return this.isScreenReaderEnabled; }, - addEventListener: function ( + addEventListener: function( eventName: ChangeEventName, handler: Function, ): void { @@ -107,14 +107,14 @@ const AccessibilityInfo = { if (eventName === 'change' || eventName === 'screenReaderChanged') { listener = RCTDeviceEventEmitter.addListener( TOUCH_EXPLORATION_EVENT, - (enabled) => { + enabled => { handler(enabled); }, ); } else if (eventName === 'reduceMotionChanged') { listener = RCTDeviceEventEmitter.addListener( REDUCE_MOTION_EVENT, - (enabled) => { + enabled => { handler(enabled); }, ); @@ -123,7 +123,7 @@ const AccessibilityInfo = { _subscriptions.set(handler, listener); }, - removeEventListener: function ( + removeEventListener: function( eventName: ChangeEventName, handler: Function, ): void { @@ -140,7 +140,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#setaccessibilityfocus */ - setAccessibilityFocus: function (reactTag: number): void { + setAccessibilityFocus: function(reactTag: number): void { UIManager.sendAccessibilityEvent( reactTag, UIManager.getConstants().AccessibilityEventTypes.typeViewFocused, @@ -152,7 +152,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#announceforaccessibility */ - announceForAccessibility: function (announcement: string): void { + announceForAccessibility: function(announcement: string): void { if (NativeAccessibilityInfo) { NativeAccessibilityInfo.announceForAccessibility(announcement); } diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js index 1550c0e46b8..c09b16d470f 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js @@ -57,7 +57,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#isBoldTextEnabled */ - isBoldTextEnabled: function (): Promise { + isBoldTextEnabled: function(): Promise { return new Promise((resolve, reject) => { if (NativeAccessibilityManager) { NativeAccessibilityManager.getCurrentBoldTextState(resolve, reject); @@ -75,7 +75,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#isGrayscaleEnabled */ - isGrayscaleEnabled: function (): Promise { + isGrayscaleEnabled: function(): Promise { return new Promise((resolve, reject) => { if (NativeAccessibilityManager) { NativeAccessibilityManager.getCurrentGrayscaleState(resolve, reject); @@ -93,7 +93,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#isInvertColorsEnabled */ - isInvertColorsEnabled: function (): Promise { + isInvertColorsEnabled: function(): Promise { return new Promise((resolve, reject) => { if (NativeAccessibilityManager) { NativeAccessibilityManager.getCurrentInvertColorsState(resolve, reject); @@ -111,7 +111,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#isReduceMotionEnabled */ - isReduceMotionEnabled: function (): Promise { + isReduceMotionEnabled: function(): Promise { return new Promise((resolve, reject) => { if (NativeAccessibilityManager) { NativeAccessibilityManager.getCurrentReduceMotionState(resolve, reject); @@ -129,7 +129,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#isReduceTransparencyEnabled */ - isReduceTransparencyEnabled: function (): Promise { + isReduceTransparencyEnabled: function(): Promise { return new Promise((resolve, reject) => { if (NativeAccessibilityManager) { NativeAccessibilityManager.getCurrentReduceTransparencyState( @@ -150,7 +150,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#isScreenReaderEnabled */ - isScreenReaderEnabled: function (): Promise { + isScreenReaderEnabled: function(): Promise { return new Promise((resolve, reject) => { if (NativeAccessibilityManager) { NativeAccessibilityManager.getCurrentVoiceOverState(resolve, reject); @@ -203,7 +203,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#addeventlistener */ - addEventListener: function ( + addEventListener: function( eventName: ChangeEventName, handler: Function, ): Object { @@ -233,7 +233,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#setaccessibilityfocus */ - setAccessibilityFocus: function (reactTag: number): void { + setAccessibilityFocus: function(reactTag: number): void { if (NativeAccessibilityManager) { NativeAccessibilityManager.setAccessibilityFocus(reactTag); } @@ -244,7 +244,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#announceforaccessibility */ - announceForAccessibility: function (announcement: string): void { + announceForAccessibility: function(announcement: string): void { if (NativeAccessibilityManager) { NativeAccessibilityManager.announceForAccessibility(announcement); } @@ -255,7 +255,7 @@ const AccessibilityInfo = { * * See https://reactnative.dev/docs/accessibilityinfo.html#removeeventlistener */ - removeEventListener: function ( + removeEventListener: function( eventName: ChangeEventName, handler: Function, ): void { diff --git a/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 62bc6664305..9d0df8f0a73 100644 --- a/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -101,7 +101,10 @@ const ActivityIndicator = (props: Props, forwardedRef?: any) => { return ( + style={StyleSheet.compose( + styles.container, + style, + )}> {Platform.OS === 'android' ? ( // $FlowFixMe Flow doesn't know when this is the android component diff --git a/Libraries/Components/AppleTV/TVEventHandler.js b/Libraries/Components/AppleTV/TVEventHandler.js index d28483ab2fa..d5cd47afdce 100644 --- a/Libraries/Components/AppleTV/TVEventHandler.js +++ b/Libraries/Components/AppleTV/TVEventHandler.js @@ -30,7 +30,7 @@ class TVEventHandler { ); this.__nativeTVNavigationEventListener = this.__nativeTVNavigationEventEmitter.addListener( 'onHWKeyEvent', - (data) => { + data => { if (callback) { callback(component, data); } diff --git a/Libraries/Components/CheckBox/CheckBox.android.js b/Libraries/Components/CheckBox/CheckBox.android.js index 4a267a6a070..aed9cd9eb38 100644 --- a/Libraries/Components/CheckBox/CheckBox.android.js +++ b/Libraries/Components/CheckBox/CheckBox.android.js @@ -137,7 +137,7 @@ class CheckBox extends React.Component { _nativeRef: ?React.ElementRef = null; _setNativeRef = setAndForwardRef({ getForwardedRef: () => this.props.forwardedRef, - setLocalRef: (ref) => { + setLocalRef: ref => { this._nativeRef = ref; }, }); diff --git a/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/Libraries/Components/DatePicker/DatePickerIOS.ios.js index 599ddb7493b..016c65bf5ab 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.ios.js @@ -146,7 +146,7 @@ class DatePickerIOS extends React.Component { { + ref={picker => { this._picker = picker; }} style={styles.datePickerIOS} diff --git a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index b0b17b90018..3758c669fd1 100644 --- a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -237,7 +237,7 @@ class DrawerLayoutAndroid extends React.Component { ); } - _onDrawerSlide = (event) => { + _onDrawerSlide = event => { if (this.props.onDrawerSlide) { this.props.onDrawerSlide(event); } @@ -258,7 +258,7 @@ class DrawerLayoutAndroid extends React.Component { } }; - _onDrawerStateChanged = (event) => { + _onDrawerStateChanged = event => { if (this.props.onDrawerStateChanged) { this.props.onDrawerStateChanged( DRAWER_STATES[event.nativeEvent.drawerState], diff --git a/Libraries/Components/Keyboard/Keyboard.js b/Libraries/Components/Keyboard/Keyboard.js index 1f8e674529b..c10fe53dad5 100644 --- a/Libraries/Components/Keyboard/Keyboard.js +++ b/Libraries/Components/Keyboard/Keyboard.js @@ -179,7 +179,7 @@ const Keyboard = { // Throw away the dummy object and reassign it to original module KeyboardEventEmitter.dismiss = dismissKeyboard; -KeyboardEventEmitter.scheduleLayoutAnimation = function (event: KeyboardEvent) { +KeyboardEventEmitter.scheduleLayoutAnimation = function(event: KeyboardEvent) { const {duration, easing} = event; if (duration != null && duration !== 0) { LayoutAnimation.configureNext({ diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index b9c2aee178a..7c794ea5e8d 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -138,7 +138,7 @@ class KeyboardAvoidingView extends React.Component { } componentWillUnmount(): void { - this._subscriptions.forEach((subscription) => { + this._subscriptions.forEach(subscription => { subscription.remove(); }); } @@ -170,7 +170,10 @@ class KeyboardAvoidingView extends React.Component { return ( {children} @@ -185,9 +188,12 @@ class KeyboardAvoidingView extends React.Component { onLayout={this._onLayout} {...props}> + style={StyleSheet.compose( + contentContainerStyle, + { + bottom: bottomHeight, + }, + )}> {children} @@ -197,7 +203,10 @@ class KeyboardAvoidingView extends React.Component { return ( {children} diff --git a/Libraries/Components/Keyboard/__tests__/Keyboard-test.js b/Libraries/Components/Keyboard/__tests__/Keyboard-test.js index 9c934092ad8..181eb14b77b 100644 --- a/Libraries/Components/Keyboard/__tests__/Keyboard-test.js +++ b/Libraries/Components/Keyboard/__tests__/Keyboard-test.js @@ -67,7 +67,7 @@ describe('Keyboard', () => { }); describe('animation update type', () => { - const assertAnimationUpdateType = (type) => + const assertAnimationUpdateType = type => expect(LayoutAnimation.configureNext).toHaveBeenCalledWith( expect.objectContaining({ duration: expect.anything(), diff --git a/Libraries/Components/Picker/PickerAndroid.android.js b/Libraries/Components/Picker/PickerAndroid.android.js index 6d0be920d5a..a47d29bd5ec 100644 --- a/Libraries/Components/Picker/PickerAndroid.android.js +++ b/Libraries/Components/Picker/PickerAndroid.android.js @@ -85,7 +85,7 @@ function PickerAndroid(props: Props): React.Node { if (onValueChange != null) { if (position >= 0) { const children = React.Children.toArray(props.children).filter( - (item) => item != null, + item => item != null, ); const value = children[position].props.value; if (props.selectedValue !== value) { @@ -121,7 +121,10 @@ function PickerAndroid(props: Props): React.Node { prompt: props.prompt, ref: pickerRef, selected, - style: StyleSheet.compose(styles.pickerAndroid, props.style), + style: StyleSheet.compose( + styles.pickerAndroid, + props.style, + ), backgroundColor: props.backgroundColor, testID: props.testID, }; diff --git a/Libraries/Components/Picker/PickerIOS.ios.js b/Libraries/Components/Picker/PickerIOS.ios.js index bc465d5b775..c2a5f2946fd 100644 --- a/Libraries/Components/Picker/PickerIOS.ios.js +++ b/Libraries/Components/Picker/PickerIOS.ios.js @@ -83,8 +83,8 @@ class PickerIOS extends React.Component { let selectedIndex = 0; const items = []; React.Children.toArray(props.children) - .filter((child) => child !== null) - .forEach(function (child, index) { + .filter(child => child !== null) + .forEach(function(child, index) { if (child.props.value === props.selectedValue) { selectedIndex = index; } @@ -106,7 +106,7 @@ class PickerIOS extends React.Component { return ( { + ref={picker => { this._picker = picker; }} testID={this.props.testID} @@ -136,7 +136,7 @@ class PickerIOS extends React.Component { } } - _onChange = (event) => { + _onChange = event => { if (this.props.onChange) { this.props.onChange(event); } diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index 7138c748884..a520d17d287 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -123,7 +123,7 @@ const ScrollResponderMixin = { _subscriptionKeyboardWillHide: (null: ?EmitterSubscription), _subscriptionKeyboardDidShow: (null: ?EmitterSubscription), _subscriptionKeyboardDidHide: (null: ?EmitterSubscription), - scrollResponderMixinGetInitialState: function (): State { + scrollResponderMixinGetInitialState: function(): State { return { isTouching: false, lastMomentumScrollBeginTime: 0, @@ -142,7 +142,7 @@ const ScrollResponderMixin = { /** * Invoke this from an `onScroll` event. */ - scrollResponderHandleScrollShouldSetResponder: function (): boolean { + scrollResponderHandleScrollShouldSetResponder: function(): boolean { // Allow any event touch pass through if the default pan responder is disabled if (this.props.disableScrollViewPanResponder === true) { return false; @@ -175,7 +175,7 @@ const ScrollResponderMixin = { * true. * */ - scrollResponderHandleStartShouldSetResponder: function ( + scrollResponderHandleStartShouldSetResponder: function( e: PressEvent, ): boolean { // Allow any event touch pass through if the default pan responder is disabled @@ -206,7 +206,7 @@ const ScrollResponderMixin = { * * Invoke this from an `onStartShouldSetResponderCapture` event. */ - scrollResponderHandleStartShouldSetResponderCapture: function ( + scrollResponderHandleStartShouldSetResponderCapture: function( e: PressEvent, ): boolean { // The scroll view should receive taps instead of its descendants if: @@ -261,7 +261,7 @@ const ScrollResponderMixin = { * altogether. To improve this, find a way to disable the `UIScrollView` after * a touch has already started. */ - scrollResponderHandleResponderReject: function () {}, + scrollResponderHandleResponderReject: function() {}, /** * We will allow the scroll view to give up its lock iff it acquired the lock @@ -278,7 +278,7 @@ const ScrollResponderMixin = { * navigation of a swipe gesture higher in the view hierarchy, should be * rejected. */ - scrollResponderHandleTerminationRequest: function (): boolean { + scrollResponderHandleTerminationRequest: function(): boolean { return !this.state.observedScrollSinceBecomingResponder; }, @@ -287,7 +287,7 @@ const ScrollResponderMixin = { * * @param {PressEvent} e Event. */ - scrollResponderHandleTouchEnd: function (e: PressEvent) { + scrollResponderHandleTouchEnd: function(e: PressEvent) { const nativeEvent = e.nativeEvent; this.state.isTouching = nativeEvent.touches.length !== 0; this.props.onTouchEnd && this.props.onTouchEnd(e); @@ -298,7 +298,7 @@ const ScrollResponderMixin = { * * @param {PressEvent} e Event. */ - scrollResponderHandleTouchCancel: function (e: PressEvent) { + scrollResponderHandleTouchCancel: function(e: PressEvent) { this.state.isTouching = false; this.props.onTouchCancel && this.props.onTouchCancel(e); }, @@ -306,7 +306,7 @@ const ScrollResponderMixin = { /** * Invoke this from an `onResponderRelease` event. */ - scrollResponderHandleResponderRelease: function (e: PressEvent) { + scrollResponderHandleResponderRelease: function(e: PressEvent) { this.props.onResponderRelease && this.props.onResponderRelease(e); if (typeof e.target === 'number') { @@ -336,7 +336,7 @@ const ScrollResponderMixin = { } }, - scrollResponderHandleScroll: function (e: ScrollEvent) { + scrollResponderHandleScroll: function(e: ScrollEvent) { (this: any).state.observedScrollSinceBecomingResponder = true; (this: any).props.onScroll && (this: any).props.onScroll(e); }, @@ -344,7 +344,7 @@ const ScrollResponderMixin = { /** * Invoke this from an `onResponderGrant` event. */ - scrollResponderHandleResponderGrant: function (e: ScrollEvent) { + scrollResponderHandleResponderGrant: function(e: ScrollEvent) { this.state.observedScrollSinceBecomingResponder = false; this.props.onResponderGrant && this.props.onResponderGrant(e); this.state.becameResponderWhileAnimating = this.scrollResponderIsAnimating(); @@ -357,7 +357,7 @@ const ScrollResponderMixin = { * * Invoke this from an `onScrollBeginDrag` event. */ - scrollResponderHandleScrollBeginDrag: function (e: ScrollEvent) { + scrollResponderHandleScrollBeginDrag: function(e: ScrollEvent) { FrameRateLogger.beginScroll(); // TODO: track all scrolls after implementing onScrollEndAnimation this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e); }, @@ -365,7 +365,7 @@ const ScrollResponderMixin = { /** * Invoke this from an `onScrollEndDrag` event. */ - scrollResponderHandleScrollEndDrag: function (e: ScrollEvent) { + scrollResponderHandleScrollEndDrag: function(e: ScrollEvent) { const {velocity} = e.nativeEvent; // - If we are animating, then this is a "drag" that is stopping the scrollview and momentum end // will fire. @@ -384,7 +384,7 @@ const ScrollResponderMixin = { /** * Invoke this from an `onMomentumScrollBegin` event. */ - scrollResponderHandleMomentumScrollBegin: function (e: ScrollEvent) { + scrollResponderHandleMomentumScrollBegin: function(e: ScrollEvent) { this.state.lastMomentumScrollBeginTime = performanceNow(); this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e); }, @@ -392,7 +392,7 @@ const ScrollResponderMixin = { /** * Invoke this from an `onMomentumScrollEnd` event. */ - scrollResponderHandleMomentumScrollEnd: function (e: ScrollEvent) { + scrollResponderHandleMomentumScrollEnd: function(e: ScrollEvent) { FrameRateLogger.endScroll(); this.state.lastMomentumScrollEndTime = performanceNow(); this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(e); @@ -409,7 +409,7 @@ const ScrollResponderMixin = { * * @param {PressEvent} e Touch Start event. */ - scrollResponderHandleTouchStart: function (e: PressEvent) { + scrollResponderHandleTouchStart: function(e: PressEvent) { this.state.isTouching = true; this.props.onTouchStart && this.props.onTouchStart(e); }, @@ -425,7 +425,7 @@ const ScrollResponderMixin = { * * @param {PressEvent} e Touch Start event. */ - scrollResponderHandleTouchMove: function (e: PressEvent) { + scrollResponderHandleTouchMove: function(e: PressEvent) { this.props.onTouchMove && this.props.onTouchMove(e); }, @@ -434,7 +434,7 @@ const ScrollResponderMixin = { * view is currently animating. This is particularly useful to know when * a touch has just started or ended. */ - scrollResponderIsAnimating: function (): boolean { + scrollResponderIsAnimating: function(): boolean { const now = performanceNow(); const timeSinceLastMomentumScrollEnd = now - this.state.lastMomentumScrollEndTime; @@ -450,7 +450,7 @@ const ScrollResponderMixin = { * Components can pass what node to use by defining a `getScrollableNode` * function otherwise `this` is used. */ - scrollResponderGetScrollableNode: function (): ?number { + scrollResponderGetScrollableNode: function(): ?number { return this.getScrollableNode ? this.getScrollableNode() : ReactNative.findNodeHandle(this); @@ -467,7 +467,7 @@ const ScrollResponderMixin = { * the function also accepts separate arguments as as alternative to the options object. * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED. */ - scrollResponderScrollTo: function ( + scrollResponderScrollTo: function( x?: | number | { @@ -507,7 +507,7 @@ const ScrollResponderMixin = { * * `scrollResponderScrollToEnd({animated: true})` */ - scrollResponderScrollToEnd: function (options?: {animated?: boolean, ...}) { + scrollResponderScrollToEnd: function(options?: {animated?: boolean, ...}) { // Default to true const animated = (options && options.animated) !== false; @@ -530,7 +530,7 @@ const ScrollResponderMixin = { * * @platform ios */ - scrollResponderZoomTo: function ( + scrollResponderZoomTo: function( rect: {| x: number, y: number, @@ -565,7 +565,7 @@ const ScrollResponderMixin = { /** * Displays the scroll indicators momentarily. */ - scrollResponderFlashScrollIndicators: function () { + scrollResponderFlashScrollIndicators: function() { const that: React.ElementRef = (this: any); invariant( that.getNativeScrollRef != null, @@ -588,7 +588,7 @@ const ScrollResponderMixin = { * @param {bool} preventNegativeScrolling Whether to allow pulling the content * down to make it meet the keyboard's top. Default is false. */ - scrollResponderScrollNativeHandleToKeyboard: function ( + scrollResponderScrollNativeHandleToKeyboard: function( nodeHandle: number | React.ElementRef>, additionalOffset?: number, preventNegativeScrollOffset?: boolean, @@ -628,7 +628,7 @@ const ScrollResponderMixin = { * @param {number} width Width of the text input. * @param {number} height Height of the text input. */ - scrollResponderInputMeasureAndScrollToKeyboard: function ( + scrollResponderInputMeasureAndScrollToKeyboard: function( left: number, top: number, width: number, @@ -654,7 +654,7 @@ const ScrollResponderMixin = { this.preventNegativeScrollOffset = false; }, - scrollResponderTextInputFocusError: function (msg: string) { + scrollResponderTextInputFocusError: function(msg: string) { console.error('Error measuring text field: ', msg); }, @@ -664,7 +664,7 @@ const ScrollResponderMixin = { * * The `keyboardWillShow` is called before input focus. */ - UNSAFE_componentWillMount: function () { + UNSAFE_componentWillMount: function() { const {keyboardShouldPersistTaps} = ((this: any).props: ScrollViewProps); if (typeof keyboardShouldPersistTaps === 'boolean') { console.warn( @@ -698,7 +698,7 @@ const ScrollResponderMixin = { ); }, - componentWillUnmount: function () { + componentWillUnmount: function() { if (this._subscriptionKeyboardWillShow != null) { this._subscriptionKeyboardWillShow.remove(); } @@ -741,17 +741,17 @@ const ScrollResponderMixin = { * relevant to you. (For example, only if you receive these callbacks after * you had explicitly focused a node etc). */ - scrollResponderKeyboardWillShow: function (e: KeyboardEvent) { + scrollResponderKeyboardWillShow: function(e: KeyboardEvent) { this.keyboardWillOpenTo = e; this.props.onKeyboardWillShow && this.props.onKeyboardWillShow(e); }, - scrollResponderKeyboardWillHide: function (e: KeyboardEvent) { + scrollResponderKeyboardWillHide: function(e: KeyboardEvent) { this.keyboardWillOpenTo = null; this.props.onKeyboardWillHide && this.props.onKeyboardWillHide(e); }, - scrollResponderKeyboardDidShow: function (e: KeyboardEvent) { + scrollResponderKeyboardDidShow: function(e: KeyboardEvent) { // TODO(7693961): The event for DidShow is not available on iOS yet. // Use the one from WillShow and do not assign. if (e) { @@ -760,7 +760,7 @@ const ScrollResponderMixin = { this.props.onKeyboardDidShow && this.props.onKeyboardDidShow(e); }, - scrollResponderKeyboardDidHide: function (e: KeyboardEvent) { + scrollResponderKeyboardDidHide: function(e: KeyboardEvent) { this.keyboardWillOpenTo = null; this.props.onKeyboardDidHide && this.props.onKeyboardDidHide(e); }, diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 824ed1c2947..dd4a0994304 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -368,7 +368,7 @@ type VRProps = $ReadOnly<{| type StickyHeaderComponentType = React.AbstractComponent< ScrollViewStickyHeaderProps, - $ReadOnly<{setNextHeaderY: (number) => void, ...}>, + $ReadOnly<{setNextHeaderY: number => void, ...}>, >; export type Props = $ReadOnly<{| @@ -691,8 +691,8 @@ class ScrollView extends React.Component { * instance. */ Object.keys(ScrollResponder.Mixin) - .filter((key) => typeof ScrollResponder.Mixin[key] !== 'function') - .forEach((key) => { + .filter(key => typeof ScrollResponder.Mixin[key] !== 'function') + .forEach(key => { // $FlowFixMe - dynamically adding properties to a class (this: any)[key] = ScrollResponder.Mixin[key]; }); @@ -966,7 +966,7 @@ class ScrollView extends React.Component { _innerViewRef: ?React.ElementRef = null; _setInnerViewRef = setAndForwardRef({ getForwardedRef: () => this.props.innerViewRef, - setLocalRef: (ref) => { + setLocalRef: ref => { this._innerViewRef = ref; }, }); @@ -1004,7 +1004,7 @@ class ScrollView extends React.Component { if (__DEV__ && this.props.style !== undefined) { const style = flattenStyle(this.props.style); const childLayoutProps = ['alignItems', 'justifyContent'].filter( - (prop) => style && style[prop] !== undefined, + prop => style && style[prop] !== undefined, ); invariant( childLayoutProps.length === 0, @@ -1037,13 +1037,11 @@ class ScrollView extends React.Component { return ( this._setStickyHeaderRef(key, ref)} + ref={ref => this._setStickyHeaderRef(key, ref)} nextHeaderLayoutY={this._headerLayoutYs.get( this._getKeyForIndex(nextIndex, childArray), )} - onLayout={(event) => - this._onStickyHeaderLayout(index, event, key) - } + onLayout={event => this._onStickyHeaderLayout(index, event, key)} scrollAnimatedValue={this._scrollAnimatedValue} inverted={this.props.invertStickyHeaders} scrollViewHeight={this.state.layoutHeight}> diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index 20665260706..0bc51bbfaec 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -52,7 +52,7 @@ class ScrollViewStickyHeader extends React.Component { this.setState({nextHeaderLayoutY: y}); } - _onLayout = (event) => { + _onLayout = event => { this.setState({ measured: true, layoutY: event.nativeEvent.layout.y, diff --git a/Libraries/Components/Slider/Slider.js b/Libraries/Components/Slider/Slider.js index 1a5d23f049b..28c7ff5a723 100644 --- a/Libraries/Components/Slider/Slider.js +++ b/Libraries/Components/Slider/Slider.js @@ -198,7 +198,10 @@ const Slider = ( props: Props, forwardedRef?: ?React.Ref, ) => { - const style = StyleSheet.compose(styles.slider, props.style); + const style = StyleSheet.compose( + styles.slider, + props.style, + ); const { disabled = false, diff --git a/Libraries/Components/Sound/SoundManager.js b/Libraries/Components/Sound/SoundManager.js index 790b3d9e0a2..943b4c5c535 100644 --- a/Libraries/Components/Sound/SoundManager.js +++ b/Libraries/Components/Sound/SoundManager.js @@ -12,7 +12,7 @@ import NativeSoundManager from './NativeSoundManager'; const SoundManager = { - playTouchSound: function (): void { + playTouchSound: function(): void { if (NativeSoundManager) { NativeSoundManager.playTouchSound(); } diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index 482149fb7be..81ab87e4d37 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -467,7 +467,9 @@ class StatusBar extends React.Component { const processedColor = processColor(mergedProps.backgroundColor.value); if (processedColor == null) { console.warn( - `\`StatusBar._updatePropsStack\`: Color ${mergedProps.backgroundColor.value} parsed to null or undefined`, + `\`StatusBar._updatePropsStack\`: Color ${ + mergedProps.backgroundColor.value + } parsed to null or undefined`, ); } else { invariant( diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 55808218618..d8addd288d4 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -945,7 +945,7 @@ function InternalTextInput(props: Props): React.Node { const _setNativeRef = setAndForwardRef({ getForwardedRef: () => props.forwardedRef, - setLocalRef: (ref) => { + setLocalRef: ref => { inputRef.current = ref; /* diff --git a/Libraries/Components/TextInput/__tests__/TextInput-test.js b/Libraries/Components/TextInput/__tests__/TextInput-test.js index 1835d4fe018..38a64dccb69 100644 --- a/Libraries/Components/TextInput/__tests__/TextInput-test.js +++ b/Libraries/Components/TextInput/__tests__/TextInput-test.js @@ -41,11 +41,11 @@ describe('TextInput tests', () => { { + onChangeText={text => { onChangeTextListener(text); setState({text}); }} - onChange={(event) => { + onChange={event => { onChangeListener(event); }} /> @@ -86,7 +86,7 @@ describe('TextInput tests', () => { ReactTestRenderer.create(); expect(textInputRef.current.isFocused()).toBe(false); - ReactNative.findNodeHandle = jest.fn().mockImplementation((ref) => { + ReactNative.findNodeHandle = jest.fn().mockImplementation(ref => { if (ref == null) { return null; } @@ -125,7 +125,7 @@ describe('TextInput tests', () => { , ); - ReactNative.findNodeHandle = jest.fn().mockImplementation((ref) => { + ReactNative.findNodeHandle = jest.fn().mockImplementation(ref => { if ( ref === textInputRe1.current || ref === textInputRe1.current.getNativeRef() diff --git a/Libraries/Components/ToastAndroid/ToastAndroid.android.js b/Libraries/Components/ToastAndroid/ToastAndroid.android.js index 8c8df1a551d..6d95ae87795 100644 --- a/Libraries/Components/ToastAndroid/ToastAndroid.android.js +++ b/Libraries/Components/ToastAndroid/ToastAndroid.android.js @@ -41,11 +41,11 @@ const ToastAndroid = { BOTTOM: (NativeToastAndroid.getConstants().BOTTOM: number), CENTER: (NativeToastAndroid.getConstants().CENTER: number), - show: function (message: string, duration: number): void { + show: function(message: string, duration: number): void { NativeToastAndroid.show(message, duration); }, - showWithGravity: function ( + showWithGravity: function( message: string, duration: number, gravity: number, @@ -53,7 +53,7 @@ const ToastAndroid = { NativeToastAndroid.showWithGravity(message, duration, gravity); }, - showWithGravityAndOffset: function ( + showWithGravityAndOffset: function( message: string, duration: number, gravity: number, diff --git a/Libraries/Components/ToastAndroid/ToastAndroid.ios.js b/Libraries/Components/ToastAndroid/ToastAndroid.ios.js index 0bd42d7cfa8..d0528ff65dc 100644 --- a/Libraries/Components/ToastAndroid/ToastAndroid.ios.js +++ b/Libraries/Components/ToastAndroid/ToastAndroid.ios.js @@ -13,11 +13,11 @@ const warning = require('fbjs/lib/warning'); const ToastAndroid = { - show: function (message: string, duration: number): void { + show: function(message: string, duration: number): void { warning(false, 'ToastAndroid is not supported on this platform.'); }, - showWithGravity: function ( + showWithGravity: function( message: string, duration: number, gravity: number, @@ -25,7 +25,7 @@ const ToastAndroid = { warning(false, 'ToastAndroid is not supported on this platform.'); }, - showWithGravityAndOffset: function ( + showWithGravityAndOffset: function( message: string, duration: number, gravity: number, diff --git a/Libraries/Components/Touchable/BoundingDimensions.js b/Libraries/Components/Touchable/BoundingDimensions.js index 6c76a774cc6..b0a48d0eccd 100644 --- a/Libraries/Components/Touchable/BoundingDimensions.js +++ b/Libraries/Components/Touchable/BoundingDimensions.js @@ -25,7 +25,7 @@ function BoundingDimensions(width, height) { this.height = height; } -BoundingDimensions.prototype.destructor = function () { +BoundingDimensions.prototype.destructor = function() { this.width = null; this.height = null; }; @@ -34,7 +34,7 @@ BoundingDimensions.prototype.destructor = function () { * @param {HTMLElement} element Element to return `BoundingDimensions` for. * @return {BoundingDimensions} Bounding dimensions of `element`. */ -BoundingDimensions.getPooledFromElement = function (element) { +BoundingDimensions.getPooledFromElement = function(element) { return BoundingDimensions.getPooled( element.offsetWidth, element.offsetHeight, diff --git a/Libraries/Components/Touchable/PooledClass.js b/Libraries/Components/Touchable/PooledClass.js index c53e0e6e39d..4aee28a81c5 100644 --- a/Libraries/Components/Touchable/PooledClass.js +++ b/Libraries/Components/Touchable/PooledClass.js @@ -19,7 +19,7 @@ const invariant = require('invariant'); * the Class itself, not an instance. If any others are needed, simply add them * here, or in their own files. */ -const oneArgumentPooler = function (copyFieldsFrom) { +const oneArgumentPooler = function(copyFieldsFrom) { const Klass = this; if (Klass.instancePool.length) { const instance = Klass.instancePool.pop(); @@ -30,7 +30,7 @@ const oneArgumentPooler = function (copyFieldsFrom) { } }; -const twoArgumentPooler = function (a1, a2) { +const twoArgumentPooler = function(a1, a2) { const Klass = this; if (Klass.instancePool.length) { const instance = Klass.instancePool.pop(); @@ -41,7 +41,7 @@ const twoArgumentPooler = function (a1, a2) { } }; -const threeArgumentPooler = function (a1, a2, a3) { +const threeArgumentPooler = function(a1, a2, a3) { const Klass = this; if (Klass.instancePool.length) { const instance = Klass.instancePool.pop(); @@ -52,7 +52,7 @@ const threeArgumentPooler = function (a1, a2, a3) { } }; -const fourArgumentPooler = function (a1, a2, a3, a4) { +const fourArgumentPooler = function(a1, a2, a3, a4) { const Klass = this; if (Klass.instancePool.length) { const instance = Klass.instancePool.pop(); @@ -63,7 +63,7 @@ const fourArgumentPooler = function (a1, a2, a3, a4) { } }; -const standardReleaser = function (instance) { +const standardReleaser = function(instance) { const Klass = this; invariant( instance instanceof Klass, @@ -89,7 +89,7 @@ type Pooler = any; * @param {Function} CopyConstructor Constructor that can be used to reset. * @param {Function} pooler Customizable pooler. */ -const addPoolingTo = function ( +const addPoolingTo = function( CopyConstructor: Class, pooler: Pooler, ): Class & { diff --git a/Libraries/Components/Touchable/Position.js b/Libraries/Components/Touchable/Position.js index f786ff245ee..37c9738dd4b 100644 --- a/Libraries/Components/Touchable/Position.js +++ b/Libraries/Components/Touchable/Position.js @@ -26,7 +26,7 @@ function Position(left, top) { this.top = top; } -Position.prototype.destructor = function () { +Position.prototype.destructor = function() { this.left = null; this.top = null; }; diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index b8ed9995d74..a55164413f4 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -27,7 +27,7 @@ const normalizeColor = require('../../StyleSheet/normalizeColor'); import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; import type {PressEvent} from '../../Types/CoreEventTypes'; -const extractSingleTouch = (nativeEvent) => { +const extractSingleTouch = nativeEvent => { const touches = nativeEvent.touches; const changedTouches = nativeEvent.changedTouches; const hasTouches = touches && touches.length > 0; @@ -367,13 +367,13 @@ const LONG_PRESS_ALLOWED_MOVEMENT = 10; * @lends Touchable.prototype */ const TouchableMixin = { - componentDidMount: function () { + componentDidMount: function() { if (!Platform.isTV) { return; } this._tvEventHandler = new TVEventHandler(); - this._tvEventHandler.enable(this, function (cmp, evt) { + this._tvEventHandler.enable(this, function(cmp, evt) { const myTag = ReactNative.findNodeHandle(cmp); evt.dispatchConfig = {}; if (myTag === evt.tag) { @@ -393,7 +393,7 @@ const TouchableMixin = { /** * Clear all timeouts on unmount */ - componentWillUnmount: function () { + componentWillUnmount: function() { if (this._tvEventHandler) { this._tvEventHandler.disable(); delete this._tvEventHandler; @@ -410,7 +410,7 @@ const TouchableMixin = { * @return {object} State object to be placed inside of * `this.state.touchable`. */ - touchableGetInitialState: function (): $TEMPORARY$object<{| + touchableGetInitialState: function(): $TEMPORARY$object<{| touchable: $TEMPORARY$object<{|responderID: null, touchState: void|}>, |}> { return { @@ -422,21 +422,21 @@ const TouchableMixin = { /** * Must return true if embedded in a native platform scroll view. */ - touchableHandleResponderTerminationRequest: function (): any { + touchableHandleResponderTerminationRequest: function(): any { return !this.props.rejectResponderTermination; }, /** * Must return true to start the process of `Touchable`. */ - touchableHandleStartShouldSetResponder: function (): any { + touchableHandleStartShouldSetResponder: function(): any { return !this.props.disabled; }, /** * Return true to cancel press on long press. */ - touchableLongPressCancelsPress: function (): boolean { + touchableLongPressCancelsPress: function(): boolean { return true; }, @@ -445,7 +445,7 @@ const TouchableMixin = { * @param {SyntheticEvent} e Synthetic event from event system. * */ - touchableHandleResponderGrant: function (e: PressEvent) { + touchableHandleResponderGrant: function(e: PressEvent) { const dispatchID = e.currentTarget; // Since e is used in a callback invoked on another event loop // (as in setTimeout etc), we need to call e.persist() on the @@ -486,7 +486,7 @@ const TouchableMixin = { /** * Place as callback for a DOM element's `onResponderRelease` event. */ - touchableHandleResponderRelease: function (e: PressEvent) { + touchableHandleResponderRelease: function(e: PressEvent) { this.pressInLocation = null; this._receiveSignal(Signals.RESPONDER_RELEASE, e); }, @@ -494,7 +494,7 @@ const TouchableMixin = { /** * Place as callback for a DOM element's `onResponderTerminate` event. */ - touchableHandleResponderTerminate: function (e: PressEvent) { + touchableHandleResponderTerminate: function(e: PressEvent) { this.pressInLocation = null; this._receiveSignal(Signals.RESPONDER_TERMINATED, e); }, @@ -502,7 +502,7 @@ const TouchableMixin = { /** * Place as callback for a DOM element's `onResponderMove` event. */ - touchableHandleResponderMove: function (e: PressEvent) { + touchableHandleResponderMove: function(e: PressEvent) { // Measurement may not have returned yet. if (!this.state.touchable.positionOnActivate) { return; @@ -587,7 +587,7 @@ const TouchableMixin = { * element that was blurred just prior to this. This can be overridden when * using `Touchable.Mixin.withoutDefaultFocusAndBlur`. */ - touchableHandleFocus: function (e: Event) { + touchableHandleFocus: function(e: Event) { this.props.onFocus && this.props.onFocus(e); }, @@ -599,7 +599,7 @@ const TouchableMixin = { * This can be overridden when using * `Touchable.Mixin.withoutDefaultFocusAndBlur`. */ - touchableHandleBlur: function (e: Event) { + touchableHandleBlur: function(e: Event) { this.props.onBlur && this.props.onBlur(e); }, @@ -679,7 +679,7 @@ const TouchableMixin = { * @sideeffects * @private */ - _remeasureMetricsOnActivation: function () { + _remeasureMetricsOnActivation: function() { const responderID = this.state.touchable.responderID; if (responderID == null) { return; @@ -692,7 +692,7 @@ const TouchableMixin = { } }, - _handleQueryLayout: function ( + _handleQueryLayout: function( l: number, t: number, w: number, @@ -718,12 +718,12 @@ const TouchableMixin = { ); }, - _handleDelay: function (e: PressEvent) { + _handleDelay: function(e: PressEvent) { this.touchableDelayTimeout = null; this._receiveSignal(Signals.DELAY, e); }, - _handleLongDelay: function (e: PressEvent) { + _handleLongDelay: function(e: PressEvent) { this.longPressDelayTimeout = null; const curState = this.state.touchable.touchState; if ( @@ -742,7 +742,7 @@ const TouchableMixin = { * @throws Error if invalid state transition or unrecognized signal. * @sideeffects */ - _receiveSignal: function (signal: Signal, e: PressEvent) { + _receiveSignal: function(signal: Signal, e: PressEvent) { const responderID = this.state.touchable.responderID; const curState = this.state.touchable.touchState; const nextState = Transitions[curState] && Transitions[curState][signal]; @@ -781,19 +781,19 @@ const TouchableMixin = { } }, - _cancelLongPressDelayTimeout: function () { + _cancelLongPressDelayTimeout: function() { this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout); this.longPressDelayTimeout = null; }, - _isHighlight: function (state: State): boolean { + _isHighlight: function(state: State): boolean { return ( state === States.RESPONDER_ACTIVE_PRESS_IN || state === States.RESPONDER_ACTIVE_LONG_PRESS_IN ); }, - _savePressInLocation: function (e: PressEvent) { + _savePressInLocation: function(e: PressEvent) { const touch = extractSingleTouch(e.nativeEvent); const pageX = touch && touch.pageX; const pageY = touch && touch.pageY; @@ -802,7 +802,7 @@ const TouchableMixin = { this.pressInLocation = {pageX, pageY, locationX, locationY}; }, - _getDistanceBetweenPoints: function ( + _getDistanceBetweenPoints: function( aX: number, aY: number, bX: number, @@ -824,7 +824,7 @@ const TouchableMixin = { * @param {Event} e Native event. * @sideeffects */ - _performSideEffectsForTransition: function ( + _performSideEffectsForTransition: function( curState: State, nextState: State, signal: Signal, @@ -885,12 +885,12 @@ const TouchableMixin = { this.touchableDelayTimeout = null; }, - _startHighlight: function (e: PressEvent) { + _startHighlight: function(e: PressEvent) { this._savePressInLocation(e); this.touchableHandleActivePressIn && this.touchableHandleActivePressIn(e); }, - _endHighlight: function (e: PressEvent) { + _endHighlight: function(e: PressEvent) { if (this.touchableHandleActivePressOut) { if ( this.touchableGetPressOutDelayMS && diff --git a/Libraries/Components/Touchable/TouchableBounce.js b/Libraries/Components/Touchable/TouchableBounce.js index cc859fb2446..c47129dd392 100644 --- a/Libraries/Components/Touchable/TouchableBounce.js +++ b/Libraries/Components/Touchable/TouchableBounce.js @@ -55,7 +55,7 @@ class TouchableBounce extends React.Component { delayPressOut: this.props.delayPressOut, pressRectOffset: this.props.pressRetentionOffset, android_disableSound: this.props.touchSoundDisabled, - onBlur: (event) => { + onBlur: event => { if (Platform.isTV) { this._bounceTo(1, 0.4, 0); } @@ -63,7 +63,7 @@ class TouchableBounce extends React.Component { this.props.onBlur(event); } }, - onFocus: (event) => { + onFocus: event => { if (Platform.isTV) { this._bounceTo(0.93, 0.1, 0); } @@ -71,12 +71,12 @@ class TouchableBounce extends React.Component { this.props.onFocus(event); } }, - onLongPress: (event) => { + onLongPress: event => { if (this.props.onLongPress != null) { this.props.onLongPress(event); } }, - onPress: (event) => { + onPress: event => { const {onPressAnimationComplete, onPressWithCompletion} = this.props; const releaseBounciness = this.props.releaseBounciness ?? 10; const releaseVelocity = this.props.releaseVelocity ?? 10; @@ -104,13 +104,13 @@ class TouchableBounce extends React.Component { this.props.onPress(event); } }, - onPressIn: (event) => { + onPressIn: event => { this._bounceTo(0.93, 0.1, 0); if (this.props.onPressIn != null) { this.props.onPressIn(event); } }, - onPressOut: (event) => { + onPressOut: event => { this._bounceTo(1, 0.4, 0); if (this.props.onPressOut != null) { this.props.onPressOut(event); @@ -179,17 +179,17 @@ class TouchableBounce extends React.Component { if (Platform.isTV) { this._tvTouchable = new TVTouchable(this, { getDisabled: () => this.props.disabled === true, - onBlur: (event) => { + onBlur: event => { if (this.props.onBlur != null) { this.props.onBlur(event); } }, - onFocus: (event) => { + onFocus: event => { if (this.props.onFocus != null) { this.props.onFocus(event); } }, - onPress: (event) => { + onPress: event => { if (this.props.onPress != null) { this.props.onPress(event); } diff --git a/Libraries/Components/Touchable/TouchableHighlight.js b/Libraries/Components/Touchable/TouchableHighlight.js index 9f7d05e58c3..c7db381c792 100644 --- a/Libraries/Components/Touchable/TouchableHighlight.js +++ b/Libraries/Components/Touchable/TouchableHighlight.js @@ -176,7 +176,7 @@ class TouchableHighlight extends React.Component { delayPressOut: this.props.delayPressOut, pressRectOffset: this.props.pressRetentionOffset, android_disableSound: this.props.touchSoundDisabled, - onBlur: (event) => { + onBlur: event => { if (Platform.isTV) { this._hideUnderlay(); } @@ -184,7 +184,7 @@ class TouchableHighlight extends React.Component { this.props.onBlur(event); } }, - onFocus: (event) => { + onFocus: event => { if (Platform.isTV) { this._showUnderlay(); } @@ -192,12 +192,12 @@ class TouchableHighlight extends React.Component { this.props.onFocus(event); } }, - onLongPress: (event) => { + onLongPress: event => { if (this.props.onLongPress != null) { this.props.onLongPress(event); } }, - onPress: (event) => { + onPress: event => { if (this._hideTimeout != null) { clearTimeout(this._hideTimeout); } @@ -211,7 +211,7 @@ class TouchableHighlight extends React.Component { this.props.onPress(event); } }, - onPressIn: (event) => { + onPressIn: event => { if (this._hideTimeout != null) { clearTimeout(this._hideTimeout); this._hideTimeout = null; @@ -221,7 +221,7 @@ class TouchableHighlight extends React.Component { this.props.onPressIn(event); } }, - onPressOut: (event) => { + onPressOut: event => { if (this._hideTimeout == null) { this._hideUnderlay(); } @@ -341,17 +341,17 @@ class TouchableHighlight extends React.Component { if (Platform.isTV) { this._tvTouchable = new TVTouchable(this, { getDisabled: () => this.props.disabled === true, - onBlur: (event) => { + onBlur: event => { if (this.props.onBlur != null) { this.props.onBlur(event); } }, - onFocus: (event) => { + onFocus: event => { if (this.props.onFocus != null) { this.props.onFocus(event); } }, - onPress: (event) => { + onPress: event => { if (this.props.onPress != null) { this.props.onPress(event); } diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.js b/Libraries/Components/Touchable/TouchableNativeFeedback.js index 39cfcefe6e9..ed03379c54d 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.js @@ -182,7 +182,7 @@ class TouchableNativeFeedback extends React.Component { android_disableSound: this.props.touchSoundDisabled, onLongPress: this.props.onLongPress, onPress: this.props.onPress, - onPressIn: (event) => { + onPressIn: event => { if (Platform.OS === 'android') { this._dispatchPressedStateChange(true); this._dispatchHotspotUpdate(event); @@ -191,12 +191,12 @@ class TouchableNativeFeedback extends React.Component { this.props.onPressIn(event); } }, - onPressMove: (event) => { + onPressMove: event => { if (Platform.OS === 'android') { this._dispatchHotspotUpdate(event); } }, - onPressOut: (event) => { + onPressOut: event => { if (Platform.OS === 'android') { this._dispatchPressedStateChange(false); } @@ -303,17 +303,17 @@ class TouchableNativeFeedback extends React.Component { if (Platform.isTV) { this._tvTouchable = new TVTouchable(this, { getDisabled: () => this.props.disabled === true, - onBlur: (event) => { + onBlur: event => { if (this.props.onBlur != null) { this.props.onBlur(event); } }, - onFocus: (event) => { + onFocus: event => { if (this.props.onFocus != null) { this.props.onFocus(event); } }, - onPress: (event) => { + onPress: event => { if (this.props.onPress != null) { this.props.onPress(event); } diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index 2b58b5a98d6..aa5239fddaf 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -148,7 +148,7 @@ class TouchableOpacity extends React.Component { delayPressIn: this.props.delayPressIn, delayPressOut: this.props.delayPressOut, pressRectOffset: this.props.pressRetentionOffset, - onBlur: (event) => { + onBlur: event => { if (Platform.isTV) { this._opacityInactive(250); } @@ -156,7 +156,7 @@ class TouchableOpacity extends React.Component { this.props.onBlur(event); } }, - onFocus: (event) => { + onFocus: event => { if (Platform.isTV) { this._opacityActive(150); } @@ -166,7 +166,7 @@ class TouchableOpacity extends React.Component { }, onLongPress: this.props.onLongPress, onPress: this.props.onPress, - onPressIn: (event) => { + onPressIn: event => { this._opacityActive( event.dispatchConfig.registrationName === 'onResponderGrant' ? 0 @@ -176,7 +176,7 @@ class TouchableOpacity extends React.Component { this.props.onPressIn(event); } }, - onPressOut: (event) => { + onPressOut: event => { this._opacityInactive(250); if (this.props.onPressOut != null) { this.props.onPressOut(event); @@ -261,17 +261,17 @@ class TouchableOpacity extends React.Component { if (Platform.isTV) { this._tvTouchable = new TVTouchable(this, { getDisabled: () => this.props.disabled === true, - onBlur: (event) => { + onBlur: event => { if (this.props.onBlur != null) { this.props.onBlur(event); } }, - onFocus: (event) => { + onFocus: event => { if (this.props.onFocus != null) { this.props.onFocus(event); } }, - onPress: (event) => { + onPress: event => { if (this.props.onPress != null) { this.props.onPress(event); } diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index c81b45b56b5..5ad8aa62e5f 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -138,17 +138,17 @@ class TouchableWithoutFeedback extends React.Component { if (Platform.isTV) { this._tvTouchable = new TVTouchable(this, { getDisabled: () => this.props.disabled === true, - onBlur: (event) => { + onBlur: event => { if (this.props.onBlur != null) { this.props.onBlur(event); } }, - onFocus: (event) => { + onFocus: event => { if (this.props.onFocus != null) { this.props.onFocus(event); } }, - onPress: (event) => { + onPress: event => { if (this.props.onPress != null) { this.props.onPress(event); } diff --git a/Libraries/Components/Touchable/ensurePositiveDelayProps.js b/Libraries/Components/Touchable/ensurePositiveDelayProps.js index e0be1ba06ca..69dad5539fa 100644 --- a/Libraries/Components/Touchable/ensurePositiveDelayProps.js +++ b/Libraries/Components/Touchable/ensurePositiveDelayProps.js @@ -12,7 +12,7 @@ const invariant = require('invariant'); -const ensurePositiveDelayProps = function (props: any) { +const ensurePositiveDelayProps = function(props: any) { invariant( !( props.delayPressIn < 0 || diff --git a/Libraries/Core/Devtools/__tests__/parseErrorStack-test.js b/Libraries/Core/Devtools/__tests__/parseErrorStack-test.js index 8bef703ba4a..c361f7a9edc 100644 --- a/Libraries/Core/Devtools/__tests__/parseErrorStack-test.js +++ b/Libraries/Core/Devtools/__tests__/parseErrorStack-test.js @@ -16,8 +16,8 @@ function getFakeError() { return new Error('Happy Cat'); } -describe('parseErrorStack', function () { - it('parses error stack', function () { +describe('parseErrorStack', function() { + it('parses error stack', function() { const stack = parseErrorStack(getFakeError()); expect(stack.length).toBeGreaterThan(0); @@ -26,7 +26,7 @@ describe('parseErrorStack', function () { expect(firstFrame.file).toMatch(/parseErrorStack-test\.js$/); }); - it('does not support framesToPop', function () { + it('does not support framesToPop', function() { function getWrappedError() { const error = getFakeError(); error.framesToPop = 1; @@ -37,7 +37,7 @@ describe('parseErrorStack', function () { expect(stack[0].methodName).toEqual('getFakeError'); }); - it('ignores bad inputs', function () { + it('ignores bad inputs', function() { expect(parseErrorStack({})).toEqual([]); expect(parseErrorStack(null)).toEqual([]); }); diff --git a/Libraries/Core/Devtools/parseErrorStack.js b/Libraries/Core/Devtools/parseErrorStack.js index 1da501776fb..ec69f3f69cf 100644 --- a/Libraries/Core/Devtools/parseErrorStack.js +++ b/Libraries/Core/Devtools/parseErrorStack.js @@ -57,7 +57,7 @@ function parseErrorStack(e: ExtendedError): Array { ? e.stack : global.HermesInternal ? convertHermesStack(parseHermesStack(e.stack)) - : stacktraceParser.parse(e.stack).map((frame) => ({ + : stacktraceParser.parse(e.stack).map(frame => ({ ...frame, column: frame.column != null ? frame.column - 1 : null, })); diff --git a/Libraries/Core/ExceptionsManager.js b/Libraries/Core/ExceptionsManager.js index c227d7f582f..fd6ce28ad6e 100644 --- a/Libraries/Core/ExceptionsManager.js +++ b/Libraries/Core/ExceptionsManager.js @@ -18,7 +18,7 @@ class SyntheticError extends Error { name: string = ''; } -type ExceptionDecorator = (ExceptionData) => ExceptionData; +type ExceptionDecorator = ExceptionData => ExceptionData; let userExceptionDecorator: ?ExceptionDecorator; let inUserExceptionDecorator = false; @@ -130,7 +130,7 @@ function reportException( throw new Error('The stack is null'); } }) - .catch((error) => { + .catch(error => { console.log('Unable to symbolicate stack trace: ' + error.message); }); } @@ -222,7 +222,7 @@ function reactConsoleErrorHandler() { } else { const stringifySafe = require('../Utilities/stringifySafe').default; const str = Array.prototype.map - .call(arguments, (value) => + .call(arguments, value => typeof value === 'string' ? value : stringifySafe(value), ) .join(' '); diff --git a/Libraries/Core/Timers/JSTimers.js b/Libraries/Core/Timers/JSTimers.js index 8b0b5b12182..4c154db519d 100644 --- a/Libraries/Core/Timers/JSTimers.js +++ b/Libraries/Core/Timers/JSTimers.js @@ -132,7 +132,7 @@ function _callTimer(timerID: number, frameTime: number, didTimeout: ?boolean) { callback(performanceNow()); } else if (type === 'requestIdleCallback') { callback({ - timeRemaining: function () { + timeRemaining: function() { // TODO: Optimisation: allow running for longer than one frame if // there are no pending JS calls on the bridge from native. This // would require a way to check the bridge queue synchronously. @@ -221,11 +221,7 @@ const JSTimers = { * @param {function} func Callback to be invoked after `duration` ms. * @param {number} duration Number of milliseconds. */ - setTimeout: function ( - func: Function, - duration: number, - ...args: any - ): number { + setTimeout: function(func: Function, duration: number, ...args: any): number { if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) { console.warn( ANDROID_LONG_TIMER_MESSAGE + @@ -247,7 +243,7 @@ const JSTimers = { * @param {function} func Callback to be invoked every `duration` ms. * @param {number} duration Number of milliseconds. */ - setInterval: function ( + setInterval: function( func: Function, duration: number, ...args: any @@ -273,7 +269,7 @@ const JSTimers = { * @param {function} func Callback to be invoked before the end of the * current JavaScript execution loop. */ - setImmediate: function (func: Function, ...args: any) { + setImmediate: function(func: Function, ...args: any) { const id = _allocateCallback( () => func.apply(undefined, args), 'setImmediate', @@ -285,7 +281,7 @@ const JSTimers = { /** * @param {function} func Callback to be invoked every frame. */ - requestAnimationFrame: function (func: Function) { + requestAnimationFrame: function(func: Function) { const id = _allocateCallback(func, 'requestAnimationFrame'); createTimer(id, 1, Date.now(), /* recurring */ false); return id; @@ -296,7 +292,7 @@ const JSTimers = { * with time remaining in frame. * @param {?object} options */ - requestIdleCallback: function (func: Function, options: ?Object) { + requestIdleCallback: function(func: Function, options: ?Object) { if (requestIdleCallbacks.length === 0) { setSendIdleEvents(true); } @@ -304,7 +300,7 @@ const JSTimers = { const timeout = options && options.timeout; const id = _allocateCallback( timeout != null - ? (deadline) => { + ? deadline => { const timeoutId = requestIdleCallbackTimeouts[id]; if (timeoutId) { JSTimers.clearTimeout(timeoutId); @@ -334,7 +330,7 @@ const JSTimers = { return id; }, - cancelIdleCallback: function (timerID: number) { + cancelIdleCallback: function(timerID: number) { _freeCallback(timerID); const index = requestIdleCallbacks.indexOf(timerID); if (index !== -1) { @@ -352,15 +348,15 @@ const JSTimers = { } }, - clearTimeout: function (timerID: number) { + clearTimeout: function(timerID: number) { _freeCallback(timerID); }, - clearInterval: function (timerID: number) { + clearInterval: function(timerID: number) { _freeCallback(timerID); }, - clearImmediate: function (timerID: number) { + clearImmediate: function(timerID: number) { _freeCallback(timerID); const index = immediates.indexOf(timerID); if (index !== -1) { @@ -368,7 +364,7 @@ const JSTimers = { } }, - cancelAnimationFrame: function (timerID: number) { + cancelAnimationFrame: function(timerID: number) { _freeCallback(timerID); }, @@ -376,7 +372,7 @@ const JSTimers = { * This is called from the native side. We are passed an array of timerIDs, * and */ - callTimers: function (timersToCall: Array) { + callTimers: function(timersToCall: Array) { invariant( timersToCall.length !== 0, 'Cannot call `callTimers` with an empty list of IDs.', @@ -394,7 +390,7 @@ const JSTimers = { // error one at a time for (let ii = 1; ii < errorCount; ii++) { JSTimers.setTimeout( - ((error) => { + (error => { throw error; }).bind(null, errors[ii]), 0, @@ -405,7 +401,7 @@ const JSTimers = { } }, - callIdleCallbacks: function (frameTime: number) { + callIdleCallbacks: function(frameTime: number) { if ( FRAME_DURATION - (performanceNow() - frameTime) < IDLE_CALLBACK_FRAME_DEADLINE @@ -428,7 +424,7 @@ const JSTimers = { } if (errors) { - errors.forEach((error) => + errors.forEach(error => JSTimers.setTimeout(() => { throw error; }, 0), @@ -444,7 +440,7 @@ const JSTimers = { errors = (null: ?Array); while (_callImmediatesPass()) {} if (errors) { - errors.forEach((error) => + errors.forEach(error => JSTimers.setTimeout(() => { throw error; }, 0), diff --git a/Libraries/Core/Timers/__tests__/JSTimers-test.js b/Libraries/Core/Timers/__tests__/JSTimers-test.js index 155a392089f..baa281f03e6 100644 --- a/Libraries/Core/Timers/__tests__/JSTimers-test.js +++ b/Libraries/Core/Timers/__tests__/JSTimers-test.js @@ -29,33 +29,33 @@ jest const JSTimers = require('../JSTimers'); -describe('JSTimers', function () { - const firstArgumentOfTheLastCallTo = function (func) { +describe('JSTimers', function() { + const firstArgumentOfTheLastCallTo = function(func) { return func.mock.calls[func.mock.calls.length - 1][0]; }; - beforeEach(function () { + beforeEach(function() { global.setTimeout = JSTimers.setTimeout; }); - it('should call function with setTimeout', function () { + it('should call function with setTimeout', function() { let didCall = false; - const id = JSTimers.setTimeout(function () { + const id = JSTimers.setTimeout(function() { didCall = true; }); JSTimers.callTimers([id]); expect(didCall).toBe(true); }); - it('should call nested setTimeout when cleared', function () { + it('should call nested setTimeout when cleared', function() { let id1, id2, id3; let callCount = 0; - id1 = JSTimers.setTimeout(function () { + id1 = JSTimers.setTimeout(function() { JSTimers.clearTimeout(id1); - id2 = JSTimers.setTimeout(function () { + id2 = JSTimers.setTimeout(function() { JSTimers.clearTimeout(id2); - id3 = JSTimers.setTimeout(function () { + id3 = JSTimers.setTimeout(function() { callCount += 1; }); }); @@ -67,15 +67,15 @@ describe('JSTimers', function () { expect(callCount).toBe(1); }); - it('should call nested setImmediate when cleared', function () { + it('should call nested setImmediate when cleared', function() { let id1, id2, id3; let callCount = 0; - id1 = JSTimers.setImmediate(function () { + id1 = JSTimers.setImmediate(function() { JSTimers.clearImmediate(id1); - id2 = JSTimers.setImmediate(function () { + id2 = JSTimers.setImmediate(function() { JSTimers.clearImmediate(id2); - id3 = JSTimers.setImmediate(function () { + id3 = JSTimers.setImmediate(function() { callCount += 1; }); }); @@ -87,15 +87,15 @@ describe('JSTimers', function () { expect(callCount).toBe(1); }); - it('should call nested requestAnimationFrame when cleared', function () { + it('should call nested requestAnimationFrame when cleared', function() { let id1, id2, id3; let callCount = 0; - id1 = JSTimers.requestAnimationFrame(function () { + id1 = JSTimers.requestAnimationFrame(function() { JSTimers.cancelAnimationFrame(id1); - id2 = JSTimers.requestAnimationFrame(function () { + id2 = JSTimers.requestAnimationFrame(function() { JSTimers.cancelAnimationFrame(id2); - id3 = JSTimers.requestAnimationFrame(function () { + id3 = JSTimers.requestAnimationFrame(function() { callCount += 1; }); }); @@ -107,15 +107,15 @@ describe('JSTimers', function () { expect(callCount).toBe(1); }); - it('should call nested setInterval when cleared', function () { + it('should call nested setInterval when cleared', function() { let id1, id2, id3; let callCount = 0; - id1 = JSTimers.setInterval(function () { + id1 = JSTimers.setInterval(function() { JSTimers.clearInterval(id1); - id2 = JSTimers.setInterval(function () { + id2 = JSTimers.setInterval(function() { JSTimers.clearInterval(id2); - id3 = JSTimers.setInterval(function () { + id3 = JSTimers.setInterval(function() { callCount += 1; }); }); @@ -127,21 +127,21 @@ describe('JSTimers', function () { expect(callCount).toBe(1); }); - it('should call function with setInterval', function () { + it('should call function with setInterval', function() { const callback = jest.fn(); const id = JSTimers.setInterval(callback); JSTimers.callTimers([id]); expect(callback).toBeCalledTimes(1); }); - it('should call function with setImmediate', function () { + it('should call function with setImmediate', function() { const callback = jest.fn(); JSTimers.setImmediate(callback); JSTimers.callImmediates(); expect(callback).toBeCalledTimes(1); }); - it('should not call function with clearImmediate', function () { + it('should not call function with clearImmediate', function() { const callback = jest.fn(); const id = JSTimers.setImmediate(callback); JSTimers.clearImmediate(id); @@ -149,14 +149,14 @@ describe('JSTimers', function () { expect(callback).not.toBeCalled(); }); - it('should call functions in the right order with setImmediate', function () { + it('should call functions in the right order with setImmediate', function() { let count = 0; let firstCalled = null; let secondCalled = null; - JSTimers.setImmediate(function () { + JSTimers.setImmediate(function() { firstCalled = count++; }); - JSTimers.setImmediate(function () { + JSTimers.setImmediate(function() { secondCalled = count++; }); JSTimers.callImmediates(); @@ -164,14 +164,14 @@ describe('JSTimers', function () { expect(secondCalled).toBe(1); }); - it('should call functions in the right order with nested setImmediate', function () { + it('should call functions in the right order with nested setImmediate', function() { let count = 0; let firstCalled = null; let secondCalled = null; let thirdCalled = null; - JSTimers.setImmediate(function () { + JSTimers.setImmediate(function() { firstCalled = count++; - JSTimers.setImmediate(function () { + JSTimers.setImmediate(function() { thirdCalled = count++; }); secondCalled = count++; @@ -182,12 +182,12 @@ describe('JSTimers', function () { expect(thirdCalled).toBe(2); }); - it('should call nested setImmediate', function () { + it('should call nested setImmediate', function() { let firstCalled = false; let secondCalled = false; - JSTimers.setImmediate(function () { + JSTimers.setImmediate(function() { firstCalled = true; - JSTimers.setImmediate(function () { + JSTimers.setImmediate(function() { secondCalled = true; }); }); @@ -196,14 +196,14 @@ describe('JSTimers', function () { expect(secondCalled).toBe(true); }); - it('should call function with requestAnimationFrame', function () { + it('should call function with requestAnimationFrame', function() { const callback = jest.fn(); const id = JSTimers.requestAnimationFrame(callback); JSTimers.callTimers([id]); expect(callback).toBeCalledTimes(1); }); - it("should not call function if we don't callTimers", function () { + it("should not call function if we don't callTimers", function() { const callback = jest.fn(); JSTimers.setTimeout(callback, 10); expect(callback).not.toBeCalled(); @@ -213,7 +213,7 @@ describe('JSTimers', function () { expect(callback).not.toBeCalled(); }); - it('should call setInterval as many times as callTimers is called', function () { + it('should call setInterval as many times as callTimers is called', function() { const callback = jest.fn(); const id = JSTimers.setInterval(callback, 10); JSTimers.callTimers([id]); @@ -223,13 +223,13 @@ describe('JSTimers', function () { expect(callback).toBeCalledTimes(4); }); - it("should only call the function who's id we pass in", function () { + it("should only call the function who's id we pass in", function() { let firstCalled = false; let secondCalled = false; - JSTimers.setTimeout(function () { + JSTimers.setTimeout(function() { firstCalled = true; }); - const secondID = JSTimers.setTimeout(function () { + const secondID = JSTimers.setTimeout(function() { secondCalled = true; }); JSTimers.callTimers([secondID]); @@ -237,13 +237,13 @@ describe('JSTimers', function () { expect(secondCalled).toBe(true); }); - it('should work with calling multiple timers', function () { + it('should work with calling multiple timers', function() { let firstCalled = false; let secondCalled = false; - const firstID = JSTimers.setTimeout(function () { + const firstID = JSTimers.setTimeout(function() { firstCalled = true; }); - const secondID = JSTimers.setTimeout(function () { + const secondID = JSTimers.setTimeout(function() { secondCalled = true; }); JSTimers.callTimers([firstID, secondID]); @@ -251,27 +251,27 @@ describe('JSTimers', function () { expect(secondCalled).toBe(true); }); - it('should still execute all callbacks even if one throws', function () { - const firstID = JSTimers.setTimeout(function () { + it('should still execute all callbacks even if one throws', function() { + const firstID = JSTimers.setTimeout(function() { throw new Error('error'); }, 10); let secondCalled = false; - const secondID = JSTimers.setTimeout(function () { + const secondID = JSTimers.setTimeout(function() { secondCalled = true; }, 10); expect(JSTimers.callTimers.bind(null, [firstID, secondID])).toThrow(); expect(secondCalled).toBe(true); }); - it('should clear timers even if callback throws', function () { - const timerID = JSTimers.setTimeout(function () { + it('should clear timers even if callback throws', function() { + const timerID = JSTimers.setTimeout(function() { throw new Error('error'); }, 10); expect(JSTimers.callTimers.bind(null, [timerID])).toThrow('error'); JSTimers.callTimers.bind(null, [timerID]); }); - it('should not warn if callback is called on cancelled timer', function () { + it('should not warn if callback is called on cancelled timer', function() { const callback = jest.fn(); const timerID = JSTimers.setTimeout(callback, 10); JSTimers.clearTimeout(timerID); @@ -280,12 +280,12 @@ describe('JSTimers', function () { expect(firstArgumentOfTheLastCallTo(warning)).toBe(true); }); - it('should warn when callTimers is called with garbage timer id', function () { + it('should warn when callTimers is called with garbage timer id', function() { JSTimers.callTimers([1337]); expect(firstArgumentOfTheLastCallTo(warning)).toBe(false); }); - it('should only call callback once for setTimeout', function () { + it('should only call callback once for setTimeout', function() { const callback = jest.fn(); const timerID = JSTimers.setTimeout(callback, 10); // First time the timer fires, should call callback @@ -297,7 +297,7 @@ describe('JSTimers', function () { expect(firstArgumentOfTheLastCallTo(warning)).toBe(true); }); - it('should only call callback once for requestAnimationFrame', function () { + it('should only call callback once for requestAnimationFrame', function() { const callback = jest.fn(); const timerID = JSTimers.requestAnimationFrame(callback, 10); // First time the timer fires, should call callback @@ -309,11 +309,11 @@ describe('JSTimers', function () { expect(firstArgumentOfTheLastCallTo(warning)).toBe(true); }); - it('should re-throw first exception', function () { - const timerID1 = JSTimers.setTimeout(function () { + it('should re-throw first exception', function() { + const timerID1 = JSTimers.setTimeout(function() { throw new Error('first error'); }); - const timerID2 = JSTimers.setTimeout(function () { + const timerID2 = JSTimers.setTimeout(function() { throw new Error('second error'); }); expect(JSTimers.callTimers.bind(null, [timerID1, timerID2])).toThrowError( @@ -321,8 +321,8 @@ describe('JSTimers', function () { ); }); - it('should pass along errors thrown from setImmediate', function () { - JSTimers.setImmediate(function () { + it('should pass along errors thrown from setImmediate', function() { + JSTimers.setImmediate(function() { throw new Error('error within setImmediate'); }); @@ -338,12 +338,12 @@ describe('JSTimers', function () { ); }); - it('should throw all errors from setImmediate', function () { - JSTimers.setImmediate(function () { + it('should throw all errors from setImmediate', function() { + JSTimers.setImmediate(function() { throw new Error('first error'); }); - JSTimers.setImmediate(function () { + JSTimers.setImmediate(function() { throw new Error('second error'); }); @@ -363,8 +363,8 @@ describe('JSTimers', function () { ); }); - it('should pass along errors thrown from setTimeout', function () { - const timerID = JSTimers.setTimeout(function () { + it('should pass along errors thrown from setTimeout', function() { + const timerID = JSTimers.setTimeout(function() { throw new Error('error within setTimeout'); }); @@ -373,11 +373,11 @@ describe('JSTimers', function () { ); }); - it('should throw all errors from setTimeout', function () { - const firstTimerID = JSTimers.setTimeout(function () { + it('should throw all errors from setTimeout', function() { + const firstTimerID = JSTimers.setTimeout(function() { throw new Error('first error'); }); - const secondTimerID = JSTimers.setTimeout(function () { + const secondTimerID = JSTimers.setTimeout(function() { throw new Error('second error'); }); @@ -393,8 +393,8 @@ describe('JSTimers', function () { ); }); - it('should pass along errors thrown from setInterval', function () { - const timerID = JSTimers.setInterval(function () { + it('should pass along errors thrown from setInterval', function() { + const timerID = JSTimers.setInterval(function() { throw new Error('error within setInterval'); }); expect(JSTimers.callTimers.bind(null, [timerID])).toThrowError( @@ -402,7 +402,7 @@ describe('JSTimers', function () { ); }); - it('should not call to native when clearing a null timer', function () { + it('should not call to native when clearing a null timer', function() { const timerID = JSTimers.setTimeout(() => {}); JSTimers.clearTimeout(timerID); NativeTiming.deleteTimer = jest.fn(); diff --git a/Libraries/Core/__mocks__/ErrorUtils.js b/Libraries/Core/__mocks__/ErrorUtils.js index a1808e1b8c3..8505e23dc56 100644 --- a/Libraries/Core/__mocks__/ErrorUtils.js +++ b/Libraries/Core/__mocks__/ErrorUtils.js @@ -24,7 +24,7 @@ function reportError(error) { const ErrorUtils = { apply: jest.fn(execute), applyWithGuard: jest.fn(execute), - guard: jest.fn((callback) => callback), + guard: jest.fn(callback => callback), inGuard: jest.fn().mockReturnValue(true), reportError: jest.fn(reportError), setGlobalHandler: jest.fn(), diff --git a/Libraries/Core/__tests__/ExceptionsManager-test.js b/Libraries/Core/__tests__/ExceptionsManager-test.js index 0ccaa4516a0..71e3be3cb94 100644 --- a/Libraries/Core/__tests__/ExceptionsManager-test.js +++ b/Libraries/Core/__tests__/ExceptionsManager-test.js @@ -482,7 +482,7 @@ describe('ExceptionsManager', () => { test('modifying the exception data', () => { const error = new Error('Some error happened'); - const decorator = jest.fn().mockImplementation((data) => ({ + const decorator = jest.fn().mockImplementation(data => ({ ...data, message: 'decorated: ' + data.message, })); @@ -515,7 +515,7 @@ describe('ExceptionsManager', () => { test('clearing a decorator', () => { const error = new Error('Some error happened'); - const decorator = jest.fn().mockImplementation((data) => ({ + const decorator = jest.fn().mockImplementation(data => ({ ...data, message: 'decorated: ' + data.message, })); @@ -530,7 +530,7 @@ describe('ExceptionsManager', () => { test('prevents decorator recursion from error handler', () => { const error = new Error('Some error happened'); - const decorator = jest.fn().mockImplementation((data) => { + const decorator = jest.fn().mockImplementation(data => { console.error('Logging an error within the decorator'); return { ...data, @@ -556,7 +556,7 @@ describe('ExceptionsManager', () => { test('prevents decorator recursion from console.error', () => { const error = new Error('Some error happened'); - const decorator = jest.fn().mockImplementation((data) => { + const decorator = jest.fn().mockImplementation(data => { console.error('Logging an error within the decorator'); return { ...data, @@ -586,7 +586,7 @@ describe('ExceptionsManager', () => { test('can handle throwing decorators recursion when exception is thrown', () => { const error = new Error('Some error happened'); - const decorator = jest.fn().mockImplementation((data) => { + const decorator = jest.fn().mockImplementation(data => { throw new Error('Throwing an error within the decorator'); }); @@ -604,7 +604,7 @@ describe('ExceptionsManager', () => { test('can handle throwing decorators recursion when exception is logged', () => { const error = new Error('Some error happened'); - const decorator = jest.fn().mockImplementation((data) => { + const decorator = jest.fn().mockImplementation(data => { throw new Error('Throwing an error within the decorator'); }); diff --git a/Libraries/Core/__tests__/ReactNativeVersionCheck-test.js b/Libraries/Core/__tests__/ReactNativeVersionCheck-test.js index f6107a6686b..dbb5920a7a2 100644 --- a/Libraries/Core/__tests__/ReactNativeVersionCheck-test.js +++ b/Libraries/Core/__tests__/ReactNativeVersionCheck-test.js @@ -45,7 +45,7 @@ function _defineCheckVersionTests() { beforeEach(() => { consoleOutput = ''; console.error = jest.fn(); - global.console = {error: jest.fn((error) => (consoleOutput += error))}; + global.console = {error: jest.fn(error => (consoleOutput += error))}; spyOnConsoleError = jest.spyOn(global.console, 'error'); }); diff --git a/Libraries/Core/setUpAlert.js b/Libraries/Core/setUpAlert.js index 7d37fef72bb..f4615ba8c2a 100644 --- a/Libraries/Core/setUpAlert.js +++ b/Libraries/Core/setUpAlert.js @@ -15,7 +15,7 @@ * You can use this module directly, or just require InitializeCore. */ if (!global.alert) { - global.alert = function (text) { + global.alert = function(text) { // Require Alert on demand. Requiring it too early can lead to issues // with things like Platform not being fully initialized. require('../Alert/Alert').alert('Alert', '' + text); diff --git a/Libraries/Core/setUpDeveloperTools.js b/Libraries/Core/setUpDeveloperTools.js index fca4aae1693..3ee84d87273 100644 --- a/Libraries/Core/setUpDeveloperTools.js +++ b/Libraries/Core/setUpDeveloperTools.js @@ -60,9 +60,9 @@ if (__DEV__) { 'groupCollapsed', 'groupEnd', 'debug', - ].forEach((level) => { + ].forEach(level => { const originalFunction = console[level]; - console[level] = function (...args) { + console[level] = function(...args) { HMRClient.log(level, args); originalFunction.apply(console, args); }; diff --git a/Libraries/Core/setUpTimers.js b/Libraries/Core/setUpTimers.js index bba4c31b366..89df16cc80c 100644 --- a/Libraries/Core/setUpTimers.js +++ b/Libraries/Core/setUpTimers.js @@ -18,7 +18,7 @@ if (!global.RN$Bridgeless) { * Set up timers. * You can use this module directly, or just require InitializeCore. */ - const defineLazyTimer = (name) => { + const defineLazyTimer = name => { polyfillGlobal(name, () => require('./Timers/JSTimers')[name]); }; defineLazyTimer('setTimeout'); diff --git a/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js b/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js index 7265fa60aee..caa6858a200 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js @@ -11,7 +11,7 @@ const normalizeColor = require('../StyleSheet/normalizeColor'); -const colorPropType = function ( +const colorPropType = function( isRequired, props, propName, diff --git a/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js b/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js index 0dd3454b5af..f692187a678 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js @@ -18,7 +18,7 @@ function DeprecatedStyleSheetPropType(shape: { ..., }): ReactPropsCheckType { const shapePropType = deprecatedCreateStrictShapeTypeChecker(shape); - return function (props, propName, componentName, location?, ...rest) { + return function(props, propName, componentName, location?, ...rest) { let newProps = props; if (props[propName]) { // Just make a dummy prop object with only the flattened style diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js index 48c918a415f..daba0d83676 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js @@ -14,7 +14,7 @@ const ReactPropTypes = require('prop-types'); const deprecatedPropType = require('../Utilities/deprecatedPropType'); -const TransformMatrixPropType = function ( +const TransformMatrixPropType = function( props: Object, propName: string, componentName: string, @@ -27,7 +27,7 @@ const TransformMatrixPropType = function ( } }; -const DecomposedMatrixPropType = function ( +const DecomposedMatrixPropType = function( props: Object, propName: string, componentName: string, diff --git a/Libraries/HeapCapture/HeapCapture.js b/Libraries/HeapCapture/HeapCapture.js index ed4ac7f1958..903343a05b0 100644 --- a/Libraries/HeapCapture/HeapCapture.js +++ b/Libraries/HeapCapture/HeapCapture.js @@ -13,7 +13,7 @@ import NativeJSCHeapCapture from './NativeJSCHeapCapture'; const HeapCapture = { - captureHeap: function (path: string) { + captureHeap: function(path: string) { let error = null; try { global.nativeCaptureHeap(path); diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index 6802dd08726..a445ebcebc5 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -154,12 +154,12 @@ function getSize( failure?: (error: any) => void, ): any { return NativeImageLoaderAndroid.getSize(url) - .then(function (sizes) { + .then(function(sizes) { success(sizes.width, sizes.height); }) .catch( failure || - function () { + function() { console.warn('Failed to get size for image: ' + url); }, ); @@ -178,12 +178,12 @@ function getSizeWithHeaders( failure?: (error: any) => void, ): any { return NativeImageLoaderAndroid.getSizeWithHeaders(url, headers) - .then(function (sizes) { + .then(function(sizes) { success(sizes.width, sizes.height); }) .catch( failure || - function () { + function() { console.warn('Failed to get size for image: ' + url); }, ); @@ -289,7 +289,7 @@ let Image = (props: ImagePropsType, forwardedRef) => { return ( - {(hasTextAncestor) => + {hasTextAncestor => hasTextAncestor ? ( ) : ( diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index 22593198265..22b28309076 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -34,7 +34,7 @@ function getSize( .then(([width, height]) => success(width, height)) .catch( failure || - function () { + function() { console.warn('Failed to get size for image ' + uri); }, ); @@ -47,12 +47,12 @@ function getSizeWithHeaders( failure?: (error: any) => void, ): any { return NativeImageLoaderIOS.getSizeWithHeaders(uri, headers) - .then(function (sizes) { + .then(function(sizes) { success(sizes.width, sizes.height); }) .catch( failure || - function () { + function() { console.warn('Failed to get size for image: ' + uri); }, ); diff --git a/Libraries/Image/ImageBackground.js b/Libraries/Image/ImageBackground.js index 68b85c6cb8d..b4b6223b846 100644 --- a/Libraries/Image/ImageBackground.js +++ b/Libraries/Image/ImageBackground.js @@ -50,7 +50,7 @@ class ImageBackground extends React.Component<$FlowFixMeProps> { _viewRef: ?React.ElementRef = null; - _captureRef = (ref) => { + _captureRef = ref => { this._viewRef = ref; }; diff --git a/Libraries/Image/ImagePickerIOS.js b/Libraries/Image/ImagePickerIOS.js index da9cb014274..a9127deaabf 100644 --- a/Libraries/Image/ImagePickerIOS.js +++ b/Libraries/Image/ImagePickerIOS.js @@ -14,15 +14,15 @@ import NativeImagePickerIOS from './NativeImagePickerIOS'; import invariant from 'invariant'; const ImagePickerIOS = { - canRecordVideos: function (callback: (result: boolean) => void): void { + canRecordVideos: function(callback: (result: boolean) => void): void { invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); return NativeImagePickerIOS.canRecordVideos(callback); }, - canUseCamera: function (callback: (result: boolean) => void): void { + canUseCamera: function(callback: (result: boolean) => void): void { invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); return NativeImagePickerIOS.canUseCamera(callback); }, - openCameraDialog: function ( + openCameraDialog: function( config: $ReadOnly<{| unmirrorFrontFacingCamera?: boolean, videoMode?: boolean, @@ -51,7 +51,7 @@ const ImagePickerIOS = { cancelCallback, ); }, - openSelectDialog: function ( + openSelectDialog: function( config: $ReadOnly<{| showImages?: boolean, showVideos?: boolean, @@ -88,7 +88,7 @@ const ImagePickerIOS = { * It is safe to call this method for urlsthat aren't video URLs; * it will be a no-op. */ - removePendingVideo: function (url: string): void { + removePendingVideo: function(url: string): void { invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); NativeImagePickerIOS.removePendingVideo(url); }, @@ -96,7 +96,7 @@ const ImagePickerIOS = { * WARNING: In most cases, removePendingVideo should be used instead because * clearAllPendingVideos could clear out pending videos made by other callers. */ - clearAllPendingVideos: function (): void { + clearAllPendingVideos: function(): void { invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); NativeImagePickerIOS.clearAllPendingVideos(); }, diff --git a/Libraries/Image/__tests__/resolveAssetSource-test.js b/Libraries/Image/__tests__/resolveAssetSource-test.js index 95261685024..ee752bd7322 100644 --- a/Libraries/Image/__tests__/resolveAssetSource-test.js +++ b/Libraries/Image/__tests__/resolveAssetSource-test.js @@ -298,7 +298,7 @@ describe('resolveAssetSource', () => { }); it('uses bundled source, event when js is sideloaded', () => { - resolveAssetSource.setCustomSourceTransformer((resolver) => + resolveAssetSource.setCustomSourceTransformer(resolver => resolver.resourceIdentifierWithoutScale(), ); expectResolvesAsset( @@ -324,7 +324,7 @@ describe('resolveAssetSource', () => { }); it('allows any customization', () => { - resolveAssetSource.setCustomSourceTransformer((resolver) => + resolveAssetSource.setCustomSourceTransformer(resolver => resolver.fromSource('TEST'), ); expectResolvesAsset( diff --git a/Libraries/Inspector/ElementProperties.js b/Libraries/Inspector/ElementProperties.js index f5e51ce3643..48a7ff491b6 100644 --- a/Libraries/Inspector/ElementProperties.js +++ b/Libraries/Inspector/ElementProperties.js @@ -35,7 +35,7 @@ type Props = $ReadOnly<{| }, frame?: ?Object, selection?: ?number, - setSelection?: (number) => mixed, + setSelection?: number => mixed, |}>; class ElementProperties extends React.Component { @@ -75,7 +75,7 @@ class ElementProperties extends React.Component { {hierarchyItem.name} ), - (i) => ( + i => ( diff --git a/Libraries/Inspector/Inspector.js b/Libraries/Inspector/Inspector.js index 8b59d580384..25993952658 100644 --- a/Libraries/Inspector/Inspector.js +++ b/Libraries/Inspector/Inspector.js @@ -118,7 +118,7 @@ class Inspector extends React.Component< componentWillUnmount() { if (this._subs) { - this._subs.map((fn) => fn()); + this._subs.map(fn => fn()); } hook.off('react-devtools', this._attachToDevtools); } @@ -149,7 +149,7 @@ class Inspector extends React.Component< }, 100); }; - _onAgentShowNativeHighlight = (node) => { + _onAgentShowNativeHighlight = node => { clearTimeout(this._hideTimeoutID); node.measure((x, y, width, height, left, top) => { @@ -242,7 +242,7 @@ class Inspector extends React.Component< setTouchTargeting(val: boolean) { Touchable.TOUCH_TARGET_DEBUG = val; - this.props.onRequestRerenderApp((inspectedView) => { + this.props.onRequestRerenderApp(inspectedView => { this.setState({inspectedView}); }); } diff --git a/Libraries/Inspector/InspectorPanel.js b/Libraries/Inspector/InspectorPanel.js index b36046267a8..9cf47a83770 100644 --- a/Libraries/Inspector/InspectorPanel.js +++ b/Libraries/Inspector/InspectorPanel.js @@ -34,7 +34,7 @@ type Props = $ReadOnly<{| setNetworking: (val: boolean) => void, hierarchy?: ?Array<{|name: string|}>, selection?: ?number, - setSelection: (number) => mixed, + setSelection: number => mixed, inspected?: ?$ReadOnly<{| style?: ?ViewStyleProp, frame?: ?$ReadOnly<{| diff --git a/Libraries/Inspector/NetworkOverlay.js b/Libraries/Inspector/NetworkOverlay.js index 4e757185729..45e6bdadcbf 100644 --- a/Libraries/Inspector/NetworkOverlay.js +++ b/Libraries/Inspector/NetworkOverlay.js @@ -360,7 +360,7 @@ class NetworkOverlay extends React.Component { _renderItemDetail(id) { const requestItem = this.state.requests[id]; - const details = Object.keys(requestItem).map((key) => { + const details = Object.keys(requestItem).map(key => { if (key === 'id') { return; } @@ -387,7 +387,7 @@ class NetworkOverlay extends React.Component { (this._detailScrollView = scrollRef)}> + ref={scrollRef => (this._detailScrollView = scrollRef)}> {details} diff --git a/Libraries/Inspector/StyleInspector.js b/Libraries/Inspector/StyleInspector.js index dea9f0d8ea0..820224b3bc6 100644 --- a/Libraries/Inspector/StyleInspector.js +++ b/Libraries/Inspector/StyleInspector.js @@ -24,7 +24,7 @@ class StyleInspector extends React.Component<$FlowFixMeProps> { return ( - {names.map((name) => ( + {names.map(name => ( {name}: @@ -32,7 +32,7 @@ class StyleInspector extends React.Component<$FlowFixMeProps> { - {names.map((name) => { + {names.map(name => { const value = this.props.style[name]; return ( diff --git a/Libraries/Interaction/BridgeSpyStallHandler.js b/Libraries/Interaction/BridgeSpyStallHandler.js index 83ab14f9242..e90777d4152 100644 --- a/Libraries/Interaction/BridgeSpyStallHandler.js +++ b/Libraries/Interaction/BridgeSpyStallHandler.js @@ -16,9 +16,9 @@ const MessageQueue = require('../BatchedBridge/MessageQueue'); const infoLog = require('../Utilities/infoLog'); const BridgeSpyStallHandler = { - register: function () { + register: function() { let spyBuffer = []; - MessageQueue.spy((data) => { + MessageQueue.spy(data => { spyBuffer.push(data); }); const TO_JS = 0; @@ -26,13 +26,13 @@ const BridgeSpyStallHandler = { onStall: () => { infoLog( spyBuffer.length + ' bridge messages during stall: ', - spyBuffer.map((info) => { + spyBuffer.map(info => { let args = ''; try { args = JSON.stringify(info.args); } catch (e1) { if (Array.isArray(info.args)) { - args = info.args.map((arg) => { + args = info.args.map(arg => { try { return JSON.stringify(arg); } catch (e2) { diff --git a/Libraries/Interaction/FrameRateLogger.js b/Libraries/Interaction/FrameRateLogger.js index 8417131b108..434e962b027 100644 --- a/Libraries/Interaction/FrameRateLogger.js +++ b/Libraries/Interaction/FrameRateLogger.js @@ -35,7 +35,7 @@ const FrameRateLogger = { * Enable `debug` to see local logs of what's going on. `reportStackTraces` will grab stack traces * during UI thread stalls and upload them if the native module supports it. */ - setGlobalOptions: function (options: { + setGlobalOptions: function(options: { debug?: boolean, reportStackTraces?: boolean, ... @@ -60,7 +60,7 @@ const FrameRateLogger = { * Must call `setContext` before any events can be properly tracked, which is done automatically * in `AppRegistry`, but navigation is also a common place to hook in. */ - setContext: function (context: string) { + setContext: function(context: string) { NativeFrameRateLogger && NativeFrameRateLogger.setContext(context); }, diff --git a/Libraries/Interaction/InteractionManager.js b/Libraries/Interaction/InteractionManager.js index 48e5ede5e6c..02912bbc3cf 100644 --- a/Libraries/Interaction/InteractionManager.js +++ b/Libraries/Interaction/InteractionManager.js @@ -94,7 +94,7 @@ const InteractionManager = { ... } { const tasks = []; - const promise = new Promise((resolve) => { + const promise = new Promise(resolve => { _scheduleUpdate(); if (task) { tasks.push(task); @@ -116,7 +116,7 @@ const InteractionManager = { ); } }, - cancel: function () { + cancel: function() { _taskQueue.cancelTasks(tasks); }, }; @@ -189,8 +189,8 @@ function _processUpdate() { _nextUpdateHandle = 0; const interactionCount = _interactionSet.size; - _addInteractionSet.forEach((handle) => _interactionSet.add(handle)); - _deleteInteractionSet.forEach((handle) => _interactionSet.delete(handle)); + _addInteractionSet.forEach(handle => _interactionSet.add(handle)); + _deleteInteractionSet.forEach(handle => _interactionSet.delete(handle)); const nextInteractionCount = _interactionSet.size; if (interactionCount !== 0 && nextInteractionCount === 0) { diff --git a/Libraries/Interaction/InteractionMixin.js b/Libraries/Interaction/InteractionMixin.js index 3d51aead5ba..fcbd88f5a19 100644 --- a/Libraries/Interaction/InteractionMixin.js +++ b/Libraries/Interaction/InteractionMixin.js @@ -19,7 +19,7 @@ import {type Handle} from './InteractionManager'; * once per start, even if the component is unmounted. */ const InteractionMixin = { - componentWillUnmount: function () { + componentWillUnmount: function() { while (this._interactionMixinHandles.length) { InteractionManager.clearInteractionHandle( this._interactionMixinHandles.pop(), @@ -29,16 +29,16 @@ const InteractionMixin = { _interactionMixinHandles: ([]: Array), - createInteractionHandle: function (): Handle { + createInteractionHandle: function(): Handle { const handle = InteractionManager.createInteractionHandle(); this._interactionMixinHandles.push(handle); return handle; }, - clearInteractionHandle: function (clearHandle: number): void { + clearInteractionHandle: function(clearHandle: number): void { InteractionManager.clearInteractionHandle(clearHandle); this._interactionMixinHandles = this._interactionMixinHandles.filter( - (handle) => handle !== clearHandle, + handle => handle !== clearHandle, ); }, @@ -47,7 +47,7 @@ const InteractionMixin = { * * @param {function} callback */ - runAfterInteractions: function (callback: Function): void { + runAfterInteractions: function(callback: Function): void { InteractionManager.runAfterInteractions(callback); }, }; diff --git a/Libraries/Interaction/JSEventLoopWatchdog.js b/Libraries/Interaction/JSEventLoopWatchdog.js index 9bb800d8c39..c2787f188fd 100644 --- a/Libraries/Interaction/JSEventLoopWatchdog.js +++ b/Libraries/Interaction/JSEventLoopWatchdog.js @@ -36,20 +36,20 @@ type Handler = { * queried with `getStats`. */ const JSEventLoopWatchdog = { - getStats: function (): Object { + getStats: function(): Object { return {stallCount, totalStallTime, longestStall, acceptableBusyTime}; }, - reset: function () { + reset: function() { infoLog('JSEventLoopWatchdog: reset'); totalStallTime = 0; stallCount = 0; longestStall = 0; lastInterval = performanceNow(); }, - addHandler: function (handler: Handler) { + addHandler: function(handler: Handler) { handlers.push(handler); }, - install: function ({thresholdMS}: {thresholdMS: number, ...}) { + install: function({thresholdMS}: {thresholdMS: number, ...}) { acceptableBusyTime = thresholdMS; if (installed) { return; @@ -67,12 +67,12 @@ const JSEventLoopWatchdog = { let msg = `JSEventLoopWatchdog: JS thread busy for ${busyTime}ms. ` + `${totalStallTime}ms in ${stallCount} stalls so far. `; - handlers.forEach((handler) => { + handlers.forEach(handler => { msg += handler.onStall({lastInterval, busyTime}) || ''; }); infoLog(msg); } - handlers.forEach((handler) => { + handlers.forEach(handler => { handler.onIterate && handler.onIterate(); }); lastInterval = now; diff --git a/Libraries/Interaction/TaskQueue.js b/Libraries/Interaction/TaskQueue.js index fe4eadb2560..bf15d06a090 100644 --- a/Libraries/Interaction/TaskQueue.js +++ b/Libraries/Interaction/TaskQueue.js @@ -66,15 +66,15 @@ class TaskQueue { } enqueueTasks(tasks: Array): void { - tasks.forEach((task) => this.enqueue(task)); + tasks.forEach(task => this.enqueue(task)); } cancelTasks(tasksToCancel: Array): void { // search through all tasks and remove them. this._queueStack = this._queueStack - .map((queue) => ({ + .map(queue => ({ ...queue, - tasks: queue.tasks.filter((task) => tasksToCancel.indexOf(task) === -1), + tasks: queue.tasks.filter(task => tasksToCancel.indexOf(task) === -1), })) .filter((queue, idx) => queue.tasks.length > 0 || idx === 0); } @@ -171,8 +171,10 @@ class TaskQueue { this._queueStack[stackIdx].popable = true; this.hasTasksToProcess() && this._onMoreTasks(); }) - .catch((ex) => { - ex.message = `TaskQueue: Error resolving Promise in task ${task.name}: ${ex.message}`; + .catch(ex => { + ex.message = `TaskQueue: Error resolving Promise in task ${ + task.name + }: ${ex.message}`; throw ex; }) .done(); diff --git a/Libraries/Interaction/TouchHistoryMath.js b/Libraries/Interaction/TouchHistoryMath.js index 2cf7704b3f2..19cf76a9f1b 100644 --- a/Libraries/Interaction/TouchHistoryMath.js +++ b/Libraries/Interaction/TouchHistoryMath.js @@ -24,7 +24,7 @@ const TouchHistoryMath = { * touches vs. previous centroid of now actively moving touches. * @return {number} value of centroid in specified dimension. */ - centroidDimension: function ( + centroidDimension: function( touchHistory, touchesChangedAfter, isXAxis, @@ -81,7 +81,7 @@ const TouchHistoryMath = { return count > 0 ? total / count : TouchHistoryMath.noCentroid; }, - currentCentroidXOfTouchesChangedAfter: function ( + currentCentroidXOfTouchesChangedAfter: function( touchHistory, touchesChangedAfter, ) { @@ -93,7 +93,7 @@ const TouchHistoryMath = { ); }, - currentCentroidYOfTouchesChangedAfter: function ( + currentCentroidYOfTouchesChangedAfter: function( touchHistory, touchesChangedAfter, ) { @@ -105,7 +105,7 @@ const TouchHistoryMath = { ); }, - previousCentroidXOfTouchesChangedAfter: function ( + previousCentroidXOfTouchesChangedAfter: function( touchHistory, touchesChangedAfter, ) { @@ -117,7 +117,7 @@ const TouchHistoryMath = { ); }, - previousCentroidYOfTouchesChangedAfter: function ( + previousCentroidYOfTouchesChangedAfter: function( touchHistory, touchesChangedAfter, ) { @@ -129,7 +129,7 @@ const TouchHistoryMath = { ); }, - currentCentroidX: function (touchHistory) { + currentCentroidX: function(touchHistory) { return TouchHistoryMath.centroidDimension( touchHistory, 0, // touchesChangedAfter @@ -138,7 +138,7 @@ const TouchHistoryMath = { ); }, - currentCentroidY: function (touchHistory) { + currentCentroidY: function(touchHistory) { return TouchHistoryMath.centroidDimension( touchHistory, 0, // touchesChangedAfter diff --git a/Libraries/Interaction/__tests__/InteractionManager-test.js b/Libraries/Interaction/__tests__/InteractionManager-test.js index d156ba58521..a9abd62f5c6 100644 --- a/Libraries/Interaction/__tests__/InteractionManager-test.js +++ b/Libraries/Interaction/__tests__/InteractionManager-test.js @@ -177,7 +177,7 @@ describe('promise tasks', () => { it('should run a basic promise task', () => { const task1 = jest.fn(() => { expect(++sequenceId).toBe(1); - return new Promise((resolve) => resolve()); + return new Promise(resolve => resolve()); }); InteractionManager.runAfterInteractions({gen: task1, name: 'gen1'}); jest.runAllTimers(); @@ -187,7 +187,7 @@ describe('promise tasks', () => { it('should handle nested promises', () => { const task1 = jest.fn(() => { expect(++sequenceId).toBe(1); - return new Promise((resolve) => { + return new Promise(resolve => { InteractionManager.runAfterInteractions({ gen: task2, name: 'gen2', @@ -196,7 +196,7 @@ describe('promise tasks', () => { }); const task2 = jest.fn(() => { expect(++sequenceId).toBe(2); - return new Promise((resolve) => resolve()); + return new Promise(resolve => resolve()); }); InteractionManager.runAfterInteractions({gen: task1, name: 'gen1'}); jest.runAllTimers(); @@ -208,7 +208,7 @@ describe('promise tasks', () => { const task1 = createSequenceTask(1); const task2 = jest.fn(() => { expect(++sequenceId).toBe(2); - return new Promise((resolve) => { + return new Promise(resolve => { setTimeout(() => { InteractionManager.runAfterInteractions(task3).then(resolve); }, 1); @@ -262,13 +262,13 @@ describe('promise tasks', () => { expectToBeCalledOnce(task2); }); - const bigAsyncTest = (resolveTest) => { + const bigAsyncTest = resolveTest => { jest.useRealTimers(); const task1 = createSequenceTask(1); const task2 = jest.fn(() => { expect(++sequenceId).toBe(2); - return new Promise((resolve) => { + return new Promise(resolve => { InteractionManager.runAfterInteractions(task3); setTimeout(() => { InteractionManager.runAfterInteractions({ @@ -281,7 +281,7 @@ describe('promise tasks', () => { const task3 = createSequenceTask(3); const task4 = jest.fn(() => { expect(++sequenceId).toBe(4); - return new Promise((resolve) => { + return new Promise(resolve => { InteractionManager.runAfterInteractions(task5).then(resolve); }); }); diff --git a/Libraries/Interaction/__tests__/TaskQueue-test.js b/Libraries/Interaction/__tests__/TaskQueue-test.js index f4e03b47357..5055fa2dde8 100644 --- a/Libraries/Interaction/__tests__/TaskQueue-test.js +++ b/Libraries/Interaction/__tests__/TaskQueue-test.js @@ -51,7 +51,7 @@ describe('TaskQueue', () => { it('should handle blocking promise task', () => { const task1 = jest.fn(() => { - return new Promise((resolve) => { + return new Promise(resolve => { setTimeout(() => { expect(++sequenceId).toBe(1); resolve(); @@ -94,7 +94,7 @@ describe('TaskQueue', () => { it('should handle nested promises', () => { const task1 = jest.fn(() => { - return new Promise((resolve) => { + return new Promise(resolve => { setTimeout(() => { expect(++sequenceId).toBe(1); taskQueue.enqueue({gen: task2, name: 'gen2'}); @@ -103,7 +103,7 @@ describe('TaskQueue', () => { }); }); const task2 = jest.fn(() => { - return new Promise((resolve) => { + return new Promise(resolve => { setTimeout(() => { expect(++sequenceId).toBe(2); taskQueue.enqueue({run: task3, name: 'run3'}); diff --git a/Libraries/LayoutAnimation/LayoutAnimation.js b/Libraries/LayoutAnimation/LayoutAnimation.js index 872ca05ec90..ba4632eb712 100644 --- a/Libraries/LayoutAnimation/LayoutAnimation.js +++ b/Libraries/LayoutAnimation/LayoutAnimation.js @@ -47,8 +47,8 @@ function configureNext( if (!Platform.isTesting) { UIManager.configureNextLayoutAnimation( config, - onAnimationDidEnd ?? function () {}, - function () {} /* unused onError */, + onAnimationDidEnd ?? function() {}, + function() {} /* unused onError */, ); } } diff --git a/Libraries/Lists/FillRateHelper.js b/Libraries/Lists/FillRateHelper.js index 678ea593399..a1d58669c48 100644 --- a/Libraries/Lists/FillRateHelper.js +++ b/Libraries/Lists/FillRateHelper.js @@ -58,7 +58,7 @@ class FillRateHelper { _samplesStartTime = (null: ?number); static addListener( - callback: (FillRateInfo) => void, + callback: FillRateInfo => void, ): {remove: () => void, ...} { warning( _sampleRate !== null, @@ -67,7 +67,7 @@ class FillRateHelper { _listeners.push(callback); return { remove: () => { - _listeners = _listeners.filter((listener) => callback !== listener); + _listeners = _listeners.filter(listener => callback !== listener); }, }; } @@ -131,7 +131,7 @@ class FillRateHelper { } console.debug('FillRateHelper deactivateAndFlush: ', {derived, info}); } - _listeners.forEach((listener) => listener(info)); + _listeners.forEach(listener => listener(info)); this._resetData(); } diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index c9ab0afee3d..fac01144957 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -405,7 +405,7 @@ class FlatList extends React.PureComponent, void> { this._checkProps(this.props); if (this.props.viewabilityConfigCallbackPairs) { this._virtualizedListPairs = this.props.viewabilityConfigCallbackPairs.map( - (pair) => ({ + pair => ({ viewabilityConfig: pair.viewabilityConfig, onViewableItemsChanged: this._createOnViewableItemsChanged( pair.onViewableItemsChanged, @@ -451,7 +451,7 @@ class FlatList extends React.PureComponent, void> { _listRef: ?React.ElementRef; _virtualizedListPairs: Array = []; - _captureRef = (ref) => { + _captureRef = ref => { this._listRef = ref; }; @@ -555,12 +555,10 @@ class FlatList extends React.PureComponent, void> { if (numColumns > 1) { const changed = []; const viewableItems = []; - info.viewableItems.forEach((v) => + info.viewableItems.forEach(v => this._pushMultiColumnViewable(viewableItems, v), ); - info.changed.forEach((v) => - this._pushMultiColumnViewable(changed, v), - ); + info.changed.forEach(v => this._pushMultiColumnViewable(changed, v)); onViewableItemsChanged({viewableItems, changed}); } else { onViewableItemsChanged(info); @@ -604,7 +602,11 @@ class FlatList extends React.PureComponent, void> { 'Expected array of items with numColumns > 1', ); return ( - + {item.map((it, kk) => { const element = renderer({ item: it, diff --git a/Libraries/Lists/SectionList.js b/Libraries/Lists/SectionList.js index c318a0a0626..0f20fa7ed93 100644 --- a/Libraries/Lists/SectionList.js +++ b/Libraries/Lists/SectionList.js @@ -246,14 +246,14 @@ class SectionList> extends React.PureComponent< items.length} + getItemCount={items => items.length} getItem={(items, index) => items[index]} /> ); } _wrapperListRef: ?React.ElementRef; - _captureRef = (ref) => { + _captureRef = ref => { /* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an * error found when Flow v0.99 was deployed. To see the error, delete this * comment and run Flow. */ diff --git a/Libraries/Lists/ViewabilityHelper.js b/Libraries/Lists/ViewabilityHelper.js index 3b6b1912a9f..48425b00707 100644 --- a/Libraries/Lists/ViewabilityHelper.js +++ b/Libraries/Lists/ViewabilityHelper.js @@ -270,12 +270,12 @@ class ViewabilityHelper { createViewToken, ) { // Filter out indices that have gone out of view since this call was scheduled. - viewableIndicesToCheck = viewableIndicesToCheck.filter((ii) => + viewableIndicesToCheck = viewableIndicesToCheck.filter(ii => this._viewableIndices.includes(ii), ); const prevItems = this._viewableItems; const nextItems = new Map( - viewableIndicesToCheck.map((ii) => { + viewableIndicesToCheck.map(ii => { const viewable = createViewToken(ii, true); return [viewable.key, viewable]; }), diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index d21ff713e06..2fcf4b36d7e 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -419,9 +419,9 @@ class VirtualizedList extends React.PureComponent { const {animated, index, viewOffset, viewPosition} = params; invariant( index >= 0 && index < getItemCount(data), - `scrollToIndex out of range: requested index ${index} but maximum is ${ - getItemCount(data) - 1 - }`, + `scrollToIndex out of range: requested index ${index} but maximum is ${getItemCount( + data, + ) - 1}`, ); if (!getItemLayout && index > this._highestMeasuredFrameIndex) { invariant( @@ -496,10 +496,10 @@ class VirtualizedList extends React.PureComponent { } recordInteraction() { - this._nestedChildLists.forEach((childList) => { + this._nestedChildLists.forEach(childList => { childList.ref && childList.ref.recordInteraction(); }); - this._viewabilityTuples.forEach((t) => { + this._viewabilityTuples.forEach(t => { t.viewabilityHelper.recordInteraction(); }); this._updateViewableItems(this.props.data); @@ -642,7 +642,7 @@ class VirtualizedList extends React.PureComponent { }, horizontal: ?boolean, getOutermostParentListRef: Function, - getNestedChildState: (string) => ?ChildListState, + getNestedChildState: string => ?ChildListState, registerAsNestedChild: ({ cellKey: string, key: string, @@ -786,7 +786,7 @@ class VirtualizedList extends React.PureComponent { if (this.props.viewabilityConfigCallbackPairs) { this._viewabilityTuples = this.props.viewabilityConfigCallbackPairs.map( - (pair) => ({ + pair => ({ viewabilityHelper: new ViewabilityHelper(pair.viewabilityConfig), onViewableItemsChanged: pair.onViewableItemsChanged, }), @@ -849,7 +849,7 @@ class VirtualizedList extends React.PureComponent { } this._updateViewableItems(null); this._updateCellsToRenderBatcher.dispose({abort: true}); - this._viewabilityTuples.forEach((tuple) => { + this._viewabilityTuples.forEach(tuple => { tuple.viewabilityHelper.dispose(); }); this._fillRateHelper.deactivateAndFlush(); @@ -909,10 +909,10 @@ class VirtualizedList extends React.PureComponent { key={key} prevCellKey={prevCellKey} onUpdateSeparators={this._onUpdateSeparators} - onLayout={(e) => this._onCellLayout(e, key, ii)} + onLayout={e => this._onCellLayout(e, key, ii)} onUnmount={this._onCellUnmount} parentProps={this.props} - ref={(ref) => { + ref={ref => { this._cellRefs[key] = ref; }} />, @@ -922,7 +922,7 @@ class VirtualizedList extends React.PureComponent { } _onUpdateSeparators = (keys: Array, newProps: Object) => { - keys.forEach((key) => { + keys.forEach(key => { const ref = key != null && this._cellRefs[key]; ref && ref.updateSeparatorProps(newProps); }); @@ -1111,13 +1111,16 @@ class VirtualizedList extends React.PureComponent { cells.push( React.cloneElement(element, { key: '$empty', - onLayout: (event) => { + onLayout: event => { this._onLayoutEmpty(event); if (element.props.onLayout) { element.props.onLayout(event); } }, - style: StyleSheet.compose(inversionStyle, element.props.style), + style: StyleSheet.compose( + inversionStyle, + element.props.style, + ), }), ); } @@ -1181,7 +1184,7 @@ class VirtualizedList extends React.PureComponent { if (__DEV__) { ret = ( - {(scrollContext) => { + {scrollContext => { if ( scrollContext != null && !scrollContext.horizontal === !this.props.horizontal && @@ -1219,7 +1222,7 @@ class VirtualizedList extends React.PureComponent { // clear the viewableIndices cache to also trigger // the onViewableItemsChanged callback with the new data - this._viewabilityTuples.forEach((tuple) => { + this._viewabilityTuples.forEach(tuple => { tuple.viewabilityHelper.resetViewableIndices(); }); } @@ -1280,7 +1283,7 @@ class VirtualizedList extends React.PureComponent { _updateCellsToRenderBatcher: Batchinator; _viewabilityTuples: Array = []; - _captureScrollRef = (ref) => { + _captureScrollRef = ref => { this._scrollRef = ref; }; @@ -1292,7 +1295,7 @@ class VirtualizedList extends React.PureComponent { ); } - _defaultRenderScrollComponent = (props) => { + _defaultRenderScrollComponent = props => { const onRefresh = props.onRefresh; if (this._isNestedWithSameOrientation()) { // $FlowFixMe - Typing ReactNativeComponent revealed errors @@ -1410,7 +1413,7 @@ class VirtualizedList extends React.PureComponent { this._scrollMetrics.visibleLength = scrollMetrics.visibleLength; this._scrollMetrics.offset = scrollMetrics.offset; }, - (error) => { + error => { console.warn( "VirtualizedList: Encountered an error while measuring a list's" + ' offset from its containing VirtualizedList.', @@ -1440,7 +1443,7 @@ class VirtualizedList extends React.PureComponent { this._maybeCallOnEndReached(); }; - _onLayoutEmpty = (e) => { + _onLayoutEmpty = e => { this.props.onLayout && this.props.onLayout(e); }; @@ -1448,12 +1451,12 @@ class VirtualizedList extends React.PureComponent { return this._getCellKey() + '-footer'; } - _onLayoutFooter = (e) => { + _onLayoutFooter = e => { this._triggerRemeasureForChildListsInCell(this._getFooterCellKey()); this._footerLength = this._selectLength(e.nativeEvent.layout); }; - _onLayoutHeader = (e) => { + _onLayoutHeader = e => { this._headerLength = this._selectLength(e.nativeEvent.layout); }; @@ -1609,7 +1612,7 @@ class VirtualizedList extends React.PureComponent { }; _onScroll = (e: Object) => { - this._nestedChildLists.forEach((childList) => { + this._nestedChildLists.forEach(childList => { childList.ref && childList.ref._onScroll(e); }); if (this.props.onScroll) { @@ -1729,10 +1732,10 @@ class VirtualizedList extends React.PureComponent { } _onScrollBeginDrag = (e): void => { - this._nestedChildLists.forEach((childList) => { + this._nestedChildLists.forEach(childList => { childList.ref && childList.ref._onScrollBeginDrag(e); }); - this._viewabilityTuples.forEach((tuple) => { + this._viewabilityTuples.forEach(tuple => { tuple.viewabilityHelper.recordInteraction(); }); this._hasInteracted = true; @@ -1761,7 +1764,7 @@ class VirtualizedList extends React.PureComponent { if (!data) { return; } - this.setState((state) => { + this.setState(state => { let newState; const {contentLength, offset, visibleLength} = this._scrollMetrics; if (!isVirtualizationDisabled) { @@ -1917,7 +1920,7 @@ class VirtualizedList extends React.PureComponent { _updateViewableItems(data: any) { const {getItemCount} = this.props; - this._viewabilityTuples.forEach((tuple) => { + this._viewabilityTuples.forEach(tuple => { tuple.viewabilityHelper.onUpdate( getItemCount(data), this._scrollMetrics.offset, @@ -2033,7 +2036,7 @@ class CellRenderer extends React.Component< }; updateSeparatorProps(newProps: Object) { - this.setState((state) => ({ + this.setState(state => ({ separatorProps: {...state.separatorProps, ...newProps}, })); } diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 0a501ad15e7..53eb54be609 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -376,7 +376,7 @@ class VirtualizedSectionList< leadingSection={info.leadingSection} onUpdateSeparator={this._onUpdateSeparator} prevCellKey={(this._subExtractor(index - 1) || {}).key} - ref={(ref) => { + ref={ref => { this._cellRefs[info.key] = ref; }} renderItem={renderItem} @@ -419,7 +419,7 @@ class VirtualizedSectionList< _cellRefs = {}; _listRef: VirtualizedList; - _captureRef = (ref) => { + _captureRef = ref => { /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment * suppresses an error when upgrading Flow's support for React. To see the * error delete this comment and run Flow. */ @@ -485,19 +485,19 @@ class ItemWithSeparator extends React.Component< _separators = { highlight: () => { - ['leading', 'trailing'].forEach((s) => + ['leading', 'trailing'].forEach(s => this._separators.updateProps(s, {highlighted: true}), ); }, unhighlight: () => { - ['leading', 'trailing'].forEach((s) => + ['leading', 'trailing'].forEach(s => this._separators.updateProps(s, {highlighted: false}), ); }, updateProps: (select: 'leading' | 'trailing', newProps: Object) => { const {LeadingSeparatorComponent, cellKey, prevCellKey} = this.props; if (select === 'leading' && LeadingSeparatorComponent != null) { - this.setState((state) => ({ + this.setState(state => ({ leadingSeparatorProps: {...state.leadingSeparatorProps, ...newProps}, })); } else { @@ -534,7 +534,7 @@ class ItemWithSeparator extends React.Component< } updateSeparatorProps(newProps: Object) { - this.setState((state) => ({ + this.setState(state => ({ separatorProps: {...state.separatorProps, ...newProps}, })); } diff --git a/Libraries/Lists/__flowtests__/FlatList-flowtest.js b/Libraries/Lists/__flowtests__/FlatList-flowtest.js index 4581b92621e..912289cbf00 100644 --- a/Libraries/Lists/__flowtests__/FlatList-flowtest.js +++ b/Libraries/Lists/__flowtests__/FlatList-flowtest.js @@ -62,7 +62,7 @@ module.exports = { ]; return ( ( + renderItem={info => ( { // $FlowExpectedError - bad widgetCount type 6, should be Object diff --git a/Libraries/Lists/__tests__/FillRateHelper-test.js b/Libraries/Lists/__tests__/FillRateHelper-test.js index 31ce11f3349..a0b0b3b4f48 100644 --- a/Libraries/Lists/__tests__/FillRateHelper-test.js +++ b/Libraries/Lists/__tests__/FillRateHelper-test.js @@ -31,7 +31,7 @@ function computeResult({helper, props, state, scroll}): number { return helper.computeBlankness( { data: dataGlobal, - getItemCount: (data2) => data2.length, + getItemCount: data2 => data2.length, initialNumToRender: 10, ...(props || {}), }, @@ -40,13 +40,13 @@ function computeResult({helper, props, state, scroll}): number { ); } -describe('computeBlankness', function () { +describe('computeBlankness', function() { beforeEach(() => { FillRateHelper.setSampleRate(1); FillRateHelper.setMinSampleCount(0); }); - it('computes correct blankness of viewport', function () { + it('computes correct blankness of viewport', function() { const helper = new FillRateHelper(getFrameMetrics); rowFramesGlobal = { header: {y: 0, height: 0, inLayout: true}, @@ -65,7 +65,7 @@ describe('computeBlankness', function () { expect(blankness).toBe(1); }); - it('skips frames that are not in layout', function () { + it('skips frames that are not in layout', function() { const helper = new FillRateHelper(getFrameMetrics); rowFramesGlobal = { header: {y: 0, height: 0, inLayout: false}, @@ -79,7 +79,7 @@ describe('computeBlankness', function () { expect(blankness).toBe(0.3); }); - it('sampling rate can disable', function () { + it('sampling rate can disable', function() { let helper = new FillRateHelper(getFrameMetrics); rowFramesGlobal = { header: {y: 0, height: 0, inLayout: true}, @@ -96,9 +96,9 @@ describe('computeBlankness', function () { expect(blankness).toBe(0); }); - it('can handle multiple listeners and unsubscribe', function () { + it('can handle multiple listeners and unsubscribe', function() { const listeners = [jest.fn(), jest.fn(), jest.fn()]; - const subscriptions = listeners.map((listener) => + const subscriptions = listeners.map(listener => FillRateHelper.addListener(listener), ); subscriptions[1].remove(); diff --git a/Libraries/Lists/__tests__/FlatList-test.js b/Libraries/Lists/__tests__/FlatList-test.js index db456aac10a..eb7e648d258 100644 --- a/Libraries/Lists/__tests__/FlatList-test.js +++ b/Libraries/Lists/__tests__/FlatList-test.js @@ -102,13 +102,13 @@ describe('FlatList', () => { ReactTestRenderer.create( ( + renderItem={outerInfo => ( { + renderItem={innerInfo => { return ; }} ref={listRef} diff --git a/Libraries/Lists/__tests__/SectionList-test.js b/Libraries/Lists/__tests__/SectionList-test.js index e0071172b84..93e31f9a329 100644 --- a/Libraries/Lists/__tests__/SectionList-test.js +++ b/Libraries/Lists/__tests__/SectionList-test.js @@ -39,21 +39,21 @@ describe('SectionList', () => { const component = ReactTestRenderer.create( ( + ItemSeparatorComponent={props => ( )} - ListEmptyComponent={(props) => } - ListFooterComponent={(props) =>