From 77ecc7ede1da8fc590d7bc238a2fc02daa736746 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Tue, 2 Nov 2021 22:10:46 -0700 Subject: [PATCH] JS: Format with Prettier v2.4.1 [3/n] Summary: Changelog: [General][Internal] Reviewed By: zertosh Differential Revision: D31883447 fbshipit-source-id: cbbf85e4bf935096d242336f41bf0cc5d6f92359 --- IntegrationTests/AsyncStorageTest.js | 12 +- .../IntegrationTestHarnessTest.js | 12 +- IntegrationTests/IntegrationTestsApp.js | 10 +- IntegrationTests/LoggingTestModule.js | 14 +- .../RCTRootViewIntegrationTestApp.js | 10 +- IntegrationTests/WebSocketTest.js | 2 +- Libraries/Alert/Alert.js | 4 +- Libraries/Alert/RCTAlertManager.android.js | 2 +- Libraries/Animated/AnimatedImplementation.js | 106 ++--- Libraries/Animated/AnimatedMock.js | 16 +- Libraries/Animated/NativeAnimatedHelper.js | 43 +- .../Animated/__tests__/AnimatedNative-test.js | 98 ++-- Libraries/Animated/__tests__/Easing-test.js | 429 +++++------------- Libraries/Animated/__tests__/bezier-test.js | 56 +-- Libraries/Animated/nodes/AnimatedNode.js | 19 +- Libraries/Animated/nodes/AnimatedValueXY.js | 2 +- Libraries/AppState/AppState.js | 11 +- .../__mocks__/MessageQueueTestModule.js | 4 +- .../__tests__/MessageQueue-test.js | 8 +- .../__tests__/NativeModules-test.js | 22 +- 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/AccessibilityInfo.js | 38 +- .../DrawerLayoutAndroid.android.js | 7 +- Libraries/Components/Keyboard/Keyboard.js | 11 +- .../ProgressViewIOS/ProgressViewIOS.ios.js | 3 +- .../RefreshControl/RefreshControl.js | 9 +- .../__mocks__/RefreshControlMock.js | 5 +- .../Components/SafeAreaView/SafeAreaView.js | 4 +- ...roidHorizontalScrollViewNativeComponent.js | 8 +- .../ScrollContentViewNativeComponent.js | 8 +- Libraries/Components/ScrollView/ScrollView.js | 24 +- .../ScrollView/ScrollViewNativeComponent.js | 8 +- .../SegmentedControlIOS.ios.js | 10 +- Libraries/Components/Sound/SoundManager.js | 2 +- .../RCTMultilineTextInputNativeComponent.js | 9 +- .../RCTSingelineTextInputNativeComponent.js | 9 +- Libraries/Components/TextInput/TextInput.js | 23 +- .../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 | 51 ++- .../Components/Touchable/TouchableBounce.js | 7 +- .../Touchable/TouchableHighlight.js | 7 +- .../Touchable/TouchableNativeFeedback.js | 15 +- .../Components/Touchable/TouchableOpacity.js | 7 +- .../Touchable/TouchableWithoutFeedback.js | 7 +- .../Components/View/ViewNativeComponent.js | 7 +- .../__tests__/parseErrorStack-test.js | 8 +- Libraries/Core/Devtools/parseHermesStack.js | 3 +- Libraries/Core/ExceptionsManager.js | 4 +- Libraries/Core/NativeExceptionsManager.js | 5 +- Libraries/Core/Timers/JSTimers.js | 30 +- .../Core/Timers/__tests__/JSTimers-test.js | 132 +++--- Libraries/Core/setUpAlert.js | 2 +- Libraries/Core/setUpDeveloperTools.js | 2 +- Libraries/Core/setUpPerformance.js | 2 +- Libraries/Core/setUpRegeneratorRuntime.js | 2 +- Libraries/Core/setUpSegmentFetcher.js | 8 +- .../DeprecatedColorPropType.js | 2 +- .../DeprecatedStyleSheetPropType.js | 4 +- .../DeprecatedTransformPropTypes.js | 4 +- .../deprecatedCreateStrictShapeTypeChecker.js | 2 +- Libraries/EventEmitter/NativeEventEmitter.js | 3 +- .../__mocks__/NativeEventEmitter.js | 3 +- Libraries/HeapCapture/HeapCapture.js | 2 +- Libraries/Image/AssetSourceResolver.js | 6 +- Libraries/Image/Image.android.js | 8 +- Libraries/Image/Image.ios.js | 6 +- Libraries/Image/ImageAnalyticsTagContext.js | 5 +- Libraries/Image/ImagePickerIOS.js | 12 +- Libraries/Image/ImageViewNativeComponent.js | 8 +- Libraries/Image/NativeImageLoaderAndroid.js | 4 +- .../Image/TextInlineImageNativeComponent.js | 8 +- .../__tests__/resolveAssetSource-test.js | 16 +- Libraries/Inspector/NetworkOverlay.js | 7 +- .../Interaction/BridgeSpyStallHandler.js | 2 +- Libraries/Interaction/FrameRateLogger.js | 4 +- Libraries/Interaction/InteractionManager.js | 6 +- Libraries/Interaction/JSEventLoopWatchdog.js | 8 +- Libraries/Interaction/PanResponder.js | 7 +- Libraries/Interaction/TouchHistoryMath.js | 14 +- Libraries/JSInspector/NetworkAgent.js | 7 +- Libraries/LayoutAnimation/LayoutAnimation.js | 6 +- Libraries/Lists/FillRateHelper.js | 7 +- Libraries/Lists/FlatList.js | 7 +- Libraries/Lists/ViewabilityHelper.js | 14 +- Libraries/Lists/VirtualizeUtils.js | 8 +- Libraries/Lists/VirtualizedList.js | 35 +- Libraries/Lists/VirtualizedListContext.js | 5 +- Libraries/Lists/VirtualizedSectionList.js | 117 +++-- .../Lists/__tests__/FillRateHelper-test.js | 10 +- .../Lists/__tests__/ViewabilityHelper-test.js | 28 +- .../Lists/__tests__/VirtualizeUtils-test.js | 33 +- Libraries/LogBox/Data/LogBoxData.js | 2 +- Libraries/LogBox/Data/parseLogBoxLog.js | 35 +- .../LogBoxInspectorMesageHeader-test.js | 4 +- .../LogBoxInspectorReactFrames-test.js | 4 +- .../LogBoxInspectorSourceMapStatus-test.js | 4 +- .../LogBoxInspectorStackFrame-test.js | 4 +- .../NativeComponentRegistry.js | 6 +- Libraries/Network/XHRInterceptor.js | 11 +- Libraries/Network/__tests__/FormData-test.js | 6 +- .../Network/__tests__/XMLHttpRequest-test.js | 26 +- Libraries/Performance/SamplingProfiler.js | 6 +- .../PermissionsAndroid/PermissionsAndroid.js | 7 +- Libraries/Pressability/Pressability.js | 4 +- .../PressabilityPerformanceEventEmitter.js | 6 +- .../PushNotificationIOS.js | 11 +- Libraries/ReactNative/AppContainer.js | 4 +- Libraries/ReactNative/AppRegistry.js | 5 +- Libraries/ReactNative/I18nManager.js | 7 +- Libraries/ReactNative/PaperUIManager.js | 5 +- Libraries/ReactNative/RootTag.js | 5 +- Libraries/Storage/AsyncStorage.js | 42 +- Libraries/StyleSheet/StyleSheet.js | 3 +- Libraries/StyleSheet/StyleSheetTypes.js | 2 +- .../__tests__/normalizeColor-test.js | 12 +- .../StyleSheet/__tests__/processColor-test.js | 12 +- .../__tests__/processColorArray-test.js | 18 +- .../__tests__/setNormalizedColorAlpha-test.js | 10 +- Libraries/StyleSheet/processColor.js | 4 +- Libraries/StyleSheet/splitLayoutProps.js | 4 +- Libraries/Text/Text.js | 3 +- Libraries/Text/TextNativeComponent.js | 8 +- Libraries/Utilities/Appearance.js | 11 +- Libraries/Utilities/BackHandler.android.js | 8 +- Libraries/Utilities/HMRClient.js | 4 +- Libraries/Utilities/JSDevSupportModule.js | 7 +- Libraries/Utilities/MatrixMath.js | 38 +- .../Utilities/PerformanceLoggerContext.js | 5 +- Libraries/Utilities/SceneTracker.js | 7 +- Libraries/Utilities/__mocks__/BackHandler.js | 6 +- .../Utilities/__tests__/MatrixMath-test.js | 33 +- .../Utilities/__tests__/SceneTracker-test.js | 4 +- .../__tests__/buildStyleInterpolator-test.js | 54 +-- .../deepFreezeAndThrowOnMutationInDev-test.js | 2 +- .../__tests__/mapWithSeparator-test.js | 16 +- .../Utilities/__tests__/stringifySafe-test.js | 2 +- .../Utilities/__tests__/useMergeRefs-test.js | 8 +- ...erifyComponentAttributeEquivalence-test.js | 4 +- Libraries/Utilities/buildStyleInterpolator.js | 18 +- Libraries/Utilities/codegenNativeComponent.js | 5 +- .../differ/__tests__/deepDiffer-test.js | 2 +- .../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/truncate.js | 2 +- Libraries/Vibration/Vibration.js | 4 +- Libraries/WebSocket/WebSocketInterceptor.js | 8 +- .../WebSocket/__tests__/WebSocket-test.js | 2 +- Libraries/promiseRejectionTrackingOptions.js | 2 +- ReactAndroid/src/androidTest/js/Asserts.js | 4 +- .../js/CatalystRootViewTestModule.js | 2 +- .../androidTest/js/MeasureLayoutTestModule.js | 146 +++--- .../androidTest/js/ProgressBarTestModule.js | 2 +- .../androidTest/js/ScrollViewTestModule.js | 10 +- .../src/androidTest/js/ShareTestModule.js | 2 +- .../js/SubviewsClippingTestModule.js | 10 +- .../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 | 2 +- .../androidTest/js/ViewRenderingTestModule.js | 10 +- .../tools/msggen/src/HeaderWriter.js | 2 +- .../inspector/tools/msggen/src/index.js | 2 +- bots/code-analysis-bot.js | 29 +- bots/dangerfile.js | 3 +- bots/make-comment.js | 8 +- jest/assetFileTransformer.js | 4 +- jest/preprocessor.js | 4 +- jest/setup.js | 6 +- .../__test_fixtures__/failures.js | 6 +- packages/babel-plugin-codegen/index.js | 2 +- .../react-native-modules.js | 8 +- .../__tests__/platform-colors-test.js | 12 +- .../platform-colors.js | 4 +- packages/normalize-color/index.js | 28 +- .../react-native-codegen/scripts/build.js | 5 +- .../src/generators/components/CppHelpers.js | 5 +- .../components/GenerateEventEmitterCpp.js | 2 +- .../components/GenerateEventEmitterH.js | 2 +- .../generators/components/GeneratePropsCpp.js | 5 +- .../generators/components/GeneratePropsH.js | 10 +- .../components/GeneratePropsJavaDelegate.js | 4 +- .../components/GeneratePropsJavaInterface.js | 4 +- .../generators/components/GenerateTests.js | 5 +- .../components/GenerateViewConfigJs.js | 4 +- .../generators/modules/GenerateModuleCpp.js | 7 +- .../src/generators/modules/GenerateModuleH.js | 9 +- .../modules/GenerateModuleJniCpp.js | 27 +- .../src/parsers/flow/components/events.js | 9 +- .../__tests__/module-parser-e2e-test.js | 121 ++--- .../src/parsers/flow/modules/index.js | 51 +-- .../RCTTest/RCTSnapshotNativeComponent.js | 5 +- .../RNTesterUnitTestsBundle.js | 2 +- packages/rn-tester/e2e/test-init.js | 2 +- .../rn-tester/js/components/RNTesterTheme.js | 7 +- .../rn-tester/js/components/TextLegend.js | 6 +- .../js/components/createExamplePage.js | 2 +- .../examples/AnimatedGratuitousApp/AnExApp.js | 2 +- .../AnimatedGratuitousApp/AnExScroll.js | 6 +- .../js/examples/Button/ButtonExample.js | 29 +- .../FlatList/FlatList-onEndReached.js | 2 +- .../FlatList/FlatList-withSeparators.js | 35 +- .../js/examples/Image/ImageExample.js | 116 ++--- .../InputAccessoryViewExample.js | 2 +- .../JSResponderHandlerExample.js | 11 +- .../KeyboardAvoidingViewExample.js | 10 +- .../js/examples/Layout/LayoutEventsExample.js | 14 +- .../js/examples/Layout/LayoutExample.js | 2 +- .../js/examples/Linking/LinkingExample.js | 4 +- .../js/examples/Modal/ModalPresentation.js | 10 +- .../NativeAnimationsExample.js | 30 +- .../PanResponder/PanResponderExample.js | 2 +- .../PointerEvents/PointerEventsExample.js | 2 +- .../js/examples/Pressable/PressableExample.js | 37 +- .../rn-tester/js/examples/RTL/RTLExample.js | 30 +- .../RefreshControl/RefreshControlExample.js | 2 +- .../SafeAreaView/SafeAreaViewExample.js | 9 +- .../ScrollView/ScrollViewAnimatedExample.js | 13 +- .../examples/ScrollView/ScrollViewExample.js | 85 ++-- .../ScrollView/ScrollViewSimpleExample.js | 2 +- .../SectionList/SectionList-contentInset.js | 2 +- .../SectionList/SectionList-inverted.js | 2 +- .../SectionList/SectionList-onEndReached.js | 2 +- .../SectionList-onViewableItemsChanged.js | 4 +- .../SectionList/SectionList-scrollable.js | 40 +- .../SectionList-stickyHeadersEnabled.js | 2 +- .../SectionList/SectionList-withSeparators.js | 41 +- .../js/examples/Share/ShareExample.js | 13 +- .../js/examples/StatusBar/StatusBarExample.js | 4 +- .../SwipeableCardExample.js | 7 +- .../js/examples/Text/TextExample.android.js | 4 +- .../js/examples/Text/TextExample.ios.js | 62 +-- .../TextInput/TextInputExample.android.js | 24 +- .../TextInput/TextInputExample.ios.js | 42 +- .../js/examples/TextInput/TextInputKeyProp.js | 2 +- .../TextInput/TextInputSharedExamples.js | 24 +- .../js/examples/Timer/TimerExample.js | 10 +- .../js/examples/Touchable/TouchableExample.js | 44 +- .../TurboModule/SampleTurboModuleExample.js | 2 +- .../TurboModule/TurboModuleExample.js | 2 +- .../rn-tester/js/examples/View/ViewExample.js | 2 +- .../js/examples/WebSocket/http_test_server.js | 2 +- scripts/android-e2e-test.js | 21 +- scripts/bump-oss-version.js | 22 +- scripts/compose-source-maps.js | 24 +- 260 files changed, 1751 insertions(+), 2143 deletions(-) diff --git a/IntegrationTests/AsyncStorageTest.js b/IntegrationTests/AsyncStorageTest.js index 51ce374556e..209a5e9b77f 100644 --- a/IntegrationTests/AsyncStorageTest.js +++ b/IntegrationTests/AsyncStorageTest.js @@ -218,11 +218,13 @@ class AsyncStorageTest extends React.Component<{...}, $FlowFixMeState> { return ( - {/* $FlowFixMe[incompatible-type] (>=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. - */ - this.constructor.displayName + ': '} + { + /* $FlowFixMe[incompatible-type] (>=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. + */ + this.constructor.displayName + ': ' + } {this.state.done ? 'Done' : 'Testing...'} {'\n\n' + this.state.messages} diff --git a/IntegrationTests/IntegrationTestHarnessTest.js b/IntegrationTests/IntegrationTestHarnessTest.js index 256bcd210e7..75c525abfbe 100644 --- a/IntegrationTests/IntegrationTestHarnessTest.js +++ b/IntegrationTests/IntegrationTestHarnessTest.js @@ -56,11 +56,13 @@ class IntegrationTestHarnessTest extends React.Component { return ( - {/* $FlowFixMe[incompatible-type] (>=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. - */ - this.constructor.displayName + ': '} + { + /* $FlowFixMe[incompatible-type] (>=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. + */ + this.constructor.displayName + ': ' + } {this.state.done ? 'Done' : 'Testing...'} diff --git a/IntegrationTests/IntegrationTestsApp.js b/IntegrationTests/IntegrationTestsApp.js index af41da151c4..a9af9b940b4 100644 --- a/IntegrationTests/IntegrationTestsApp.js +++ b/IntegrationTests/IntegrationTestsApp.js @@ -13,14 +13,8 @@ require('react-native/Libraries/Core/InitializeCore'); const React = require('react'); const ReactNative = require('react-native'); -const { - AppRegistry, - ScrollView, - StyleSheet, - Text, - TouchableOpacity, - View, -} = ReactNative; +const {AppRegistry, ScrollView, StyleSheet, Text, TouchableOpacity, View} = + ReactNative; // Keep this list in sync with RNTesterIntegrationTests.m const TESTS = [ diff --git a/IntegrationTests/LoggingTestModule.js b/IntegrationTests/LoggingTestModule.js index dc1dfb8ac03..70df6c33320 100644 --- a/IntegrationTests/LoggingTestModule.js +++ b/IntegrationTests/LoggingTestModule.js @@ -14,24 +14,24 @@ const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridg 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) { console.warn(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 2466b637858..4df83a0752d 100644 --- a/IntegrationTests/RCTRootViewIntegrationTestApp.js +++ b/IntegrationTests/RCTRootViewIntegrationTestApp.js @@ -12,14 +12,8 @@ const React = require('react'); const ReactNative = require('react-native'); -const { - AppRegistry, - ScrollView, - StyleSheet, - Text, - TouchableOpacity, - View, -} = ReactNative; +const {AppRegistry, ScrollView, StyleSheet, Text, TouchableOpacity, View} = + ReactNative; /* Keep this list in sync with RCTRootViewIntegrationTests.m */ const TESTS = [ diff --git a/IntegrationTests/WebSocketTest.js b/IntegrationTests/WebSocketTest.js index 3435feabb11..d361ede9f63 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; diff --git a/Libraries/Alert/Alert.js b/Libraries/Alert/Alert.js index 02a7a312e5b..091ff74ab65 100644 --- a/Libraries/Alert/Alert.js +++ b/Libraries/Alert/Alert.js @@ -46,8 +46,8 @@ class Alert { if (Platform.OS === 'ios') { Alert.prompt(title, message, buttons, 'default'); } else if (Platform.OS === 'android') { - const NativeDialogManagerAndroid = require('../NativeModules/specs/NativeDialogManagerAndroid') - .default; + const NativeDialogManagerAndroid = + require('../NativeModules/specs/NativeDialogManagerAndroid').default; if (!NativeDialogManagerAndroid) { return; } diff --git a/Libraries/Alert/RCTAlertManager.android.js b/Libraries/Alert/RCTAlertManager.android.js index 366692bd906..72f0e1b1cce 100644 --- a/Libraries/Alert/RCTAlertManager.android.js +++ b/Libraries/Alert/RCTAlertManager.android.js @@ -12,7 +12,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/AnimatedImplementation.js b/Libraries/Animated/AnimatedImplementation.js index 706b87ea01e..2fdae2d1309 100644 --- a/Libraries/Animated/AnimatedImplementation.js +++ b/Libraries/Animated/AnimatedImplementation.js @@ -48,39 +48,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, @@ -88,7 +88,7 @@ const diffClamp = function( return new AnimatedDiffClamp(a, min, max); }; -const _combineCallbacks = function( +const _combineCallbacks = function ( callback: ?EndCallback, config: {...AnimationConfig, ...}, ) { @@ -102,7 +102,7 @@ const _combineCallbacks = function( } }; -const maybeVectorAnim = function( +const maybeVectorAnim = function ( value: AnimatedValue | AnimatedValueXY, config: Object, anim: (value: AnimatedValue, config: Object) => CompositeAnimation, @@ -126,11 +126,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, @@ -155,35 +155,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, @@ -209,35 +209,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, @@ -251,37 +251,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; @@ -304,13 +304,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(); @@ -319,13 +319,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; }, }; @@ -336,7 +336,7 @@ type ParallelConfig = { stopTogether?: boolean, ... }; -const parallel = function( +const parallel = function ( animations: Array, config?: ?ParallelConfig, ): CompositeAnimation { @@ -346,14 +346,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) { @@ -375,14 +375,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; @@ -390,13 +390,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; }, }; @@ -404,7 +404,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, @@ -414,7 +414,7 @@ const delay = function(time: number): CompositeAnimation { }); }; -const stagger = function( +const stagger = function ( time: number, animations: Array, ): CompositeAnimation { @@ -431,15 +431,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 || @@ -463,24 +463,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(); }, }; @@ -512,7 +512,7 @@ function unforkEvent( } } -const event = function( +const event = function ( argMapping: $ReadOnlyArray, config: EventConfig, ): any { diff --git a/Libraries/Animated/AnimatedMock.js b/Libraries/Animated/AnimatedMock.js index 561f4b5a875..8f69819310f 100644 --- a/Libraries/Animated/AnimatedMock.js +++ b/Libraries/Animated/AnimatedMock.js @@ -88,7 +88,7 @@ const mockCompositeAnimation = ( }), }); -const spring = function( +const spring = function ( value: AnimatedValue | AnimatedValueXY, config: SpringAnimationConfig, ): CompositeAnimation { @@ -102,7 +102,7 @@ const spring = function( }; }; -const timing = function( +const timing = function ( value: AnimatedValue | AnimatedValueXY, config: TimingAnimationConfig, ): CompositeAnimation { @@ -116,32 +116,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 mockCompositeAnimation(animations); }; type ParallelConfig = {stopTogether?: boolean, ...}; -const parallel = function( +const parallel = function ( animations: Array, config?: ?ParallelConfig, ): CompositeAnimation { return mockCompositeAnimation(animations); }; -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 { @@ -154,7 +154,7 @@ type LoopAnimationConfig = { ... }; -const loop = function( +const loop = function ( animation: CompositeAnimation, {iterations = -1}: LoopAnimationConfig = {}, ): CompositeAnimation { diff --git a/Libraries/Animated/NativeAnimatedHelper.js b/Libraries/Animated/NativeAnimatedHelper.js index 89fe7b5a8d2..dff0f541d08 100644 --- a/Libraries/Animated/NativeAnimatedHelper.js +++ b/Libraries/Animated/NativeAnimatedHelper.js @@ -42,7 +42,7 @@ let queue: Array<() => void> = []; * the native module methods */ const API = { - getValue: function( + getValue: function ( tag: number, saveValueCallback: (value: number) => void, ): void { @@ -51,11 +51,11 @@ const API = { NativeAnimatedModule.getValue(tag, saveValueCallback); }); }, - setWaitingForIdentifier: function(id: string): void { + setWaitingForIdentifier: function (id: string): void { waitingForQueuedOperations.add(id); queueOperations = true; }, - unsetWaitingForIdentifier: function(id: string): void { + unsetWaitingForIdentifier: function (id: string): void { waitingForQueuedOperations.delete(id); if (waitingForQueuedOperations.size === 0) { @@ -63,7 +63,7 @@ const API = { API.disableQueue(); } }, - disableQueue: function(): void { + disableQueue: function (): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); if (Platform.OS === 'android') { @@ -84,37 +84,40 @@ const API = { fn(); } }, - createAnimatedNode: function(tag: number, config: AnimatedNodeConfig): void { + createAnimatedNode: function (tag: number, config: AnimatedNodeConfig): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); API.queueOperation(() => NativeAnimatedModule.createAnimatedNode(tag, config), ); }, - startListeningToAnimatedNodeValue: function(tag: number) { + startListeningToAnimatedNodeValue: function (tag: number) { invariant(NativeAnimatedModule, 'Native animated module is not available'); API.queueOperation(() => NativeAnimatedModule.startListeningToAnimatedNodeValue(tag), ); }, - stopListeningToAnimatedNodeValue: function(tag: number) { + stopListeningToAnimatedNodeValue: function (tag: number) { invariant(NativeAnimatedModule, 'Native animated module is not available'); API.queueOperation(() => 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'); API.queueOperation(() => 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'); API.queueOperation(() => NativeAnimatedModule.disconnectAnimatedNodes(parentTag, childTag), ); }, - startAnimatingNode: function( + startAnimatingNode: function ( animationId: number, nodeTag: number, config: AnimatingNodeConfig, @@ -130,41 +133,41 @@ const API = { ), ); }, - stopAnimation: function(animationId: number) { + stopAnimation: function (animationId: number) { invariant(NativeAnimatedModule, 'Native animated module is not available'); API.queueOperation(() => 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'); API.queueOperation(() => 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'); API.queueOperation(() => NativeAnimatedModule.setAnimatedNodeOffset(nodeTag, offset), ); }, - flattenAnimatedNodeOffset: function(nodeTag: number): void { + flattenAnimatedNodeOffset: function (nodeTag: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); API.queueOperation(() => NativeAnimatedModule.flattenAnimatedNodeOffset(nodeTag), ); }, - extractAnimatedNodeOffset: function(nodeTag: number): void { + extractAnimatedNodeOffset: function (nodeTag: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); API.queueOperation(() => 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'); API.queueOperation(() => NativeAnimatedModule.connectAnimatedNodeToView(nodeTag, viewTag), ); }, - disconnectAnimatedNodeFromView: function( + disconnectAnimatedNodeFromView: function ( nodeTag: number, viewTag: number, ): void { @@ -173,7 +176,7 @@ const API = { 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) { @@ -182,11 +185,11 @@ const API = { ); } }, - dropAnimatedNode: function(tag: number): void { + dropAnimatedNode: function (tag: number): void { invariant(NativeAnimatedModule, 'Native animated module is not available'); API.queueOperation(() => NativeAnimatedModule.dropAnimatedNode(tag)); }, - addAnimatedEventToView: function( + addAnimatedEventToView: function ( viewTag: number, eventName: string, eventMapping: EventMapping, diff --git a/Libraries/Animated/__tests__/AnimatedNative-test.js b/Libraries/Animated/__tests__/AnimatedNative-test.js index a6655d83952..597aae9b6c4 100644 --- a/Libraries/Animated/__tests__/AnimatedNative-test.js +++ b/Libraries/Animated/__tests__/AnimatedNative-test.js @@ -382,15 +382,17 @@ describe('Native Animated', () => { expect.any(Number), {type: 'addition', input: expect.any(Array)}, ); - const additionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - call => call[1].type === 'addition', - ); + const additionCalls = + NativeAnimatedModule.createAnimatedNode.mock.calls.filter( + 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, - ); + const additionConnectionCalls = + NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( + call => call[1] === additionNodeTag, + ); expect(additionConnectionCalls.length).toBe(2); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( additionCall[1].input[0], @@ -424,15 +426,17 @@ describe('Native Animated', () => { expect.any(Number), {type: 'subtraction', input: expect.any(Array)}, ); - const subtractionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - call => call[1].type === 'subtraction', - ); + const subtractionCalls = + NativeAnimatedModule.createAnimatedNode.mock.calls.filter( + 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, - ); + const subtractionConnectionCalls = + NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( + call => call[1] === subtractionNodeTag, + ); expect(subtractionConnectionCalls.length).toBe(2); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( subtractionCall[1].input[0], @@ -466,15 +470,17 @@ describe('Native Animated', () => { expect.any(Number), {type: 'multiplication', input: expect.any(Array)}, ); - const multiplicationCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - call => call[1].type === 'multiplication', - ); + const multiplicationCalls = + NativeAnimatedModule.createAnimatedNode.mock.calls.filter( + 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, - ); + const multiplicationConnectionCalls = + NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( + call => call[1] === multiplicationNodeTag, + ); expect(multiplicationConnectionCalls.length).toBe(2); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( multiplicationCall[1].input[0], @@ -508,15 +514,17 @@ describe('Native Animated', () => { expect.any(Number), {type: 'division', input: expect.any(Array)}, ); - const divisionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - call => call[1].type === 'division', - ); + const divisionCalls = + NativeAnimatedModule.createAnimatedNode.mock.calls.filter( + 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, - ); + const divisionConnectionCalls = + NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( + call => call[1] === divisionNodeTag, + ); expect(divisionConnectionCalls.length).toBe(2); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( divisionCall[1].input[0], @@ -548,15 +556,17 @@ describe('Native Animated', () => { expect.any(Number), {type: 'modulus', modulus: 4, input: expect.any(Number)}, ); - const moduloCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - call => call[1].type === 'modulus', - ); + const moduloCalls = + NativeAnimatedModule.createAnimatedNode.mock.calls.filter( + 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, - ); + const moduloConnectionCalls = + NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( + call => call[1] === moduloNodeTag, + ); expect(moduloConnectionCalls.length).toBe(1); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( moduloCall[1].input, @@ -597,12 +607,14 @@ describe('Native Animated', () => { extrapolateRight: 'extend', }, ); - const interpolationNodeTag = NativeAnimatedModule.createAnimatedNode.mock.calls.find( - call => call[1].type === 'interpolation', - )[0]; - const valueNodeTag = NativeAnimatedModule.createAnimatedNode.mock.calls.find( - call => call[1].type === 'value', - )[0]; + const interpolationNodeTag = + NativeAnimatedModule.createAnimatedNode.mock.calls.find( + call => call[1].type === 'interpolation', + )[0]; + const valueNodeTag = + NativeAnimatedModule.createAnimatedNode.mock.calls.find( + call => call[1].type === 'value', + )[0]; expect(NativeAnimatedModule.connectAnimatedNodes).toBeCalledWith( valueNodeTag, interpolationNodeTag, @@ -649,15 +661,17 @@ describe('Native Animated', () => { expect.any(Number), {type: 'diffclamp', input: expect.any(Number), max: 20, min: 0}, ); - const diffClampCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter( - call => call[1].type === 'diffclamp', - ); + const diffClampCalls = + NativeAnimatedModule.createAnimatedNode.mock.calls.filter( + 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, - ); + const diffClampConnectionCalls = + NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter( + call => call[1] === diffClampNodeTag, + ); expect(diffClampConnectionCalls.length).toBe(1); expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith( diffClampCall[1].input, diff --git a/Libraries/Animated/__tests__/Easing-test.js b/Libraries/Animated/__tests__/Easing-test.js index 409b1a7c3a8..a478919587c 100644 --- a/Libraries/Animated/__tests__/Easing-test.js +++ b/Libraries/Animated/__tests__/Easing-test.js @@ -91,366 +91,145 @@ describe('Easing', () => { const Samples = { in_quad: [ - 0, - 0.0030864197530864196, - 0.012345679012345678, - 0.027777777777777776, - 0.04938271604938271, - 0.0771604938271605, - 0.1111111111111111, - 0.15123456790123457, - 0.19753086419753085, - 0.25, - 0.308641975308642, - 0.37345679012345684, - 0.4444444444444444, - 0.5216049382716049, - 0.6049382716049383, - 0.6944444444444445, - 0.7901234567901234, - 0.8919753086419753, - 1, + 0, 0.0030864197530864196, 0.012345679012345678, 0.027777777777777776, + 0.04938271604938271, 0.0771604938271605, 0.1111111111111111, + 0.15123456790123457, 0.19753086419753085, 0.25, 0.308641975308642, + 0.37345679012345684, 0.4444444444444444, 0.5216049382716049, + 0.6049382716049383, 0.6944444444444445, 0.7901234567901234, + 0.8919753086419753, 1, ], out_quad: [ - 0, - 0.10802469135802469, - 0.20987654320987653, - 0.3055555555555555, - 0.3950617283950617, - 0.47839506172839513, - 0.5555555555555556, - 0.6265432098765432, - 0.691358024691358, - 0.75, - 0.8024691358024691, - 0.8487654320987654, - 0.888888888888889, - 0.9228395061728394, - 0.9506172839506174, - 0.9722222222222221, - 0.9876543209876543, - 0.9969135802469136, - 1, + 0, 0.10802469135802469, 0.20987654320987653, 0.3055555555555555, + 0.3950617283950617, 0.47839506172839513, 0.5555555555555556, + 0.6265432098765432, 0.691358024691358, 0.75, 0.8024691358024691, + 0.8487654320987654, 0.888888888888889, 0.9228395061728394, + 0.9506172839506174, 0.9722222222222221, 0.9876543209876543, + 0.9969135802469136, 1, ], inOut_quad: [ - 0, - 0.006172839506172839, - 0.024691358024691357, - 0.05555555555555555, - 0.09876543209876543, - 0.154320987654321, - 0.2222222222222222, - 0.30246913580246915, - 0.3950617283950617, - 0.5, - 0.6049382716049383, - 0.697530864197531, - 0.7777777777777777, - 0.845679012345679, - 0.9012345679012346, - 0.9444444444444444, - 0.9753086419753086, - 0.9938271604938271, - 1, + 0, 0.006172839506172839, 0.024691358024691357, 0.05555555555555555, + 0.09876543209876543, 0.154320987654321, 0.2222222222222222, + 0.30246913580246915, 0.3950617283950617, 0.5, 0.6049382716049383, + 0.697530864197531, 0.7777777777777777, 0.845679012345679, + 0.9012345679012346, 0.9444444444444444, 0.9753086419753086, + 0.9938271604938271, 1, ], in_cubic: [ - 0, - 0.00017146776406035664, - 0.0013717421124828531, - 0.004629629629629629, - 0.010973936899862825, - 0.021433470507544586, - 0.037037037037037035, - 0.05881344307270234, - 0.0877914951989026, - 0.125, - 0.1714677640603567, - 0.22822359396433475, - 0.2962962962962963, - 0.37671467764060357, - 0.4705075445816187, - 0.5787037037037038, - 0.7023319615912208, - 0.8424211248285322, - 1, + 0, 0.00017146776406035664, 0.0013717421124828531, 0.004629629629629629, + 0.010973936899862825, 0.021433470507544586, 0.037037037037037035, + 0.05881344307270234, 0.0877914951989026, 0.125, 0.1714677640603567, + 0.22822359396433475, 0.2962962962962963, 0.37671467764060357, + 0.4705075445816187, 0.5787037037037038, 0.7023319615912208, + 0.8424211248285322, 1, ], out_cubic: [ - 0, - 0.15757887517146785, - 0.2976680384087792, - 0.42129629629629617, - 0.5294924554183813, - 0.6232853223593964, - 0.7037037037037036, - 0.7717764060356652, - 0.8285322359396433, - 0.875, - 0.9122085048010974, - 0.9411865569272977, - 0.9629629629629629, - 0.9785665294924554, - 0.9890260631001372, - 0.9953703703703703, - 0.9986282578875172, - 0.9998285322359396, - 1, + 0, 0.15757887517146785, 0.2976680384087792, 0.42129629629629617, + 0.5294924554183813, 0.6232853223593964, 0.7037037037037036, + 0.7717764060356652, 0.8285322359396433, 0.875, 0.9122085048010974, + 0.9411865569272977, 0.9629629629629629, 0.9785665294924554, + 0.9890260631001372, 0.9953703703703703, 0.9986282578875172, + 0.9998285322359396, 1, ], inOut_cubic: [ - 0, - 0.0006858710562414266, - 0.0054869684499314125, - 0.018518518518518517, - 0.0438957475994513, - 0.08573388203017834, - 0.14814814814814814, - 0.23525377229080935, - 0.3511659807956104, - 0.5, - 0.6488340192043895, - 0.7647462277091908, - 0.8518518518518519, - 0.9142661179698217, - 0.9561042524005487, - 0.9814814814814815, - 0.9945130315500685, - 0.9993141289437586, - 1, + 0, 0.0006858710562414266, 0.0054869684499314125, 0.018518518518518517, + 0.0438957475994513, 0.08573388203017834, 0.14814814814814814, + 0.23525377229080935, 0.3511659807956104, 0.5, 0.6488340192043895, + 0.7647462277091908, 0.8518518518518519, 0.9142661179698217, + 0.9561042524005487, 0.9814814814814815, 0.9945130315500685, + 0.9993141289437586, 1, ], in_sin: [ - 0, - 0.003805301908254455, - 0.01519224698779198, - 0.03407417371093169, - 0.06030737921409157, - 0.09369221296335006, - 0.1339745962155613, - 0.1808479557110082, - 0.233955556881022, - 0.2928932188134524, - 0.35721239031346064, - 0.42642356364895384, - 0.4999999999999999, - 0.5773817382593005, - 0.6579798566743311, - 0.7411809548974793, - 0.8263518223330696, - 0.9128442572523416, - 0.9999999999999999, + 0, 0.003805301908254455, 0.01519224698779198, 0.03407417371093169, + 0.06030737921409157, 0.09369221296335006, 0.1339745962155613, + 0.1808479557110082, 0.233955556881022, 0.2928932188134524, + 0.35721239031346064, 0.42642356364895384, 0.4999999999999999, + 0.5773817382593005, 0.6579798566743311, 0.7411809548974793, + 0.8263518223330696, 0.9128442572523416, 0.9999999999999999, ], out_sin: [ - 0, - 0.08715574274765817, - 0.17364817766693033, - 0.25881904510252074, - 0.3420201433256687, - 0.42261826174069944, - 0.49999999999999994, - 0.573576436351046, - 0.6427876096865393, - 0.7071067811865475, - 0.766044443118978, - 0.8191520442889918, - 0.8660254037844386, - 0.9063077870366499, - 0.9396926207859083, - 0.9659258262890683, - 0.984807753012208, - 0.9961946980917455, - 1, + 0, 0.08715574274765817, 0.17364817766693033, 0.25881904510252074, + 0.3420201433256687, 0.42261826174069944, 0.49999999999999994, + 0.573576436351046, 0.6427876096865393, 0.7071067811865475, + 0.766044443118978, 0.8191520442889918, 0.8660254037844386, + 0.9063077870366499, 0.9396926207859083, 0.9659258262890683, + 0.984807753012208, 0.9961946980917455, 1, ], inOut_sin: [ - 0, - 0.00759612349389599, - 0.030153689607045786, - 0.06698729810778065, - 0.116977778440511, - 0.17860619515673032, - 0.24999999999999994, - 0.32898992833716556, - 0.4131759111665348, - 0.49999999999999994, - 0.5868240888334652, - 0.6710100716628343, - 0.7499999999999999, - 0.8213938048432696, - 0.883022221559489, - 0.9330127018922194, - 0.9698463103929542, - 0.9924038765061041, - 1, + 0, 0.00759612349389599, 0.030153689607045786, 0.06698729810778065, + 0.116977778440511, 0.17860619515673032, 0.24999999999999994, + 0.32898992833716556, 0.4131759111665348, 0.49999999999999994, + 0.5868240888334652, 0.6710100716628343, 0.7499999999999999, + 0.8213938048432696, 0.883022221559489, 0.9330127018922194, + 0.9698463103929542, 0.9924038765061041, 1, ], in_exp: [ - 0, - 0.0014352875901128893, - 0.002109491677524035, - 0.0031003926796253885, - 0.004556754060844206, - 0.006697218616039631, - 0.009843133202303688, - 0.014466792379488908, - 0.021262343752724643, - 0.03125, - 0.045929202883612456, - 0.06750373368076916, - 0.09921256574801243, - 0.1458161299470146, - 0.2143109957132682, - 0.31498026247371835, - 0.46293735614364506, - 0.6803950000871883, - 1, + 0, 0.0014352875901128893, 0.002109491677524035, 0.0031003926796253885, + 0.004556754060844206, 0.006697218616039631, 0.009843133202303688, + 0.014466792379488908, 0.021262343752724643, 0.03125, 0.045929202883612456, + 0.06750373368076916, 0.09921256574801243, 0.1458161299470146, + 0.2143109957132682, 0.31498026247371835, 0.46293735614364506, + 0.6803950000871883, 1, ], out_exp: [ - 0, - 0.31960499991281155, - 0.5370626438563548, - 0.6850197375262816, - 0.7856890042867318, - 0.8541838700529854, - 0.9007874342519875, - 0.9324962663192309, - 0.9540707971163875, - 0.96875, - 0.9787376562472754, - 0.9855332076205111, - 0.9901568667976963, - 0.9933027813839603, - 0.9954432459391558, - 0.9968996073203746, - 0.9978905083224759, - 0.9985647124098871, - 1, + 0, 0.31960499991281155, 0.5370626438563548, 0.6850197375262816, + 0.7856890042867318, 0.8541838700529854, 0.9007874342519875, + 0.9324962663192309, 0.9540707971163875, 0.96875, 0.9787376562472754, + 0.9855332076205111, 0.9901568667976963, 0.9933027813839603, + 0.9954432459391558, 0.9968996073203746, 0.9978905083224759, + 0.9985647124098871, 1, ], inOut_exp: [ - 0, - 0.0010547458387620175, - 0.002278377030422103, - 0.004921566601151844, - 0.010631171876362321, - 0.022964601441806228, - 0.049606282874006216, - 0.1071554978566341, - 0.23146867807182253, - 0.5, - 0.7685313219281775, - 0.892844502143366, - 0.9503937171259937, - 0.9770353985581938, - 0.9893688281236377, - 0.9950784333988482, - 0.9977216229695779, - 0.998945254161238, - 1, + 0, 0.0010547458387620175, 0.002278377030422103, 0.004921566601151844, + 0.010631171876362321, 0.022964601441806228, 0.049606282874006216, + 0.1071554978566341, 0.23146867807182253, 0.5, 0.7685313219281775, + 0.892844502143366, 0.9503937171259937, 0.9770353985581938, + 0.9893688281236377, 0.9950784333988482, 0.9977216229695779, + 0.998945254161238, 1, ], in_circle: [ - 0, - 0.0015444024660317135, - 0.006192010000093506, - 0.013986702816730645, - 0.025003956956430873, - 0.03935464078941209, - 0.057190958417936644, - 0.07871533601238889, - 0.10419358352238339, - 0.1339745962155614, - 0.1685205807169019, - 0.20845517506805522, - 0.2546440075000701, - 0.3083389112228482, - 0.37146063894529113, - 0.4472292016074334, - 0.5418771527091488, - 0.6713289009389102, - 1, + 0, 0.0015444024660317135, 0.006192010000093506, 0.013986702816730645, + 0.025003956956430873, 0.03935464078941209, 0.057190958417936644, + 0.07871533601238889, 0.10419358352238339, 0.1339745962155614, + 0.1685205807169019, 0.20845517506805522, 0.2546440075000701, + 0.3083389112228482, 0.37146063894529113, 0.4472292016074334, + 0.5418771527091488, 0.6713289009389102, 1, ], out_circle: [ - 0, - 0.3286710990610898, - 0.45812284729085123, - 0.5527707983925666, - 0.6285393610547089, - 0.6916610887771518, - 0.7453559924999298, - 0.7915448249319448, - 0.8314794192830981, - 0.8660254037844386, - 0.8958064164776166, - 0.9212846639876111, - 0.9428090415820634, - 0.9606453592105879, - 0.9749960430435691, - 0.9860132971832694, - 0.9938079899999065, - 0.9984555975339683, - 1, + 0, 0.3286710990610898, 0.45812284729085123, 0.5527707983925666, + 0.6285393610547089, 0.6916610887771518, 0.7453559924999298, + 0.7915448249319448, 0.8314794192830981, 0.8660254037844386, + 0.8958064164776166, 0.9212846639876111, 0.9428090415820634, + 0.9606453592105879, 0.9749960430435691, 0.9860132971832694, + 0.9938079899999065, 0.9984555975339683, 1, ], inOut_circle: [ - 0, - 0.003096005000046753, - 0.012501978478215436, - 0.028595479208968322, - 0.052096791761191696, - 0.08426029035845095, - 0.12732200375003505, - 0.18573031947264557, - 0.2709385763545744, - 0.5, - 0.7290614236454256, - 0.8142696805273546, - 0.8726779962499649, - 0.915739709641549, - 0.9479032082388084, - 0.9714045207910317, - 0.9874980215217846, - 0.9969039949999532, - 1, + 0, 0.003096005000046753, 0.012501978478215436, 0.028595479208968322, + 0.052096791761191696, 0.08426029035845095, 0.12732200375003505, + 0.18573031947264557, 0.2709385763545744, 0.5, 0.7290614236454256, + 0.8142696805273546, 0.8726779962499649, 0.915739709641549, + 0.9479032082388084, 0.9714045207910317, 0.9874980215217846, + 0.9969039949999532, 1, ], in_back_: [ - 0, - -0.004788556241426612, - -0.017301289437585736, - -0.0347587962962963, - -0.05438167352537723, - -0.07339051783264748, - -0.08900592592592595, - -0.09844849451303156, - -0.0989388203017833, - -0.08769750000000004, - -0.06194513031550073, - -0.018902307956104283, - 0.044210370370370254, - 0.13017230795610413, - 0.2417629080932785, - 0.3817615740740742, - 0.5529477091906719, - 0.7581007167352535, - 0.9999999999999998, + 0, -0.004788556241426612, -0.017301289437585736, -0.0347587962962963, + -0.05438167352537723, -0.07339051783264748, -0.08900592592592595, + -0.09844849451303156, -0.0989388203017833, -0.08769750000000004, + -0.06194513031550073, -0.018902307956104283, 0.044210370370370254, + 0.13017230795610413, 0.2417629080932785, 0.3817615740740742, + 0.5529477091906719, 0.7581007167352535, 0.9999999999999998, ], out_back_: [ - 2.220446049250313e-16, - 0.24189928326474652, - 0.44705229080932807, - 0.6182384259259258, - 0.7582370919067215, - 0.8698276920438959, - 0.9557896296296297, - 1.0189023079561044, - 1.0619451303155008, - 1.0876975, - 1.0989388203017834, - 1.0984484945130315, - 1.089005925925926, - 1.0733905178326475, - 1.0543816735253773, - 1.0347587962962963, - 1.0173012894375857, - 1.0047885562414267, - 1, + 2.220446049250313e-16, 0.24189928326474652, 0.44705229080932807, + 0.6182384259259258, 0.7582370919067215, 0.8698276920438959, + 0.9557896296296297, 1.0189023079561044, 1.0619451303155008, 1.0876975, + 1.0989388203017834, 1.0984484945130315, 1.089005925925926, + 1.0733905178326475, 1.0543816735253773, 1.0347587962962963, + 1.0173012894375857, 1.0047885562414267, 1, ], }; - 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/__tests__/bezier-test.js b/Libraries/Animated/__tests__/bezier-test.js index e7be582a524..846edc12828 100644 --- a/Libraries/Animated/__tests__/bezier-test.js +++ b/Libraries/Animated/__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/nodes/AnimatedNode.js b/Libraries/Animated/nodes/AnimatedNode.js index 7371d49fd5b..082f42e5103 100644 --- a/Libraries/Animated/nodes/AnimatedNode.js +++ b/Libraries/Animated/nodes/AnimatedNode.js @@ -119,15 +119,16 @@ class AnimatedNode { } NativeAnimatedAPI.startListeningToAnimatedNodeValue(this.__getNativeTag()); - this.__nativeAnimatedValueListener = NativeAnimatedHelper.nativeEventEmitter.addListener( - 'onAnimatedValueUpdate', - data => { - if (data.tag !== this.__getNativeTag()) { - return; - } - this._onAnimatedValueUpdateReceived(data.value); - }, - ); + this.__nativeAnimatedValueListener = + NativeAnimatedHelper.nativeEventEmitter.addListener( + 'onAnimatedValueUpdate', + data => { + if (data.tag !== this.__getNativeTag()) { + return; + } + this._onAnimatedValueUpdateReceived(data.value); + }, + ); } _onAnimatedValueUpdateReceived(value: number) { diff --git a/Libraries/Animated/nodes/AnimatedValueXY.js b/Libraries/Animated/nodes/AnimatedValueXY.js index 28d3395db8a..4c0f9e86404 100644 --- a/Libraries/Animated/nodes/AnimatedValueXY.js +++ b/Libraries/Animated/nodes/AnimatedValueXY.js @@ -38,7 +38,7 @@ class AnimatedValueXY extends AnimatedWithChildren { y: string, ... }, - ..., + ... }; constructor( diff --git a/Libraries/AppState/AppState.js b/Libraries/AppState/AppState.js index 303c97ed28e..191ab4b28f2 100644 --- a/Libraries/AppState/AppState.js +++ b/Libraries/AppState/AppState.js @@ -47,11 +47,12 @@ class AppState { } else { this.isAvailable = true; - const emitter: NativeEventEmitter = new NativeEventEmitter( - // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior - // If you want to use the native module on other platforms, please remove this condition and test its behavior - Platform.OS !== 'ios' ? null : NativeAppState, - ); + const emitter: NativeEventEmitter = + new NativeEventEmitter( + // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior + // If you want to use the native module on other platforms, please remove this condition and test its behavior + Platform.OS !== 'ios' ? null : NativeAppState, + ); this._emitter = emitter; this.currentState = NativeAppState.getConstants().initialAppState; diff --git a/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js b/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js index 667799a42f4..d0e5477822e 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 9c63238d8a0..031192793de 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'); @@ -141,7 +141,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); @@ -153,7 +153,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 bedff6127d9..35f1c43764a 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/__tests__/Blob-test.js b/Libraries/Blob/__tests__/Blob-test.js index 42aea6f05e5..0ec3d8904d8 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 e711e68f956..bc788cdbf61 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 eefbe2864ed..ee097235e22 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 4e73df3c569..3ccf4924242 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 713ceeea0ef..fa7e234385e 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.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js index ed2c4a3644e..a388a6d618f 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js @@ -44,24 +44,26 @@ type AccessibilityEventDefinitions = { type AccessibilityEventTypes = 'click' | 'focus'; // Mapping of public event names to platform-specific event names. -const EventNames: Map<$Keys, string> = - Platform.OS === 'android' - ? new Map([ - ['change', 'touchExplorationDidChange'], - ['reduceMotionChanged', 'reduceMotionDidChange'], - ['screenReaderChanged', 'touchExplorationDidChange'], - ['accessibilityServiceChanged', 'accessibilityServiceDidChange'], - ]) - : new Map([ - ['announcementFinished', 'announcementFinished'], - ['boldTextChanged', 'boldTextChanged'], - ['change', 'screenReaderChanged'], - ['grayscaleChanged', 'grayscaleChanged'], - ['invertColorsChanged', 'invertColorsChanged'], - ['reduceMotionChanged', 'reduceMotionChanged'], - ['reduceTransparencyChanged', 'reduceTransparencyChanged'], - ['screenReaderChanged', 'screenReaderChanged'], - ]); +const EventNames: Map< + $Keys, + string, +> = Platform.OS === 'android' + ? new Map([ + ['change', 'touchExplorationDidChange'], + ['reduceMotionChanged', 'reduceMotionDidChange'], + ['screenReaderChanged', 'touchExplorationDidChange'], + ['accessibilityServiceChanged', 'accessibilityServiceDidChange'], + ]) + : new Map([ + ['announcementFinished', 'announcementFinished'], + ['boldTextChanged', 'boldTextChanged'], + ['change', 'screenReaderChanged'], + ['grayscaleChanged', 'grayscaleChanged'], + ['invertColorsChanged', 'invertColorsChanged'], + ['reduceMotionChanged', 'reduceMotionChanged'], + ['reduceTransparencyChanged', 'reduceTransparencyChanged'], + ['screenReaderChanged', 'screenReaderChanged'], + ]); /** * Sometimes it's useful to know whether or not the device has a screen reader diff --git a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index 9c7b9154bbc..2e82e12dce7 100644 --- a/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -162,9 +162,10 @@ class DrawerLayoutAndroid extends React.Component { return {Left: 'left', Right: 'right'}; } - _nativeRef = React.createRef< - React.ElementRef, - >(); + _nativeRef = + React.createRef< + React.ElementRef, + >(); state: State = {statusBarBackgroundColor: null}; diff --git a/Libraries/Components/Keyboard/Keyboard.js b/Libraries/Components/Keyboard/Keyboard.js index fec163cd284..c357aeb3767 100644 --- a/Libraries/Components/Keyboard/Keyboard.js +++ b/Libraries/Components/Keyboard/Keyboard.js @@ -103,11 +103,12 @@ type KeyboardEventDefinitions = { */ class Keyboard { - _emitter: NativeEventEmitter = new NativeEventEmitter( - // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior - // If you want to use the native module on other platforms, please remove this condition and test its behavior - Platform.OS !== 'ios' ? null : NativeKeyboardObserver, - ); + _emitter: NativeEventEmitter = + new NativeEventEmitter( + // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior + // If you want to use the native module on other platforms, please remove this condition and test its behavior + Platform.OS !== 'ios' ? null : NativeKeyboardObserver, + ); /** * The `addListener` function connects a JavaScript function to an identified native diff --git a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js index d465440d174..de2068068dd 100644 --- a/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js +++ b/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js @@ -71,4 +71,5 @@ const styles = StyleSheet.create({ const ProgressViewIOSWithRef = React.forwardRef(ProgressViewIOS); -module.exports = (ProgressViewIOSWithRef: typeof RCTProgressViewNativeComponent); +module.exports = + (ProgressViewIOSWithRef: typeof RCTProgressViewNativeComponent); diff --git a/Libraries/Components/RefreshControl/RefreshControl.js b/Libraries/Components/RefreshControl/RefreshControl.js index 0f0a16dbbcc..d04e01b53f6 100644 --- a/Libraries/Components/RefreshControl/RefreshControl.js +++ b/Libraries/Components/RefreshControl/RefreshControl.js @@ -158,13 +158,8 @@ class RefreshControl extends React.Component { render(): React.Node { if (Platform.OS === 'ios') { - const { - enabled, - colors, - progressBackgroundColor, - size, - ...props - } = this.props; + const {enabled, colors, progressBackgroundColor, size, ...props} = + this.props; return ( = requireNativeComponent( - 'RCTRefreshControl', -); +const RCTRefreshControl: HostComponent = + requireNativeComponent('RCTRefreshControl'); class RefreshControlMock extends React.Component<{...}> { static latestRef: ?RefreshControlMock; diff --git a/Libraries/Components/SafeAreaView/SafeAreaView.js b/Libraries/Components/SafeAreaView/SafeAreaView.js index 2e6e0e74c7c..b71aac24e62 100644 --- a/Libraries/Components/SafeAreaView/SafeAreaView.js +++ b/Libraries/Components/SafeAreaView/SafeAreaView.js @@ -42,8 +42,8 @@ if (Platform.OS === 'android') { }, ); } else { - const RCTSafeAreaViewNativeComponent = require('./RCTSafeAreaViewNativeComponent') - .default; + const RCTSafeAreaViewNativeComponent = + require('./RCTSafeAreaViewNativeComponent').default; exported = React.forwardRef>>( function SafeAreaView(props, forwardedRef) { diff --git a/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js index 9ba0b235f2e..343b63d4b4c 100644 --- a/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +++ b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js @@ -12,9 +12,8 @@ import type {ScrollViewNativeProps as Props} from './ScrollViewNativeComponentTy import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; -const AndroidHorizontalScrollViewNativeComponent: HostComponent = NativeComponentRegistry.get( - 'AndroidHorizontalScrollView', - () => ({ +const AndroidHorizontalScrollViewNativeComponent: HostComponent = + NativeComponentRegistry.get('AndroidHorizontalScrollView', () => ({ uiViewClassName: 'AndroidHorizontalScrollView', bubblingEventTypes: {}, directEventTypes: {}, @@ -38,7 +37,6 @@ const AndroidHorizontalScrollViewNativeComponent: HostComponent = NativeC snapToOffsets: true, contentOffset: true, }, - }), -); + })); export default AndroidHorizontalScrollViewNativeComponent; diff --git a/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js b/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js index 4e3174044df..afd3557ecd1 100644 --- a/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js +++ b/Libraries/Components/ScrollView/ScrollContentViewNativeComponent.js @@ -12,14 +12,12 @@ import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; import type {ViewProps as Props} from '../View/ViewPropTypes'; -const ScrollContentViewNativeComponent: HostComponent = NativeComponentRegistry.get( - 'RCTScrollContentView', - () => ({ +const ScrollContentViewNativeComponent: HostComponent = + NativeComponentRegistry.get('RCTScrollContentView', () => ({ uiViewClassName: 'RCTScrollContentView', bubblingEventTypes: {}, directEventTypes: {}, validAttributes: {}, - }), -); + })); export default ScrollContentViewNativeComponent; diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index b121da39eb4..87bec5b7629 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -721,10 +721,8 @@ class ScrollView extends React.Component { _scrollAnimatedValue: AnimatedImplementation.Value; _scrollAnimatedValueAttachment: ?{detach: () => void, ...} = null; - _stickyHeaderRefs: Map< - string, - React.ElementRef, - > = new Map(); + _stickyHeaderRefs: Map> = + new Map(); _headerLayoutYs: Map = new Map(); _keyboardWillOpenTo: ?KeyboardEvent = null; @@ -845,7 +843,8 @@ class ScrollView extends React.Component { ref.scrollToEnd = this.scrollToEnd; ref.flashScrollIndicators = this.flashScrollIndicators; ref.scrollResponderZoomTo = this.scrollResponderZoomTo; - ref.scrollResponderScrollNativeHandleToKeyboard = this.scrollResponderScrollNativeHandleToKeyboard; + ref.scrollResponderScrollNativeHandleToKeyboard = + this.scrollResponderScrollNativeHandleToKeyboard; } }, }); @@ -1115,11 +1114,12 @@ class ScrollView extends React.Component { this.props.stickyHeaderIndices && this.props.stickyHeaderIndices.length > 0 ) { - this._scrollAnimatedValueAttachment = AnimatedImplementation.attachNativeEvent( - this._scrollViewRef, - 'onScroll', - [{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}], - ); + this._scrollAnimatedValueAttachment = + AnimatedImplementation.attachNativeEvent( + this._scrollViewRef, + 'onScroll', + [{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}], + ); } } @@ -1721,8 +1721,8 @@ class ScrollView extends React.Component { onScrollEndDrag: this._handleScrollEndDrag, onScrollShouldSetResponder: this._handleScrollShouldSetResponder, onStartShouldSetResponder: this._handleStartShouldSetResponder, - onStartShouldSetResponderCapture: this - ._handleStartShouldSetResponderCapture, + onStartShouldSetResponderCapture: + this._handleStartShouldSetResponderCapture, onTouchEnd: this._handleTouchEnd, onTouchMove: this._handleTouchMove, onTouchStart: this._handleTouchStart, diff --git a/Libraries/Components/ScrollView/ScrollViewNativeComponent.js b/Libraries/Components/ScrollView/ScrollViewNativeComponent.js index cdfc8ff450f..ab6a5d3634b 100644 --- a/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +++ b/Libraries/Components/ScrollView/ScrollViewNativeComponent.js @@ -12,9 +12,8 @@ import type {ScrollViewNativeProps as Props} from './ScrollViewNativeComponentTy import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; -const ScrollViewNativeComponent: HostComponent = NativeComponentRegistry.get( - 'RCTScrollView', - () => ({ +const ScrollViewNativeComponent: HostComponent = + NativeComponentRegistry.get('RCTScrollView', () => ({ uiViewClassName: 'RCTScrollView', bubblingEventTypes: {}, directEventTypes: { @@ -80,7 +79,6 @@ const ScrollViewNativeComponent: HostComponent = NativeComponentRegistry. snapToStart: true, zoomScale: true, }, - }), -); + })); export default ScrollViewNativeComponent; diff --git a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js index 84770d7646b..1812a01018a 100644 --- a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js +++ b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js @@ -87,14 +87,8 @@ class SegmentedControlIOS extends React.Component { }; render() { - const { - enabled, - forwardedRef, - onValueChange, - style, - values, - ...props - } = this.props; + const {enabled, forwardedRef, onValueChange, style, values, ...props} = + this.props; return ( ({ supportedCommands: ['focus', 'blur', 'setTextAndSelection'], }); -const MultilineTextInputNativeComponent: HostComponent = NativeComponentRegistry.get( - 'RCTMultilineTextInputView', - () => RCTTextInputViewConfig, -); +const MultilineTextInputNativeComponent: HostComponent = + NativeComponentRegistry.get( + 'RCTMultilineTextInputView', + () => RCTTextInputViewConfig, + ); // flowlint-next-line unclear-type:off export default ((MultilineTextInputNativeComponent: any): HostComponent); diff --git a/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js b/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js index e9ac2bc9cc2..043451a1c8f 100644 --- a/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js @@ -22,10 +22,11 @@ export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: ['focus', 'blur', 'setTextAndSelection'], }); -const SinglelineTextInputNativeComponent: HostComponent = NativeComponentRegistry.get( - 'RCTSinglelineTextInputView', - () => RCTTextInputViewConfig, -); +const SinglelineTextInputNativeComponent: HostComponent = + NativeComponentRegistry.get( + 'RCTSinglelineTextInputView', + () => RCTTextInputViewConfig, + ); // flowlint-next-line unclear-type:off export default ((SinglelineTextInputNativeComponent: any): HostComponent); diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index e1c4a0ea34e..c88abc59838 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -46,17 +46,17 @@ let RCTMultilineTextInputNativeCommands; if (Platform.OS === 'android') { AndroidTextInput = require('./AndroidTextInputNativeComponent').default; - AndroidTextInputCommands = require('./AndroidTextInputNativeComponent') - .Commands; + AndroidTextInputCommands = + require('./AndroidTextInputNativeComponent').Commands; } else if (Platform.OS === 'ios') { - RCTSinglelineTextInputView = require('./RCTSingelineTextInputNativeComponent') - .default; - RCTSinglelineTextInputNativeCommands = require('./RCTSingelineTextInputNativeComponent') - .Commands; - RCTMultilineTextInputView = require('./RCTMultilineTextInputNativeComponent') - .default; - RCTMultilineTextInputNativeCommands = require('./RCTMultilineTextInputNativeComponent') - .Commands; + RCTSinglelineTextInputView = + require('./RCTSingelineTextInputNativeComponent').default; + RCTSinglelineTextInputNativeCommands = + require('./RCTSingelineTextInputNativeComponent').Commands; + RCTMultilineTextInputView = + require('./RCTMultilineTextInputNativeComponent').default; + RCTMultilineTextInputNativeCommands = + require('./RCTMultilineTextInputNativeComponent').Commands; } export type ChangeEvent = SyntheticEvent< @@ -1245,7 +1245,8 @@ const ExportedForwardRef: React.AbstractComponent< * Switch to `deprecated-react-native-prop-types` for compatibility with future * releases. This is deprecated and will be removed in the future. */ -ExportedForwardRef.propTypes = require('deprecated-react-native-prop-types').TextInputPropTypes; +ExportedForwardRef.propTypes = + require('deprecated-react-native-prop-types').TextInputPropTypes; // $FlowFixMe[prop-missing] ExportedForwardRef.State = { diff --git a/Libraries/Components/ToastAndroid/ToastAndroid.android.js b/Libraries/Components/ToastAndroid/ToastAndroid.android.js index b15100a1769..b29ec4ede71 100644 --- a/Libraries/Components/ToastAndroid/ToastAndroid.android.js +++ b/Libraries/Components/ToastAndroid/ToastAndroid.android.js @@ -42,11 +42,11 @@ const ToastAndroid = { BOTTOM: (ToastAndroidConstants.BOTTOM: number), CENTER: (ToastAndroidConstants.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, @@ -54,7 +54,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 611e50fe87b..01fa7998ae6 100644 --- a/Libraries/Components/ToastAndroid/ToastAndroid.ios.js +++ b/Libraries/Components/ToastAndroid/ToastAndroid.ios.js @@ -11,11 +11,11 @@ 'use strict'; const ToastAndroid = { - show: function(message: string, duration: number): void { + show: function (message: string, duration: number): void { console.warn('ToastAndroid is not supported on this platform.'); }, - showWithGravity: function( + showWithGravity: function ( message: string, duration: number, gravity: number, @@ -23,7 +23,7 @@ const ToastAndroid = { console.warn('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 114b950733d..5aa45dba22b 100644 --- a/Libraries/Components/Touchable/BoundingDimensions.js +++ b/Libraries/Components/Touchable/BoundingDimensions.js @@ -24,7 +24,7 @@ function BoundingDimensions(width, height) { this.height = height; } -BoundingDimensions.prototype.destructor = function() { +BoundingDimensions.prototype.destructor = function () { this.width = null; this.height = null; }; @@ -33,7 +33,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 1c9e940bd53..73e104e75ee 100644 --- a/Libraries/Components/Touchable/PooledClass.js +++ b/Libraries/Components/Touchable/PooledClass.js @@ -18,7 +18,7 @@ import invariant from '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(); @@ -29,7 +29,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(); @@ -40,7 +40,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(); @@ -51,7 +51,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(); @@ -62,7 +62,7 @@ const fourArgumentPooler = function(a1, a2, a3, a4) { } }; -const standardReleaser = function(instance) { +const standardReleaser = function (instance) { const Klass = this; invariant( instance instanceof Klass, @@ -88,7 +88,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 5656bf9aaab..dd06e5288d1 100644 --- a/Libraries/Components/Touchable/Position.js +++ b/Libraries/Components/Touchable/Position.js @@ -25,7 +25,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 f59ba3ad495..972bc11ed91 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -361,7 +361,7 @@ const LONG_PRESS_ALLOWED_MOVEMENT = 10; * @lends Touchable.prototype */ const TouchableMixin = { - componentDidMount: function() { + componentDidMount: function () { if (!Platform.isTV) { return; } @@ -370,7 +370,7 @@ const TouchableMixin = { /** * Clear all timeouts on unmount */ - componentWillUnmount: function() { + componentWillUnmount: function () { this.touchableDelayTimeout && clearTimeout(this.touchableDelayTimeout); this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout); this.pressOutDelayTimeout && clearTimeout(this.pressOutDelayTimeout); @@ -383,7 +383,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 { @@ -395,21 +395,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; }, @@ -418,7 +418,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 @@ -459,7 +459,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); }, @@ -467,7 +467,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); }, @@ -475,7 +475,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; @@ -560,7 +560,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); }, @@ -572,7 +572,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); }, @@ -652,7 +652,7 @@ const TouchableMixin = { * @sideeffects * @private */ - _remeasureMetricsOnActivation: function() { + _remeasureMetricsOnActivation: function () { const responderID = this.state.touchable.responderID; if (responderID == null) { return; @@ -665,7 +665,7 @@ const TouchableMixin = { } }, - _handleQueryLayout: function( + _handleQueryLayout: function ( l: number, t: number, w: number, @@ -691,12 +691,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 ( @@ -715,7 +715,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]; @@ -754,19 +754,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; @@ -775,7 +775,7 @@ const TouchableMixin = { this.pressInLocation = {pageX, pageY, locationX, locationY}; }, - _getDistanceBetweenPoints: function( + _getDistanceBetweenPoints: function ( aX: number, aY: number, bX: number, @@ -797,7 +797,7 @@ const TouchableMixin = { * @param {Event} e Native event. * @sideeffects */ - _performSideEffectsForTransition: function( + _performSideEffectsForTransition: function ( curState: State, nextState: State, signal: Signal, @@ -858,12 +858,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 && @@ -892,7 +892,8 @@ const { touchableHandleBlur, ...TouchableMixinWithoutDefaultFocusAndBlur } = TouchableMixin; -TouchableMixin.withoutDefaultFocusAndBlur = TouchableMixinWithoutDefaultFocusAndBlur; +TouchableMixin.withoutDefaultFocusAndBlur = + TouchableMixinWithoutDefaultFocusAndBlur; const Touchable = { Mixin: TouchableMixin, diff --git a/Libraries/Components/Touchable/TouchableBounce.js b/Libraries/Components/Touchable/TouchableBounce.js index 4bf9c201fc5..0a61b9a01fb 100644 --- a/Libraries/Components/Touchable/TouchableBounce.js +++ b/Libraries/Components/Touchable/TouchableBounce.js @@ -128,11 +128,8 @@ class TouchableBounce extends React.Component { render(): React.Node { // BACKWARD-COMPATIBILITY: Focus and blur events were never supported before // adopting `Pressability`, so preserve that behavior. - const { - onBlur, - onFocus, - ...eventHandlersWithoutBlurAndFocus - } = this.state.pressability.getEventHandlers(); + const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} = + this.state.pressability.getEventHandlers(); return ( { // BACKWARD-COMPATIBILITY: Focus and blur events were never supported before // adopting `Pressability`, so preserve that behavior. - const { - onBlur, - onFocus, - ...eventHandlersWithoutBlurAndFocus - } = this.state.pressability.getEventHandlers(); + const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} = + this.state.pressability.getEventHandlers(); const accessibilityState = this.props.disabled != null diff --git a/Libraries/Components/Touchable/TouchableNativeFeedback.js b/Libraries/Components/Touchable/TouchableNativeFeedback.js index 6132f0a6c25..78a6abb90b4 100644 --- a/Libraries/Components/Touchable/TouchableNativeFeedback.js +++ b/Libraries/Components/Touchable/TouchableNativeFeedback.js @@ -99,9 +99,7 @@ class TouchableNativeFeedback extends React.Component { * Creates a value for the `background` prop that uses the Android theme's * default background for selectable elements. */ - static SelectableBackground: ( - rippleRadius: ?number, - ) => $ReadOnly<{| + static SelectableBackground: (rippleRadius: ?number) => $ReadOnly<{| attribute: 'selectableItemBackground', type: 'ThemeAttrAndroid', rippleRadius: ?number, @@ -115,9 +113,7 @@ class TouchableNativeFeedback extends React.Component { * Creates a value for the `background` prop that uses the Android theme's * default background for borderless selectable elements. Requires API 21+. */ - static SelectableBackgroundBorderless: ( - rippleRadius: ?number, - ) => $ReadOnly<{| + static SelectableBackgroundBorderless: (rippleRadius: ?number) => $ReadOnly<{| attribute: 'selectableItemBackgroundBorderless', type: 'ThemeAttrAndroid', rippleRadius: ?number, @@ -252,11 +248,8 @@ class TouchableNativeFeedback extends React.Component { // BACKWARD-COMPATIBILITY: Focus and blur events were never supported before // adopting `Pressability`, so preserve that behavior. - const { - onBlur, - onFocus, - ...eventHandlersWithoutBlurAndFocus - } = this.state.pressability.getEventHandlers(); + const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} = + this.state.pressability.getEventHandlers(); const accessibilityState = this.props.disabled != null diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index 01b59674ad3..4ce0692c358 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -210,11 +210,8 @@ class TouchableOpacity extends React.Component { render(): React.Node { // BACKWARD-COMPATIBILITY: Focus and blur events were never supported before // adopting `Pressability`, so preserve that behavior. - const { - onBlur, - onFocus, - ...eventHandlersWithoutBlurAndFocus - } = this.state.pressability.getEventHandlers(); + const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} = + this.state.pressability.getEventHandlers(); const accessibilityState = this.props.disabled != null diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index 0b2c305b232..db4aaa4d599 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -106,11 +106,8 @@ class TouchableWithoutFeedback extends React.Component { // BACKWARD-COMPATIBILITY: Focus and blur events were never supported before // adopting `Pressability`, so preserve that behavior. - const { - onBlur, - onFocus, - ...eventHandlersWithoutBlurAndFocus - } = this.state.pressability.getEventHandlers(); + const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} = + this.state.pressability.getEventHandlers(); const elementProps: {[string]: mixed, ...} = { ...eventHandlersWithoutBlurAndFocus, diff --git a/Libraries/Components/View/ViewNativeComponent.js b/Libraries/Components/View/ViewNativeComponent.js index 4ca5ec9cf3c..a38c2a0a3b6 100644 --- a/Libraries/Components/View/ViewNativeComponent.js +++ b/Libraries/Components/View/ViewNativeComponent.js @@ -16,13 +16,12 @@ import ReactNativeViewViewConfigAndroid from './ReactNativeViewViewConfigAndroid import {type ViewProps as Props} from './ViewPropTypes'; import * as React from 'react'; -const ViewNativeComponent: HostComponent = NativeComponentRegistry.get( - 'RCTView', - () => +const ViewNativeComponent: HostComponent = + NativeComponentRegistry.get('RCTView', () => Platform.OS === 'android' ? ReactNativeViewViewConfigAndroid : {uiViewClassName: 'RCTView'}, -); + ); interface NativeCommands { +hotspotUpdate: ( diff --git a/Libraries/Core/Devtools/__tests__/parseErrorStack-test.js b/Libraries/Core/Devtools/__tests__/parseErrorStack-test.js index a92172c9876..ce7117bd268 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().stack); 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(undefined)).toEqual([]); expect(parseErrorStack(null)).toEqual([]); }); diff --git a/Libraries/Core/Devtools/parseHermesStack.js b/Libraries/Core/Devtools/parseHermesStack.js index 70d47a0991d..e9cdfd091cb 100644 --- a/Libraries/Core/Devtools/parseHermesStack.js +++ b/Libraries/Core/Devtools/parseHermesStack.js @@ -58,7 +58,8 @@ export type HermesParsedStack = {| // 4. source URL (filename) // 5. line number (1 based) // 6. column number (1 based) or virtual offset (0 based) -const RE_FRAME = /^ {4}at (.+?)(?: \((native)\)?| \((address at )?(.*?):(\d+):(\d+)\))$/; +const RE_FRAME = + /^ {4}at (.+?)(?: \((native)\)?| \((address at )?(.*?):(\d+):(\d+)\))$/; // Capturing groups: // 1. count of skipped frames diff --git a/Libraries/Core/ExceptionsManager.js b/Libraries/Core/ExceptionsManager.js index 00caaf92ab9..4c17ddb4db1 100644 --- a/Libraries/Core/ExceptionsManager.js +++ b/Libraries/Core/ExceptionsManager.js @@ -102,8 +102,8 @@ function reportException( isComponentError: !!e.isComponentError, }); } else if (isFatal || e.type !== 'warn') { - const NativeExceptionsManager = require('./NativeExceptionsManager') - .default; + const NativeExceptionsManager = + require('./NativeExceptionsManager').default; if (NativeExceptionsManager) { NativeExceptionsManager.reportException(data); } diff --git a/Libraries/Core/NativeExceptionsManager.js b/Libraries/Core/NativeExceptionsManager.js index 3716edbd4c7..b79e331917e 100644 --- a/Libraries/Core/NativeExceptionsManager.js +++ b/Libraries/Core/NativeExceptionsManager.js @@ -57,9 +57,8 @@ export interface Spec extends TurboModule { const Platform = require('../Utilities/Platform'); -const NativeModule = TurboModuleRegistry.getEnforcing( - 'ExceptionsManager', -); +const NativeModule = + TurboModuleRegistry.getEnforcing('ExceptionsManager'); const ExceptionsManager = { reportFatalException( diff --git a/Libraries/Core/Timers/JSTimers.js b/Libraries/Core/Timers/JSTimers.js index 5c2f0d854e5..9522d52077e 100644 --- a/Libraries/Core/Timers/JSTimers.js +++ b/Libraries/Core/Timers/JSTimers.js @@ -114,7 +114,7 @@ function _callTimer(timerID: number, frameTime: number, didTimeout: ?boolean) { callback(global.performance.now()); } 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. @@ -209,7 +209,11 @@ 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 { const id = _allocateCallback( () => func.apply(undefined, args), 'setTimeout', @@ -222,7 +226,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 @@ -243,7 +247,7 @@ const JSTimers = { * @param {function} func Callback to be invoked before the end of the * current JavaScript execution loop. */ - queueReactNativeMicrotask: function(func: Function, ...args: any) { + queueReactNativeMicrotask: function (func: Function, ...args: any) { const id = _allocateCallback( () => func.apply(undefined, args), 'queueReactNativeMicrotask', @@ -255,7 +259,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; @@ -266,7 +270,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 +308,7 @@ const JSTimers = { return id; }, - cancelIdleCallback: function(timerID: number) { + cancelIdleCallback: function (timerID: number) { _freeCallback(timerID); const index = requestIdleCallbacks.indexOf(timerID); if (index !== -1) { @@ -322,15 +326,15 @@ const JSTimers = { } }, - clearTimeout: function(timerID: number) { + clearTimeout: function (timerID: number) { _freeCallback(timerID); }, - clearInterval: function(timerID: number) { + clearInterval: function (timerID: number) { _freeCallback(timerID); }, - clearReactNativeMicrotask: function(timerID: number) { + clearReactNativeMicrotask: function (timerID: number) { _freeCallback(timerID); const index = reactNativeMicrotasks.indexOf(timerID); if (index !== -1) { @@ -338,7 +342,7 @@ const JSTimers = { } }, - cancelAnimationFrame: function(timerID: number) { + cancelAnimationFrame: function (timerID: number) { _freeCallback(timerID); }, @@ -346,7 +350,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.', @@ -378,7 +382,7 @@ const JSTimers = { } }, - callIdleCallbacks: function(frameTime: number) { + callIdleCallbacks: function (frameTime: number) { if ( FRAME_DURATION - (global.performance.now() - frameTime) < IDLE_CALLBACK_FRAME_DEADLINE diff --git a/Libraries/Core/Timers/__tests__/JSTimers-test.js b/Libraries/Core/Timers/__tests__/JSTimers-test.js index 371e8548a91..2df2001c7e3 100644 --- a/Libraries/Core/Timers/__tests__/JSTimers-test.js +++ b/Libraries/Core/Timers/__tests__/JSTimers-test.js @@ -26,8 +26,8 @@ jest const JSTimers = require('../JSTimers'); -describe('JSTimers', function() { - beforeEach(function() { +describe('JSTimers', function () { + beforeEach(function () { jest.spyOn(console, 'warn'); global.setTimeout = JSTimers.setTimeout; }); @@ -36,24 +36,24 @@ describe('JSTimers', function() { console.warn.mockRestore(); }); - 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; }); }); @@ -65,15 +65,15 @@ describe('JSTimers', function() { expect(callCount).toBe(1); }); - it('should call nested queueReactNativeMicrotask when cleared', function() { + it('should call nested queueReactNativeMicrotask when cleared', function () { let id1, id2, id3; let callCount = 0; - id1 = JSTimers.queueReactNativeMicrotask(function() { + id1 = JSTimers.queueReactNativeMicrotask(function () { JSTimers.clearReactNativeMicrotask(id1); - id2 = JSTimers.queueReactNativeMicrotask(function() { + id2 = JSTimers.queueReactNativeMicrotask(function () { JSTimers.clearReactNativeMicrotask(id2); - id3 = JSTimers.queueReactNativeMicrotask(function() { + id3 = JSTimers.queueReactNativeMicrotask(function () { callCount += 1; }); }); @@ -85,15 +85,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; }); }); @@ -105,15 +105,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; }); }); @@ -125,21 +125,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 queueReactNativeMicrotask', function() { + it('should call function with queueReactNativeMicrotask', function () { const callback = jest.fn(); JSTimers.queueReactNativeMicrotask(callback); JSTimers.callReactNativeMicrotasks(); expect(callback).toBeCalledTimes(1); }); - it('should not call function with clearReactNativeMicrotask', function() { + it('should not call function with clearReactNativeMicrotask', function () { const callback = jest.fn(); const id = JSTimers.queueReactNativeMicrotask(callback); JSTimers.clearReactNativeMicrotask(id); @@ -147,14 +147,14 @@ describe('JSTimers', function() { expect(callback).not.toBeCalled(); }); - it('should call functions in the right order with queueReactNativeMicrotask', function() { + it('should call functions in the right order with queueReactNativeMicrotask', function () { let count = 0; let firstCalled = null; let secondCalled = null; - JSTimers.queueReactNativeMicrotask(function() { + JSTimers.queueReactNativeMicrotask(function () { firstCalled = count++; }); - JSTimers.queueReactNativeMicrotask(function() { + JSTimers.queueReactNativeMicrotask(function () { secondCalled = count++; }); JSTimers.callReactNativeMicrotasks(); @@ -162,14 +162,14 @@ describe('JSTimers', function() { expect(secondCalled).toBe(1); }); - it('should call functions in the right order with nested queueReactNativeMicrotask', function() { + it('should call functions in the right order with nested queueReactNativeMicrotask', function () { let count = 0; let firstCalled = null; let secondCalled = null; let thirdCalled = null; - JSTimers.queueReactNativeMicrotask(function() { + JSTimers.queueReactNativeMicrotask(function () { firstCalled = count++; - JSTimers.queueReactNativeMicrotask(function() { + JSTimers.queueReactNativeMicrotask(function () { thirdCalled = count++; }); secondCalled = count++; @@ -180,12 +180,12 @@ describe('JSTimers', function() { expect(thirdCalled).toBe(2); }); - it('should call nested queueReactNativeMicrotask', function() { + it('should call nested queueReactNativeMicrotask', function () { let firstCalled = false; let secondCalled = false; - JSTimers.queueReactNativeMicrotask(function() { + JSTimers.queueReactNativeMicrotask(function () { firstCalled = true; - JSTimers.queueReactNativeMicrotask(function() { + JSTimers.queueReactNativeMicrotask(function () { secondCalled = true; }); }); @@ -194,14 +194,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(); @@ -211,7 +211,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]); @@ -221,13 +221,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]); @@ -235,13 +235,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]); @@ -249,27 +249,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); @@ -278,12 +278,12 @@ describe('JSTimers', function() { expect(console.warn).not.toBeCalled(); }); - 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(console.warn).toBeCalled(); }); - 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 @@ -295,7 +295,7 @@ describe('JSTimers', function() { expect(console.warn).not.toBeCalled(); }); - 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 @@ -307,11 +307,11 @@ describe('JSTimers', function() { expect(console.warn).not.toBeCalled(); }); - 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( @@ -319,8 +319,8 @@ describe('JSTimers', function() { ); }); - it('should pass along errors thrown from queueReactNativeMicrotask', function() { - JSTimers.queueReactNativeMicrotask(function() { + it('should pass along errors thrown from queueReactNativeMicrotask', function () { + JSTimers.queueReactNativeMicrotask(function () { throw new Error('error within queueReactNativeMicrotask'); }); @@ -336,12 +336,12 @@ describe('JSTimers', function() { ); }); - it('should throw all errors from queueReactNativeMicrotask', function() { - JSTimers.queueReactNativeMicrotask(function() { + it('should throw all errors from queueReactNativeMicrotask', function () { + JSTimers.queueReactNativeMicrotask(function () { throw new Error('first error'); }); - JSTimers.queueReactNativeMicrotask(function() { + JSTimers.queueReactNativeMicrotask(function () { throw new Error('second error'); }); @@ -361,8 +361,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'); }); @@ -371,11 +371,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'); }); @@ -391,8 +391,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( @@ -400,7 +400,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/setUpAlert.js b/Libraries/Core/setUpAlert.js index f4615ba8c2a..7d37fef72bb 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 86f2732643a..4c4a6a6cb81 100644 --- a/Libraries/Core/setUpDeveloperTools.js +++ b/Libraries/Core/setUpDeveloperTools.js @@ -58,7 +58,7 @@ if (__DEV__) { 'debug', ].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/setUpPerformance.js b/Libraries/Core/setUpPerformance.js index 12cace05f81..c253b76f430 100644 --- a/Libraries/Core/setUpPerformance.js +++ b/Libraries/Core/setUpPerformance.js @@ -19,7 +19,7 @@ if (!global.performance) { * https://developer.mozilla.org/en-US/docs/Web/API/Performance/now */ if (typeof global.performance.now !== 'function') { - global.performance.now = function() { + global.performance.now = function () { const performanceNow = global.nativePerformanceNow || Date.now; return performanceNow(); }; diff --git a/Libraries/Core/setUpRegeneratorRuntime.js b/Libraries/Core/setUpRegeneratorRuntime.js index 426e9b3b160..5cac97ec579 100644 --- a/Libraries/Core/setUpRegeneratorRuntime.js +++ b/Libraries/Core/setUpRegeneratorRuntime.js @@ -22,7 +22,7 @@ let hasNativeGenerator; try { // If this function was lowered by regenerator-transform, it will try to // access `global.regeneratorRuntime` which doesn't exist yet and will throw. - hasNativeGenerator = hasNativeConstructor(function*() {}, + hasNativeGenerator = hasNativeConstructor(function* () {}, 'GeneratorFunction'); } catch { // In this case, we know generators are not provided natively. diff --git a/Libraries/Core/setUpSegmentFetcher.js b/Libraries/Core/setUpSegmentFetcher.js index d48810ae22c..49ae1c6f33b 100644 --- a/Libraries/Core/setUpSegmentFetcher.js +++ b/Libraries/Core/setUpSegmentFetcher.js @@ -27,8 +27,8 @@ function __fetchSegment( }>, callback: (?Error) => void, ) { - const SegmentFetcher = require('./SegmentFetcher/NativeSegmentFetcher') - .default; + const SegmentFetcher = + require('./SegmentFetcher/NativeSegmentFetcher').default; SegmentFetcher.fetchSegment( segmentId, options, @@ -61,8 +61,8 @@ function __getSegment( }>, callback: (?Error, ?string) => void, ) { - const SegmentFetcher = require('./SegmentFetcher/NativeSegmentFetcher') - .default; + const SegmentFetcher = + require('./SegmentFetcher/NativeSegmentFetcher').default; if (!SegmentFetcher.getSegment) { throw new Error('SegmentFetcher.getSegment must be defined'); diff --git a/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js b/Libraries/DeprecatedPropTypes/DeprecatedColorPropType.js index caa6858a200..7265fa60aee 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 f692187a678..ac336be274a 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js @@ -15,10 +15,10 @@ const flattenStyle = require('../StyleSheet/flattenStyle'); function DeprecatedStyleSheetPropType(shape: { [key: string]: ReactPropsCheckType, - ..., + ... }): 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 daba0d83676..48c918a415f 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/DeprecatedPropTypes/deprecatedCreateStrictShapeTypeChecker.js b/Libraries/DeprecatedPropTypes/deprecatedCreateStrictShapeTypeChecker.js index b9249abab95..240844ea5c6 100644 --- a/Libraries/DeprecatedPropTypes/deprecatedCreateStrictShapeTypeChecker.js +++ b/Libraries/DeprecatedPropTypes/deprecatedCreateStrictShapeTypeChecker.js @@ -14,7 +14,7 @@ const invariant = require('invariant'); function deprecatedCreateStrictShapeTypeChecker(shapeTypes: { [key: string]: ReactPropsCheckType, - ..., + ... }): ReactPropsChainableTypeChecker { function checkType( isRequired, diff --git a/Libraries/EventEmitter/NativeEventEmitter.js b/Libraries/EventEmitter/NativeEventEmitter.js index f999dddf3e4..dbe164fd882 100644 --- a/Libraries/EventEmitter/NativeEventEmitter.js +++ b/Libraries/EventEmitter/NativeEventEmitter.js @@ -36,7 +36,8 @@ export type {EventSubscription}; * can theoretically listen to `RCTDeviceEventEmitter` (although discouraged). */ export default class NativeEventEmitter - implements IEventEmitter { + implements IEventEmitter +{ _nativeModule: ?NativeModule; constructor(nativeModule: ?NativeModule) { diff --git a/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js b/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js index 6863f81ef5f..ecaed2cfa23 100644 --- a/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +++ b/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js @@ -18,7 +18,8 @@ import RCTDeviceEventEmitter from '../RCTDeviceEventEmitter'; * Mock `NativeEventEmitter` to ignore Native Modules. */ export default class NativeEventEmitter - implements IEventEmitter { + implements IEventEmitter +{ addListener>( eventType: TEvent, listener: (...args: $ElementType) => mixed, diff --git a/Libraries/HeapCapture/HeapCapture.js b/Libraries/HeapCapture/HeapCapture.js index 1e76fd2cb1b..b13099ecec8 100644 --- a/Libraries/HeapCapture/HeapCapture.js +++ b/Libraries/HeapCapture/HeapCapture.js @@ -11,7 +11,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/AssetSourceResolver.js b/Libraries/Image/AssetSourceResolver.js index ee81537631c..af702130fbf 100644 --- a/Libraries/Image/AssetSourceResolver.js +++ b/Libraries/Image/AssetSourceResolver.js @@ -159,10 +159,8 @@ class AssetSourceResolver { }; } - static pickScale: ( - scales: Array, - deviceScale?: number, - ) => number = pickScale; + static pickScale: (scales: Array, deviceScale?: number) => number = + pickScale; } module.exports = AssetSourceResolver; diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index 935064389fe..24b0f55b378 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -40,12 +40,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); }, ); @@ -64,12 +64,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); }, ); diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index 2601ad6253e..953d01716d5 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -33,7 +33,7 @@ function getSize( .then(([width, height]) => success(width, height)) .catch( failure || - function() { + function () { console.warn('Failed to get size for image ' + uri); }, ); @@ -46,12 +46,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/ImageAnalyticsTagContext.js b/Libraries/Image/ImageAnalyticsTagContext.js index 54d8b65a26b..742a042c98d 100644 --- a/Libraries/Image/ImageAnalyticsTagContext.js +++ b/Libraries/Image/ImageAnalyticsTagContext.js @@ -12,9 +12,8 @@ import * as React from 'react'; type ContextType = ?string; -const Context: React.Context = React.createContext( - null, -); +const Context: React.Context = + React.createContext(null); if (__DEV__) { Context.displayName = 'ImageAnalyticsTagContext'; diff --git a/Libraries/Image/ImagePickerIOS.js b/Libraries/Image/ImagePickerIOS.js index 1d7438f2b53..60ae31ba764 100644 --- a/Libraries/Image/ImagePickerIOS.js +++ b/Libraries/Image/ImagePickerIOS.js @@ -12,15 +12,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, @@ -49,7 +49,7 @@ const ImagePickerIOS = { cancelCallback, ); }, - openSelectDialog: function( + openSelectDialog: function ( config: $ReadOnly<{| showImages?: boolean, showVideos?: boolean, @@ -86,7 +86,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); }, @@ -94,7 +94,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/ImageViewNativeComponent.js b/Libraries/Image/ImageViewNativeComponent.js index 7f26d89dcff..652f59d9b6d 100644 --- a/Libraries/Image/ImageViewNativeComponent.js +++ b/Libraries/Image/ImageViewNativeComponent.js @@ -36,9 +36,8 @@ type Props = $ReadOnly<{ loadingIndicatorSrc?: ?string, }>; -const ImageViewNativeComponent: HostComponent = NativeComponentRegistry.get( - 'RCTImageView', - () => ({ +const ImageViewNativeComponent: HostComponent = + NativeComponentRegistry.get('RCTImageView', () => ({ uiViewClassName: 'RCTImageView', bubblingEventTypes: {}, directEventTypes: { @@ -93,7 +92,6 @@ const ImageViewNativeComponent: HostComponent = NativeComponentRegistry.g process: require('../StyleSheet/processColor'), }, }, - }), -); + })); export default ImageViewNativeComponent; diff --git a/Libraries/Image/NativeImageLoaderAndroid.js b/Libraries/Image/NativeImageLoaderAndroid.js index c55fe6eb9d6..f75ddbfde69 100644 --- a/Libraries/Image/NativeImageLoaderAndroid.js +++ b/Libraries/Image/NativeImageLoaderAndroid.js @@ -14,9 +14,7 @@ import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { +abortRequest: (requestId: number) => void; +getConstants: () => {||}; - +getSize: ( - uri: string, - ) => Promise< + +getSize: (uri: string) => Promise< $ReadOnly<{ width: number, height: number, diff --git a/Libraries/Image/TextInlineImageNativeComponent.js b/Libraries/Image/TextInlineImageNativeComponent.js index c17de2581f0..6e6cddbc822 100644 --- a/Libraries/Image/TextInlineImageNativeComponent.js +++ b/Libraries/Image/TextInlineImageNativeComponent.js @@ -39,9 +39,8 @@ type Props = $ReadOnly<{ internal_analyticTag?: ?string, }>; -const TextInlineImage: HostComponent = NativeComponentRegistry.get( - 'RCTTextInlineImage', - () => ({ +const TextInlineImage: HostComponent = + NativeComponentRegistry.get('RCTTextInlineImage', () => ({ uiViewClassName: 'RCTImageView', bubblingEventTypes: {}, directEventTypes: { @@ -96,7 +95,6 @@ const TextInlineImage: HostComponent = NativeComponentRegistry.get process: require('../StyleSheet/processColor'), }, }, - }), -); + })); module.exports = TextInlineImage; diff --git a/Libraries/Image/__tests__/resolveAssetSource-test.js b/Libraries/Image/__tests__/resolveAssetSource-test.js index c9fa18374bb..2fc46ed6f59 100644 --- a/Libraries/Image/__tests__/resolveAssetSource-test.js +++ b/Libraries/Image/__tests__/resolveAssetSource-test.js @@ -21,8 +21,8 @@ describe('resolveAssetSource', () => { AssetRegistry = require('@react-native/assets/registry'); resolveAssetSource = require('../resolveAssetSource'); - NativeSourceCode = require('../../NativeModules/specs/NativeSourceCode') - .default; + NativeSourceCode = + require('../../NativeModules/specs/NativeSourceCode').default; Platform = require('../../Utilities/Platform'); }); @@ -81,8 +81,7 @@ describe('resolveAssetSource', () => { __packager_asset: true, width: 100, height: 200, - uri: - 'http://10.0.0.1:8081/assets/module/a/logo.png?platform=ios&hash=5b6f00f', + uri: 'http://10.0.0.1:8081/assets/module/a/logo.png?platform=ios&hash=5b6f00f', scale: 1, }, ); @@ -105,8 +104,7 @@ describe('resolveAssetSource', () => { __packager_asset: true, width: 100, height: 200, - uri: - 'http://10.0.0.1:8081/assets/module/a/logo@2x.png?platform=ios&hash=5b6f00f', + uri: 'http://10.0.0.1:8081/assets/module/a/logo@2x.png?platform=ios&hash=5b6f00f', scale: 2, }, ); @@ -248,8 +246,7 @@ describe('resolveAssetSource', () => { __packager_asset: true, width: 100, height: 200, - uri: - 'file:///sdcard/Path/To/Simulator/drawable-mdpi/awesomemodule_subdir_logo1_.png', + uri: 'file:///sdcard/Path/To/Simulator/drawable-mdpi/awesomemodule_subdir_logo1_.png', scale: 1, }, ); @@ -281,8 +278,7 @@ describe('resolveAssetSource', () => { __packager_asset: true, width: 100, height: 200, - uri: - 'file:///sdcard/Path/To/Simulator/drawable-mdpi/awesomemodule_subdir_logo1_.png', + uri: 'file:///sdcard/Path/To/Simulator/drawable-mdpi/awesomemodule_subdir_logo1_.png', scale: 1, }, ); diff --git a/Libraries/Inspector/NetworkOverlay.js b/Libraries/Inspector/NetworkOverlay.js index 45e6bdadcbf..1de327a827f 100644 --- a/Libraries/Inspector/NetworkOverlay.js +++ b/Libraries/Inspector/NetworkOverlay.js @@ -397,11 +397,8 @@ class NetworkOverlay extends React.Component { _indicateAdditionalRequests = (): void => { if (this._requestsListView) { const distanceFromEndThreshold = LISTVIEW_CELL_HEIGHT * 2; - const { - offset, - visibleLength, - contentLength, - } = this._requestsListViewScrollMetrics; + const {offset, visibleLength, contentLength} = + this._requestsListViewScrollMetrics; const distanceFromEnd = contentLength - visibleLength - offset; const isCloseToEnd = distanceFromEnd <= distanceFromEndThreshold; if (isCloseToEnd) { diff --git a/Libraries/Interaction/BridgeSpyStallHandler.js b/Libraries/Interaction/BridgeSpyStallHandler.js index e90777d4152..340d046cacc 100644 --- a/Libraries/Interaction/BridgeSpyStallHandler.js +++ b/Libraries/Interaction/BridgeSpyStallHandler.js @@ -16,7 +16,7 @@ const MessageQueue = require('../BatchedBridge/MessageQueue'); const infoLog = require('../Utilities/infoLog'); const BridgeSpyStallHandler = { - register: function() { + register: function () { let spyBuffer = []; MessageQueue.spy(data => { spyBuffer.push(data); diff --git a/Libraries/Interaction/FrameRateLogger.js b/Libraries/Interaction/FrameRateLogger.js index cad15c2cac7..3c3bf48c91f 100644 --- a/Libraries/Interaction/FrameRateLogger.js +++ b/Libraries/Interaction/FrameRateLogger.js @@ -33,7 +33,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, ... @@ -58,7 +58,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 b5a84145d50..5823196aba4 100644 --- a/Libraries/Interaction/InteractionManager.js +++ b/Libraries/Interaction/InteractionManager.js @@ -86,9 +86,7 @@ const InteractionManager = { * Schedule a function to run after all interactions have completed. Returns a cancellable * "promise". */ - runAfterInteractions( - task: ?Task, - ): { + runAfterInteractions(task: ?Task): { then: ( onFulfill?: ?(void) => ?(Promise | U), onReject?: ?(error: mixed) => ?(Promise | U), @@ -122,7 +120,7 @@ const InteractionManager = { ); } }, - cancel: function() { + cancel: function () { _taskQueue.cancelTasks(tasks); }, }; diff --git a/Libraries/Interaction/JSEventLoopWatchdog.js b/Libraries/Interaction/JSEventLoopWatchdog.js index 9d9f6cc05b0..bcba47164fe 100644 --- a/Libraries/Interaction/JSEventLoopWatchdog.js +++ b/Libraries/Interaction/JSEventLoopWatchdog.js @@ -35,20 +35,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 = global.performance.now(); }, - 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; diff --git a/Libraries/Interaction/PanResponder.js b/Libraries/Interaction/PanResponder.js index a41d34e0185..ee13970532d 100644 --- a/Libraries/Interaction/PanResponder.js +++ b/Libraries/Interaction/PanResponder.js @@ -383,9 +383,7 @@ const PanResponder = { * accordingly. (numberActiveTouches) may not be totally accurate unless you * are the responder. */ - create( - config: PanResponderConfig, - ): $TEMPORARY$object<{| + create(config: PanResponderConfig): $TEMPORARY$object<{| getInteractionHandle: () => ?number, panHandlers: $TEMPORARY$object<{| onMoveShouldSetResponder: (event: PressEvent) => boolean, @@ -462,7 +460,8 @@ const PanResponder = { onResponderGrant(event: PressEvent): boolean { if (!interactionState.handle) { - interactionState.handle = InteractionManager.createInteractionHandle(); + interactionState.handle = + InteractionManager.createInteractionHandle(); } gestureState.x0 = currentCentroidX(event.touchHistory); gestureState.y0 = currentCentroidY(event.touchHistory); diff --git a/Libraries/Interaction/TouchHistoryMath.js b/Libraries/Interaction/TouchHistoryMath.js index 19cf76a9f1b..2cf7704b3f2 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/JSInspector/NetworkAgent.js b/Libraries/JSInspector/NetworkAgent.js index f1811978709..e8e2f43b2a2 100644 --- a/Libraries/JSInspector/NetworkAgent.js +++ b/Libraries/JSInspector/NetworkAgent.js @@ -275,12 +275,7 @@ class NetworkAgent extends InspectorAgent { this._interceptor = null; } - getResponseBody({ - requestId, - }: { - requestId: RequestId, - ... - }): { + getResponseBody({requestId}: {requestId: RequestId, ...}): { body: ?string, base64Encoded: boolean, ... diff --git a/Libraries/LayoutAnimation/LayoutAnimation.js b/Libraries/LayoutAnimation/LayoutAnimation.js index efb12afa5dc..331308f36be 100644 --- a/Libraries/LayoutAnimation/LayoutAnimation.js +++ b/Libraries/LayoutAnimation/LayoutAnimation.js @@ -70,7 +70,7 @@ function configureNext( config, onAnimationComplete, onAnimationDidFail ?? - function() {} /* this will only be called if configuration parsing fails */, + function () {} /* this will only be called if configuration parsing fails */, ); return; } @@ -81,9 +81,9 @@ function configureNext( if (UIManager?.configureNextLayoutAnimation) { UIManager.configureNextLayoutAnimation( config, - onAnimationComplete ?? function() {}, + onAnimationComplete ?? function () {}, onAnimationDidFail ?? - function() {} /* this should never be called in Non-Fabric */, + function () {} /* this should never be called in Non-Fabric */, ); } } diff --git a/Libraries/Lists/FillRateHelper.js b/Libraries/Lists/FillRateHelper.js index 6e18000b48f..bcbd415be2a 100644 --- a/Libraries/Lists/FillRateHelper.js +++ b/Libraries/Lists/FillRateHelper.js @@ -54,9 +54,10 @@ class FillRateHelper { _mostlyBlankStartTime = (null: ?number); _samplesStartTime = (null: ?number); - static addListener( - callback: FillRateInfo => void, - ): {remove: () => void, ...} { + static addListener(callback: FillRateInfo => void): { + remove: () => void, + ... + } { if (_sampleRate === null) { console.warn('Call `FillRateHelper.setSampleRate` before `addListener`.'); } diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 5e49715a8e7..7f4932458e9 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -408,14 +408,13 @@ class FlatList extends React.PureComponent, void> { super(props); this._checkProps(this.props); if (this.props.viewabilityConfigCallbackPairs) { - this._virtualizedListPairs = this.props.viewabilityConfigCallbackPairs.map( - pair => ({ + this._virtualizedListPairs = + this.props.viewabilityConfigCallbackPairs.map(pair => ({ viewabilityConfig: pair.viewabilityConfig, onViewableItemsChanged: this._createOnViewableItemsChanged( pair.onViewableItemsChanged, ), - }), - ); + })); } else if (this.props.onViewableItemsChanged) { this._virtualizedListPairs.push({ /* $FlowFixMe[incompatible-call] (>=0.63.0 site=react_native_fb) This diff --git a/Libraries/Lists/ViewabilityHelper.js b/Libraries/Lists/ViewabilityHelper.js index 8b1d49fd8ba..aa59185fa1d 100644 --- a/Libraries/Lists/ViewabilityHelper.js +++ b/Libraries/Lists/ViewabilityHelper.js @@ -102,9 +102,7 @@ class ViewabilityHelper { itemCount: number, scrollOffset: number, viewportHeight: number, - getFrameMetrics: ( - index: number, - ) => ?{ + getFrameMetrics: (index: number) => ?{ length: number, offset: number, ... @@ -116,10 +114,8 @@ class ViewabilityHelper { ... }, ): Array { - const { - itemVisiblePercentThreshold, - viewAreaCoveragePercentThreshold, - } = this._config; + const {itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold} = + this._config; const viewAreaMode = viewAreaCoveragePercentThreshold != null; const viewablePercentThreshold = viewAreaMode ? viewAreaCoveragePercentThreshold @@ -179,9 +175,7 @@ class ViewabilityHelper { itemCount: number, scrollOffset: number, viewportHeight: number, - getFrameMetrics: ( - index: number, - ) => ?{ + getFrameMetrics: (index: number) => ?{ length: number, offset: number, ... diff --git a/Libraries/Lists/VirtualizeUtils.js b/Libraries/Lists/VirtualizeUtils.js index 1d80b378aa8..11dfd8cc203 100644 --- a/Libraries/Lists/VirtualizeUtils.js +++ b/Libraries/Lists/VirtualizeUtils.js @@ -20,9 +20,7 @@ import invariant from 'invariant'; export function elementsThatOverlapOffsets( offsets: Array, itemCount: number, - getFrameMetrics: ( - index: number, - ) => { + getFrameMetrics: (index: number) => { length: number, offset: number, ... @@ -96,9 +94,7 @@ export function computeWindowedRenderLimits( last: number, ... }, - getFrameMetricsApprox: ( - index: number, - ) => { + getFrameMetricsApprox: (index: number) => { length: number, offset: number, ... diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index efd740bfb7a..c411032c269 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -441,9 +441,9 @@ class VirtualizedList extends React.PureComponent { ); invariant( index < getItemCount(data), - `scrollToIndex out of range: requested index ${index} is out of 0 to ${getItemCount( - data, - ) - 1}`, + `scrollToIndex out of range: requested index ${index} is out of 0 to ${ + getItemCount(data) - 1 + }`, ); if (!getItemLayout && index > this._highestMeasuredFrameIndex) { invariant( @@ -882,11 +882,8 @@ class VirtualizedList extends React.PureComponent { ); } } - const { - ListEmptyComponent, - ListFooterComponent, - ListHeaderComponent, - } = this.props; + const {ListEmptyComponent, ListFooterComponent, ListHeaderComponent} = + this.props; const {data, horizontal} = this.props; const isVirtualizationDisabled = this._isVirtualizationDisabled(); const inversionStyle = this.props.inverted @@ -1496,12 +1493,8 @@ class VirtualizedList extends React.PureComponent { } _maybeCallOnEndReached() { - const { - data, - getItemCount, - onEndReached, - onEndReachedThreshold, - } = this.props; + const {data, getItemCount, onEndReached, onEndReachedThreshold} = + this.props; const {contentLength, visibleLength, offset} = this._scrollMetrics; const distanceFromEnd = contentLength - visibleLength - offset; const threshold = @@ -1588,15 +1581,11 @@ class VirtualizedList extends React.PureComponent { // know our offset from our offset from our parent return; } - ({ - visibleLength, - contentLength, - offset, - dOffset, - } = this._convertParentScrollMetrics({ - visibleLength, - offset, - })); + ({visibleLength, contentLength, offset, dOffset} = + this._convertParentScrollMetrics({ + visibleLength, + offset, + })); } const dt = this._scrollMetrics.timestamp diff --git a/Libraries/Lists/VirtualizedListContext.js b/Libraries/Lists/VirtualizedListContext.js index b2f8d063dca..c79fd146b18 100644 --- a/Libraries/Lists/VirtualizedListContext.js +++ b/Libraries/Lists/VirtualizedListContext.js @@ -64,9 +64,8 @@ type Context = $ReadOnly<{ debugInfo: ListDebugInfo, }>; -export const VirtualizedListContext: React.Context = React.createContext( - null, -); +export const VirtualizedListContext: React.Context = + React.createContext(null); if (__DEV__) { VirtualizedListContext.displayName = 'VirtualizedListContext'; } diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 977fa3a0d78..a3d858d2ff7 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -240,9 +240,7 @@ class VirtualizedSectionList< return (info && info.key) || String(index); }; - _subExtractor( - index: number, - ): ?{ + _subExtractor(index: number): ?{ section: SectionT, // Key of the section or combined key for section + item key: string, @@ -339,63 +337,58 @@ class VirtualizedSectionList< } }; - _renderItem = (listItemCount: number) => ({ - item, - index, - }: { - item: Item, - index: number, - ... - }) => { - const info = this._subExtractor(index); - if (!info) { - return null; - } - const infoIndex = info.index; - if (infoIndex == null) { - const {section} = info; - if (info.header === true) { - const {renderSectionHeader} = this.props; - return renderSectionHeader ? renderSectionHeader({section}) : null; - } else { - const {renderSectionFooter} = this.props; - return renderSectionFooter ? renderSectionFooter({section}) : null; + _renderItem = + (listItemCount: number) => + ({item, index}: {item: Item, index: number, ...}) => { + const info = this._subExtractor(index); + if (!info) { + return null; } - } else { - const renderItem = info.section.renderItem || this.props.renderItem; - const SeparatorComponent = this._getSeparatorComponent( - index, - info, - listItemCount, - ); - invariant(renderItem, 'no renderItem!'); - return ( - - ); - } - }; + const infoIndex = info.index; + if (infoIndex == null) { + const {section} = info; + if (info.header === true) { + const {renderSectionHeader} = this.props; + return renderSectionHeader ? renderSectionHeader({section}) : null; + } else { + const {renderSectionFooter} = this.props; + return renderSectionFooter ? renderSectionFooter({section}) : null; + } + } else { + const renderItem = info.section.renderItem || this.props.renderItem; + const SeparatorComponent = this._getSeparatorComponent( + index, + info, + listItemCount, + ); + invariant(renderItem, 'no renderItem!'); + return ( + + ); + } + }; _updatePropsFor = (cellKey, value) => { const updateProps = this._updatePropsMap[cellKey]; @@ -506,10 +499,8 @@ function ItemWithSeparator(props: ItemWithSeparatorProps): React.Node { inverted, } = props; - const [ - leadingSeparatorHiglighted, - setLeadingSeparatorHighlighted, - ] = React.useState(false); + const [leadingSeparatorHiglighted, setLeadingSeparatorHighlighted] = + React.useState(false); const [separatorHighlighted, setSeparatorHighlighted] = React.useState(false); diff --git a/Libraries/Lists/__tests__/FillRateHelper-test.js b/Libraries/Lists/__tests__/FillRateHelper-test.js index a0b0b3b4f48..f3c11323c1c 100644 --- a/Libraries/Lists/__tests__/FillRateHelper-test.js +++ b/Libraries/Lists/__tests__/FillRateHelper-test.js @@ -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,7 +96,7 @@ 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 => FillRateHelper.addListener(listener), diff --git a/Libraries/Lists/__tests__/ViewabilityHelper-test.js b/Libraries/Lists/__tests__/ViewabilityHelper-test.js index 6240824b68c..301679785f9 100644 --- a/Libraries/Lists/__tests__/ViewabilityHelper-test.js +++ b/Libraries/Lists/__tests__/ViewabilityHelper-test.js @@ -22,8 +22,8 @@ function createViewToken(index: number, isViewable: boolean) { return {key: data[index].key, isViewable}; } -describe('computeViewableItems', function() { - it('returns all 4 entirely visible rows as viewable', function() { +describe('computeViewableItems', function () { + it('returns all 4 entirely visible rows as viewable', function () { const helper = new ViewabilityHelper({ viewAreaCoveragePercentThreshold: 50, }); @@ -39,7 +39,7 @@ describe('computeViewableItems', function() { ).toEqual([0, 1, 2, 3]); }); - it('returns top 2 rows as viewable (1. entirely visible and 2. majority)', function() { + it('returns top 2 rows as viewable (1. entirely visible and 2. majority)', function () { const helper = new ViewabilityHelper({ viewAreaCoveragePercentThreshold: 50, }); @@ -55,7 +55,7 @@ describe('computeViewableItems', function() { ).toEqual([0, 1]); }); - it('returns only 2nd row as viewable (majority)', function() { + it('returns only 2nd row as viewable (majority)', function () { const helper = new ViewabilityHelper({ viewAreaCoveragePercentThreshold: 50, }); @@ -71,7 +71,7 @@ describe('computeViewableItems', function() { ).toEqual([1]); }); - it('handles empty input', function() { + it('handles empty input', function () { const helper = new ViewabilityHelper({ viewAreaCoveragePercentThreshold: 50, }); @@ -82,7 +82,7 @@ describe('computeViewableItems', function() { ).toEqual([]); }); - it('handles different view area coverage percent thresholds', function() { + it('handles different view area coverage percent thresholds', function () { rowFrames = { a: {y: 0, height: 50}, b: {y: 50, height: 150}, @@ -128,7 +128,7 @@ describe('computeViewableItems', function() { ).toEqual([1, 2]); }); - it('handles different item visible percent thresholds', function() { + it('handles different item visible percent thresholds', function () { rowFrames = { a: {y: 0, height: 50}, b: {y: 50, height: 150}, @@ -165,8 +165,8 @@ describe('computeViewableItems', function() { }); }); -describe('onUpdate', function() { - it('returns 1 visible row as viewable then scrolls away', function() { +describe('onUpdate', function () { + it('returns 1 visible row as viewable then scrolls away', function () { const helper = new ViewabilityHelper(); rowFrames = { a: {y: 0, height: 50}, @@ -212,7 +212,7 @@ describe('onUpdate', function() { }); }); - it('returns 1st visible row then 1st and 2nd then just 2nd', function() { + it('returns 1st visible row then 1st and 2nd then just 2nd', function () { const helper = new ViewabilityHelper(); rowFrames = { a: {y: 0, height: 200}, @@ -268,7 +268,7 @@ describe('onUpdate', function() { }); }); - it('minimumViewTime delays callback', function() { + it('minimumViewTime delays callback', function () { const helper = new ViewabilityHelper({ minimumViewTime: 350, viewAreaCoveragePercentThreshold: 0, @@ -302,7 +302,7 @@ describe('onUpdate', function() { }); }); - it('minimumViewTime skips briefly visible items', function() { + it('minimumViewTime skips briefly visible items', function () { const helper = new ViewabilityHelper({ minimumViewTime: 350, viewAreaCoveragePercentThreshold: 0, @@ -343,7 +343,7 @@ describe('onUpdate', function() { }); }); - it('waitForInteraction blocks callback until interaction', function() { + it('waitForInteraction blocks callback until interaction', function () { const helper = new ViewabilityHelper({ waitForInteraction: true, viewAreaCoveragePercentThreshold: 0, @@ -385,7 +385,7 @@ describe('onUpdate', function() { }); }); - it('returns the right visible row after the underlying data changed', function() { + it('returns the right visible row after the underlying data changed', function () { const helper = new ViewabilityHelper(); rowFrames = { a: {y: 0, height: 200}, diff --git a/Libraries/Lists/__tests__/VirtualizeUtils-test.js b/Libraries/Lists/__tests__/VirtualizeUtils-test.js index 389f4f53758..0181eabeb88 100644 --- a/Libraries/Lists/__tests__/VirtualizeUtils-test.js +++ b/Libraries/Lists/__tests__/VirtualizeUtils-test.js @@ -12,35 +12,35 @@ import {elementsThatOverlapOffsets, newRangeCount} from '../VirtualizeUtils'; -describe('newRangeCount', function() { - it('handles subset', function() { +describe('newRangeCount', function () { + it('handles subset', function () { expect(newRangeCount({first: 1, last: 4}, {first: 2, last: 3})).toBe(0); }); - it('handles forward disjoint set', function() { + it('handles forward disjoint set', function () { expect(newRangeCount({first: 1, last: 4}, {first: 6, last: 9})).toBe(4); }); - it('handles reverse disjoint set', function() { + it('handles reverse disjoint set', function () { expect(newRangeCount({first: 6, last: 8}, {first: 1, last: 4})).toBe(4); }); - it('handles superset', function() { + it('handles superset', function () { expect(newRangeCount({first: 1, last: 4}, {first: 0, last: 5})).toBe(2); }); - it('handles end extension', function() { + it('handles end extension', function () { expect(newRangeCount({first: 1, last: 4}, {first: 1, last: 8})).toBe(4); }); - it('handles front extension', function() { + it('handles front extension', function () { expect(newRangeCount({first: 1, last: 4}, {first: 0, last: 4})).toBe(1); }); - it('handles forward intersect', function() { + it('handles forward intersect', function () { expect(newRangeCount({first: 1, last: 4}, {first: 3, last: 6})).toBe(2); }); - it('handles reverse intersect', function() { + it('handles reverse intersect', function () { expect(newRangeCount({first: 3, last: 6}, {first: 1, last: 4})).toBe(2); }); }); -describe('elementsThatOverlapOffsets', function() { - it('handles fixed length', function() { +describe('elementsThatOverlapOffsets', function () { + it('handles fixed length', function () { const offsets = [0, 250, 350, 450]; function getFrameMetrics(index: number) { return { @@ -49,13 +49,10 @@ describe('elementsThatOverlapOffsets', function() { }; } expect(elementsThatOverlapOffsets(offsets, 100, getFrameMetrics)).toEqual([ - 0, - 2, - 3, - 4, + 0, 2, 3, 4, ]); }); - it('handles variable length', function() { + it('handles variable length', function () { const offsets = [150, 250, 900]; const frames = [ {offset: 0, length: 50}, @@ -68,7 +65,7 @@ describe('elementsThatOverlapOffsets', function() { elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]), ).toEqual([1, 1, 3]); }); - it('handles out of bounds', function() { + it('handles out of bounds', function () { const offsets = [150, 900]; const frames = [ {offset: 0, length: 50}, @@ -79,7 +76,7 @@ describe('elementsThatOverlapOffsets', function() { elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]), ).toEqual([1]); }); - it('errors on non-increasing offsets', function() { + it('errors on non-increasing offsets', function () { const offsets = [150, 50]; const frames = [ {offset: 0, length: 50}, diff --git a/Libraries/LogBox/Data/LogBoxData.js b/Libraries/LogBox/Data/LogBoxData.js index 1c2f8426024..2c1f48da169 100644 --- a/Libraries/LogBox/Data/LogBoxData.js +++ b/Libraries/LogBox/Data/LogBoxData.js @@ -71,7 +71,7 @@ let updateTimeout = null; let _isDisabled = false; let _selectedIndex = -1; -let warningFilter: WarningFilter = function(format) { +let warningFilter: WarningFilter = function (format) { return { finalFormat: format, forceDialogImmediately: false, diff --git a/Libraries/LogBox/Data/parseLogBoxLog.js b/Libraries/LogBox/Data/parseLogBoxLog.js index df75479bb5d..66d3273f523 100644 --- a/Libraries/LogBox/Data/parseLogBoxLog.js +++ b/Libraries/LogBox/Data/parseLogBoxLog.js @@ -14,9 +14,12 @@ import type {ExceptionData} from '../../Core/NativeExceptionsManager'; import type {LogBoxLogData} from './LogBoxLog'; import parseErrorStack from '../../Core/Devtools/parseErrorStack'; -const BABEL_TRANSFORM_ERROR_FORMAT = /^(?:TransformError )?(?:SyntaxError: |ReferenceError: )(.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/; -const BABEL_CODE_FRAME_ERROR_FORMAT = /^(?:TransformError )?(?:.*):? (?:.*?)(\/.*): ([\s\S]+?)\n([ >]{2}[\d\s]+ \|[\s\S]+|\u{001b}[\s\S]+)/u; -const METRO_ERROR_FORMAT = /^(?:InternalError Metro has encountered an error:) (.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/u; +const BABEL_TRANSFORM_ERROR_FORMAT = + /^(?:TransformError )?(?:SyntaxError: |ReferenceError: )(.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/; +const BABEL_CODE_FRAME_ERROR_FORMAT = + /^(?:TransformError )?(?:.*):? (?:.*?)(\/.*): ([\s\S]+?)\n([ >]{2}[\d\s]+ \|[\s\S]+|\u{001b}[\s\S]+)/u; +const METRO_ERROR_FORMAT = + /^(?:InternalError Metro has encountered an error:) (.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+)/u; export type ExtendedExceptionData = ExceptionData & { isComponentError: boolean, @@ -51,9 +54,7 @@ export type ComponentStack = $ReadOnlyArray; const SUBSTITUTION = UTFSequence.BOM + '%s'; -export function parseInterpolation( - args: $ReadOnlyArray, -): $ReadOnly<{| +export function parseInterpolation(args: $ReadOnlyArray): $ReadOnly<{| category: Category, message: Message, |}> { @@ -186,13 +187,8 @@ export function parseLogBoxException( const metroInternalError = message.match(METRO_ERROR_FORMAT); if (metroInternalError) { - const [ - content, - fileName, - row, - column, - codeFrame, - ] = metroInternalError.slice(1); + const [content, fileName, row, column, codeFrame] = + metroInternalError.slice(1); return { level: 'fatal', @@ -219,13 +215,8 @@ export function parseLogBoxException( const babelTransformError = message.match(BABEL_TRANSFORM_ERROR_FORMAT); if (babelTransformError) { // Transform errors are thrown from inside the Babel transformer. - const [ - fileName, - content, - row, - column, - codeFrame, - ] = babelTransformError.slice(1); + const [fileName, content, row, column, codeFrame] = + babelTransformError.slice(1); return { level: 'syntax', @@ -318,9 +309,7 @@ export function parseLogBoxException( }; } -export function parseLogBoxLog( - args: $ReadOnlyArray, -): {| +export function parseLogBoxLog(args: $ReadOnlyArray): {| componentStack: ComponentStack, category: Category, message: Message, diff --git a/Libraries/LogBox/UI/__tests__/LogBoxInspectorMesageHeader-test.js b/Libraries/LogBox/UI/__tests__/LogBoxInspectorMesageHeader-test.js index 7326a02c009..7cabd321ee7 100644 --- a/Libraries/LogBox/UI/__tests__/LogBoxInspectorMesageHeader-test.js +++ b/Libraries/LogBox/UI/__tests__/LogBoxInspectorMesageHeader-test.js @@ -12,8 +12,8 @@ 'use strict'; const React = require('react'); -const LogBoxInspectorMessageHeader = require('../LogBoxInspectorMessageHeader') - .default; +const LogBoxInspectorMessageHeader = + require('../LogBoxInspectorMessageHeader').default; const render = require('../../../../jest/renderer'); describe('LogBoxInspectorMessageHeader', () => { diff --git a/Libraries/LogBox/UI/__tests__/LogBoxInspectorReactFrames-test.js b/Libraries/LogBox/UI/__tests__/LogBoxInspectorReactFrames-test.js index 117fbafde0e..386f8c6bbe0 100644 --- a/Libraries/LogBox/UI/__tests__/LogBoxInspectorReactFrames-test.js +++ b/Libraries/LogBox/UI/__tests__/LogBoxInspectorReactFrames-test.js @@ -12,8 +12,8 @@ 'use strict'; const React = require('react'); -const LogBoxInspectorReactFrames = require('../LogBoxInspectorReactFrames') - .default; +const LogBoxInspectorReactFrames = + require('../LogBoxInspectorReactFrames').default; const LogBoxLog = require('../../Data/LogBoxLog').default; const render = require('../../../../jest/renderer'); diff --git a/Libraries/LogBox/UI/__tests__/LogBoxInspectorSourceMapStatus-test.js b/Libraries/LogBox/UI/__tests__/LogBoxInspectorSourceMapStatus-test.js index b44c4decf47..dd5d768eb47 100644 --- a/Libraries/LogBox/UI/__tests__/LogBoxInspectorSourceMapStatus-test.js +++ b/Libraries/LogBox/UI/__tests__/LogBoxInspectorSourceMapStatus-test.js @@ -12,8 +12,8 @@ 'use strict'; const React = require('react'); -const LogBoxInspectorSourceMapStatus = require('../LogBoxInspectorSourceMapStatus') - .default; +const LogBoxInspectorSourceMapStatus = + require('../LogBoxInspectorSourceMapStatus').default; const render = require('../../../../jest/renderer'); describe('LogBoxInspectorSourceMapStatus', () => { diff --git a/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrame-test.js b/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrame-test.js index b52175d54ab..4b0e508b7f6 100644 --- a/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrame-test.js +++ b/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrame-test.js @@ -12,8 +12,8 @@ 'use strict'; const React = require('react'); -const LogBoxInspectorStackFrame = require('../LogBoxInspectorStackFrame') - .default; +const LogBoxInspectorStackFrame = + require('../LogBoxInspectorStackFrame').default; const render = require('../../../../jest/renderer'); describe('LogBoxInspectorStackFrame', () => { diff --git a/Libraries/NativeComponent/NativeComponentRegistry.js b/Libraries/NativeComponent/NativeComponentRegistry.js index 2e90c650a02..cc8986ae694 100644 --- a/Libraries/NativeComponent/NativeComponentRegistry.js +++ b/Libraries/NativeComponent/NativeComponentRegistry.js @@ -33,9 +33,7 @@ let componentNameToExists: Map = new Map(); * the current environment. */ export function setRuntimeConfigProvider( - runtimeConfigProvider: ( - name: string, - ) => ?{ + runtimeConfigProvider: (name: string) => ?{ native: boolean, strict: boolean, verify: boolean, @@ -132,7 +130,7 @@ export function getWithFallback_DEPRECATED( } } - const FallbackNativeComponent = function(props: Config): React.Node { + const FallbackNativeComponent = function (props: Config): React.Node { return null; }; FallbackNativeComponent.displayName = `Fallback(${name})`; diff --git a/Libraries/Network/XHRInterceptor.js b/Libraries/Network/XHRInterceptor.js index 65c32e5606d..e9c26b5b6c5 100644 --- a/Libraries/Network/XHRInterceptor.js +++ b/Libraries/Network/XHRInterceptor.js @@ -75,7 +75,7 @@ const XHRInterceptor = { } // Override `open` method for all XHR requests to intercept the request // method and url, then pass them through the `openCallback`. - XMLHttpRequest.prototype.open = function(method, url) { + XMLHttpRequest.prototype.open = function (method, url) { if (openCallback) { openCallback(method, url, this); } @@ -84,7 +84,7 @@ const XHRInterceptor = { // Override `setRequestHeader` method for all XHR requests to intercept // the request headers, then pass them through the `requestHeaderCallback`. - XMLHttpRequest.prototype.setRequestHeader = function(header, value) { + XMLHttpRequest.prototype.setRequestHeader = function (header, value) { if (requestHeaderCallback) { requestHeaderCallback(header, value, this); } @@ -93,7 +93,7 @@ const XHRInterceptor = { // Override `send` method of all XHR requests to intercept the data sent, // register listeners to intercept the response, and invoke the callbacks. - XMLHttpRequest.prototype.send = function(data) { + XMLHttpRequest.prototype.send = function (data) { if (sendCallback) { sendCallback(data, this); } @@ -106,9 +106,8 @@ const XHRInterceptor = { } if (this.readyState === this.HEADERS_RECEIVED) { const contentTypeString = this.getResponseHeader('Content-Type'); - const contentLengthString = this.getResponseHeader( - 'Content-Length', - ); + const contentLengthString = + this.getResponseHeader('Content-Length'); let responseContentType, responseSize; if (contentTypeString) { responseContentType = contentTypeString.split(';')[0]; diff --git a/Libraries/Network/__tests__/FormData-test.js b/Libraries/Network/__tests__/FormData-test.js index 5ea0263aac3..b93b8a53342 100644 --- a/Libraries/Network/__tests__/FormData-test.js +++ b/Libraries/Network/__tests__/FormData-test.js @@ -12,7 +12,7 @@ const FormData = require('../FormData'); -describe('FormData', function() { +describe('FormData', function () { var formData; beforeEach(() => { @@ -23,7 +23,7 @@ describe('FormData', function() { formData = null; }); - it('should return non blob null', function() { + it('should return non blob null', function () { formData.append('null', null); const expectedPart = { @@ -36,7 +36,7 @@ describe('FormData', function() { expect(formData.getParts()[0]).toMatchObject(expectedPart); }); - it('should return blob', function() { + it('should return blob', function () { formData.append('photo', { uri: 'arbitrary/path', type: 'image/jpeg', diff --git a/Libraries/Network/__tests__/XMLHttpRequest-test.js b/Libraries/Network/__tests__/XMLHttpRequest-test.js index f769d356f78..1968be210bc 100644 --- a/Libraries/Network/__tests__/XMLHttpRequest-test.js +++ b/Libraries/Network/__tests__/XMLHttpRequest-test.js @@ -28,15 +28,15 @@ jest .dontMock('event-target-shim') .setMock('../../BatchedBridge/NativeModules', { Networking: { - addListener: function() {}, - removeListeners: function() {}, + addListener: function () {}, + removeListeners: function () {}, sendRequest(options, callback) { if (typeof callback === 'function') { // android does not pass a callback callback(requestId); } }, - abortRequest: function() {}, + abortRequest: function () {}, }, PlatformConstants: { getConstants() { @@ -47,7 +47,7 @@ jest const XMLHttpRequest = require('../XMLHttpRequest'); -describe('XMLHttpRequest', function() { +describe('XMLHttpRequest', function () { let xhr; let handleTimeout; let handleError; @@ -88,7 +88,7 @@ describe('XMLHttpRequest', function() { handleReadyStateChange = null; }); - it('should transition readyState correctly', function() { + it('should transition readyState correctly', function () { expect(xhr.readyState).toBe(xhr.UNSENT); xhr.open('GET', 'blabla'); @@ -98,7 +98,7 @@ describe('XMLHttpRequest', function() { expect(xhr.readyState).toBe(xhr.OPENED); }); - it('should expose responseType correctly', function() { + it('should expose responseType correctly', function () { expect(xhr.responseType).toBe(''); jest.spyOn(console, 'warn').mockReturnValue(undefined); @@ -123,7 +123,7 @@ describe('XMLHttpRequest', function() { }).toThrow(); }); - it('should expose responseText correctly', function() { + it('should expose responseText correctly', function () { xhr.responseType = ''; expect(xhr.responseText).toBe(''); expect(xhr.response).toBe(''); @@ -150,7 +150,7 @@ describe('XMLHttpRequest', function() { expect(xhr.responseText).toBe('Some data'); }); - it('should call ontimeout function when the request times out', function() { + it('should call ontimeout function when the request times out', function () { xhr.open('GET', 'blabla'); xhr.send(); setRequestId(3); @@ -170,7 +170,7 @@ describe('XMLHttpRequest', function() { expect(handleLoad).not.toBeCalled(); }); - it('should call onerror function when the request times out', function() { + it('should call onerror function when the request times out', function () { xhr.open('GET', 'blabla'); xhr.send(); setRequestId(4); @@ -191,7 +191,7 @@ describe('XMLHttpRequest', function() { expect(handleLoad).not.toBeCalled(); }); - it('should call onload function when there is no error', function() { + it('should call onload function when there is no error', function () { xhr.open('GET', 'blabla'); xhr.send(); setRequestId(5); @@ -212,7 +212,7 @@ describe('XMLHttpRequest', function() { expect(handleTimeout).not.toBeCalled(); }); - it('should call upload onprogress', function() { + it('should call upload onprogress', function () { xhr.open('GET', 'blabla'); xhr.send(); @@ -231,7 +231,7 @@ describe('XMLHttpRequest', function() { expect(handleProgress.mock.calls[0][0].total).toBe(100); }); - it('should combine response headers with CRLF', function() { + it('should combine response headers with CRLF', function () { xhr.open('GET', 'blabla'); xhr.send(); setRequestId(7); @@ -293,7 +293,7 @@ describe('XMLHttpRequest', function() { expect(GlobalPerformanceLogger.stopTimespan).not.toHaveBeenCalled(); }); - it('should sort and lowercase response headers', function() { + it('should sort and lowercase response headers', function () { // Derived from XHR Web Platform Test: https://github.com/web-platform-tests/wpt/blob/master/xhr/getallresponseheaders.htm xhr.open('GET', 'blabla'); xhr.send(); diff --git a/Libraries/Performance/SamplingProfiler.js b/Libraries/Performance/SamplingProfiler.js index a1c0ece4d16..4f3a211eb13 100644 --- a/Libraries/Performance/SamplingProfiler.js +++ b/Libraries/Performance/SamplingProfiler.js @@ -11,7 +11,7 @@ 'use strict'; const SamplingProfiler = { - poke: function(token: number): void { + poke: function (token: number): void { let error = null; let result = null; try { @@ -28,8 +28,8 @@ const SamplingProfiler = { error = e.toString(); } - const NativeJSCSamplingProfiler = require('./NativeJSCSamplingProfiler') - .default; + const NativeJSCSamplingProfiler = + require('./NativeJSCSamplingProfiler').default; if (NativeJSCSamplingProfiler) { NativeJSCSamplingProfiler.operationComplete(token, result, error); } diff --git a/Libraries/PermissionsAndroid/PermissionsAndroid.js b/Libraries/PermissionsAndroid/PermissionsAndroid.js index 8d8ceb4e9bb..5d9ff0d7af9 100644 --- a/Libraries/PermissionsAndroid/PermissionsAndroid.js +++ b/Libraries/PermissionsAndroid/PermissionsAndroid.js @@ -223,9 +223,10 @@ class PermissionsAndroid { ); if (rationale) { - const shouldShowRationale = await NativePermissionsAndroid.shouldShowRequestPermissionRationale( - permission, - ); + const shouldShowRationale = + await NativePermissionsAndroid.shouldShowRequestPermissionRationale( + permission, + ); if (shouldShowRationale && !!NativeDialogManagerAndroid) { return new Promise((resolve, reject) => { diff --git a/Libraries/Pressability/Pressability.js b/Libraries/Pressability/Pressability.js index bb3c6d4d282..6446d1476f3 100644 --- a/Libraries/Pressability/Pressability.js +++ b/Libraries/Pressability/Pressability.js @@ -545,8 +545,8 @@ export default class Pressability { if (process.env.NODE_ENV === 'test') { // We are setting this in order to find this node in ReactNativeTestTools - responderEventHandlers.onStartShouldSetResponder.testOnly_pressabilityConfig = () => - this._config; + responderEventHandlers.onStartShouldSetResponder.testOnly_pressabilityConfig = + () => this._config; } const mouseEventHandlers = diff --git a/Libraries/Pressability/PressabilityPerformanceEventEmitter.js b/Libraries/Pressability/PressabilityPerformanceEventEmitter.js index ec49f2bf9a4..3412f8bbf13 100644 --- a/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +++ b/Libraries/Pressability/PressabilityPerformanceEventEmitter.js @@ -14,7 +14,8 @@ export type PressabilityPerformanceEvent = $ReadOnly<{| signal: TouchSignal, nativeTimestamp: number, |}>; -export type PressabilityPerformanceEventListener = PressabilityPerformanceEvent => void; +export type PressabilityPerformanceEventListener = + PressabilityPerformanceEvent => void; class PressabilityPerformanceEventEmitter { _listeners: Array = []; @@ -42,6 +43,7 @@ class PressabilityPerformanceEventEmitter { } } -const PressabilityPerformanceEventEmitterSingleton: PressabilityPerformanceEventEmitter = new PressabilityPerformanceEventEmitter(); +const PressabilityPerformanceEventEmitterSingleton: PressabilityPerformanceEventEmitter = + new PressabilityPerformanceEventEmitter(); export default PressabilityPerformanceEventEmitterSingleton; diff --git a/Libraries/PushNotificationIOS/PushNotificationIOS.js b/Libraries/PushNotificationIOS/PushNotificationIOS.js index 288d06d9a7b..d1d78cc860c 100644 --- a/Libraries/PushNotificationIOS/PushNotificationIOS.js +++ b/Libraries/PushNotificationIOS/PushNotificationIOS.js @@ -37,11 +37,12 @@ type NativePushNotificationIOSEventDefinitions = { localNotificationReceived: [{...}], }; -const PushNotificationEmitter = new NativeEventEmitter( - // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior - // If you want to use the native module on other platforms, please remove this condition and test its behavior - Platform.OS !== 'ios' ? null : NativePushNotificationManagerIOS, -); +const PushNotificationEmitter = + new NativeEventEmitter( + // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior + // If you want to use the native module on other platforms, please remove this condition and test its behavior + Platform.OS !== 'ios' ? null : NativePushNotificationManagerIOS, + ); const _notifHandlers = new Map(); diff --git a/Libraries/ReactNative/AppContainer.js b/Libraries/ReactNative/AppContainer.js index 23da450a310..8f848da5cae 100644 --- a/Libraries/ReactNative/AppContainer.js +++ b/Libraries/ReactNative/AppContainer.js @@ -82,8 +82,8 @@ class AppContainer extends React.Component { !global.__RCTProfileIsProfiling && !this.props.internal_excludeLogBox ) { - const LogBoxNotificationContainer = require('../LogBox/LogBoxNotificationContainer') - .default; + const LogBoxNotificationContainer = + require('../LogBox/LogBoxNotificationContainer').default; logBox = ; } } diff --git a/Libraries/ReactNative/AppRegistry.js b/Libraries/ReactNative/AppRegistry.js index f1ff791dd3d..e6cd6757195 100644 --- a/Libraries/ReactNative/AppRegistry.js +++ b/Libraries/ReactNative/AppRegistry.js @@ -59,9 +59,8 @@ let runCount = 1; const sections: Runnables = {}; const taskProviders: Map = new Map(); const taskCancelProviders: Map = new Map(); -let componentProviderInstrumentationHook: ComponentProviderInstrumentationHook = ( - component: ComponentProvider, -) => component(); +let componentProviderInstrumentationHook: ComponentProviderInstrumentationHook = + (component: ComponentProvider) => component(); let wrapperComponentProvider: ?WrapperComponentProvider; let showArchitectureIndicator = false; diff --git a/Libraries/ReactNative/I18nManager.js b/Libraries/ReactNative/I18nManager.js index 1095ab81cdb..fb4fe46857d 100644 --- a/Libraries/ReactNative/I18nManager.js +++ b/Libraries/ReactNative/I18nManager.js @@ -18,11 +18,8 @@ const i18nConstants: {| function getI18nManagerConstants() { if (NativeI18nManager) { - const { - isRTL, - doLeftAndRightSwapInRTL, - localeIdentifier, - } = NativeI18nManager.getConstants(); + const {isRTL, doLeftAndRightSwapInRTL, localeIdentifier} = + NativeI18nManager.getConstants(); return {isRTL, doLeftAndRightSwapInRTL, localeIdentifier}; } diff --git a/Libraries/ReactNative/PaperUIManager.js b/Libraries/ReactNative/PaperUIManager.js index 87cc101db31..f3288c871b3 100644 --- a/Libraries/ReactNative/PaperUIManager.js +++ b/Libraries/ReactNative/PaperUIManager.js @@ -38,9 +38,8 @@ function getViewManagerConfig(viewManagerName: string): any { NativeUIManager.getConstantsForViewManager ) { try { - viewManagerConfigs[ - viewManagerName - ] = NativeUIManager.getConstantsForViewManager(viewManagerName); + viewManagerConfigs[viewManagerName] = + NativeUIManager.getConstantsForViewManager(viewManagerName); } catch (e) { console.error( "NativeUIManager.getConstantsForViewManager('" + diff --git a/Libraries/ReactNative/RootTag.js b/Libraries/ReactNative/RootTag.js index 03c83a86af9..b41117a1141 100644 --- a/Libraries/ReactNative/RootTag.js +++ b/Libraries/ReactNative/RootTag.js @@ -13,9 +13,8 @@ import * as React from 'react'; // TODO: Make this into an opaque type. export opaque type RootTag = number; -export const RootTagContext: React$Context = React.createContext( - 0, -); +export const RootTagContext: React$Context = + React.createContext(0); if (__DEV__) { RootTagContext.displayName = 'RootTagContext'; diff --git a/Libraries/Storage/AsyncStorage.js b/Libraries/Storage/AsyncStorage.js index 15080dbc42c..d254e8093f9 100644 --- a/Libraries/Storage/AsyncStorage.js +++ b/Libraries/Storage/AsyncStorage.js @@ -47,13 +47,13 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#getitem */ - getItem: function( + getItem: function ( key: string, callback?: ?(error: ?Error, result: ?string) => void, ): Promise { invariant(RCTAsyncStorage, 'RCTAsyncStorage not available'); return new Promise((resolve, reject) => { - RCTAsyncStorage.multiGet([key], function(errors, result) { + RCTAsyncStorage.multiGet([key], function (errors, result) { // Unpack result to get value from [[key,value]] const value = result && result[0] && result[0][1] ? result[0][1] : null; const errs = convertErrors(errors); @@ -72,14 +72,14 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#setitem */ - setItem: function( + setItem: function ( key: string, value: string, callback?: ?(error: ?Error) => void, ): Promise { invariant(RCTAsyncStorage, 'RCTAsyncStorage not available'); return new Promise((resolve, reject) => { - RCTAsyncStorage.multiSet([[key, value]], function(errors) { + RCTAsyncStorage.multiSet([[key, value]], function (errors) { const errs = convertErrors(errors); callback && callback(errs && errs[0]); if (errs) { @@ -96,13 +96,13 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#removeitem */ - removeItem: function( + removeItem: function ( key: string, callback?: ?(error: ?Error) => void, ): Promise { invariant(RCTAsyncStorage, 'RCTAsyncStorage not available'); return new Promise((resolve, reject) => { - RCTAsyncStorage.multiRemove([key], function(errors) { + RCTAsyncStorage.multiRemove([key], function (errors) { const errs = convertErrors(errors); callback && callback(errs && errs[0]); if (errs) { @@ -122,14 +122,14 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#mergeitem */ - mergeItem: function( + mergeItem: function ( key: string, value: string, callback?: ?(error: ?Error) => void, ): Promise { invariant(RCTAsyncStorage, 'RCTAsyncStorage not available'); return new Promise((resolve, reject) => { - RCTAsyncStorage.multiMerge([[key, value]], function(errors) { + RCTAsyncStorage.multiMerge([[key, value]], function (errors) { const errs = convertErrors(errors); callback && callback(errs && errs[0]); if (errs) { @@ -148,10 +148,10 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#clear */ - clear: function(callback?: ?(error: ?Error) => void): Promise { + clear: function (callback?: ?(error: ?Error) => void): Promise { invariant(RCTAsyncStorage, 'RCTAsyncStorage not available'); return new Promise((resolve, reject) => { - RCTAsyncStorage.clear(function(error) { + RCTAsyncStorage.clear(function (error) { callback && callback(convertError(error)); if (error && convertError(error)) { reject(convertError(error)); @@ -167,12 +167,12 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#getallkeys */ - getAllKeys: function( + getAllKeys: function ( callback?: ?(error: ?Error, keys: ?Array) => void, ): Promise> { invariant(RCTAsyncStorage, 'RCTAsyncStorage not available'); return new Promise((resolve, reject) => { - RCTAsyncStorage.getAllKeys(function(error, keys) { + RCTAsyncStorage.getAllKeys(function (error, keys) { callback && callback(convertError(error), keys); if (error) { reject(convertError(error)); @@ -198,7 +198,7 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#flushgetrequests * */ - flushGetRequests: function(): void { + flushGetRequests: function (): void { const getRequests = this._getRequests; const getKeys = this._getKeys; @@ -206,7 +206,7 @@ const AsyncStorage = { this._getKeys = []; invariant(RCTAsyncStorage, 'RCTAsyncStorage not available'); - RCTAsyncStorage.multiGet(getKeys, function(errors, result) { + RCTAsyncStorage.multiGet(getKeys, function (errors, result) { // Even though the runtime complexity of this is theoretically worse vs if we used a map, // it's much, much faster in practice for the data sets we deal with (we avoid // allocating result pair arrays). This was heavily benchmarked. @@ -237,7 +237,7 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#multiget */ - multiGet: function( + multiGet: function ( keys: Array, callback?: ?(errors: ?Array, result: ?Array>) => void, ): Promise>> { @@ -272,13 +272,13 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#multiset */ - multiSet: function( + multiSet: function ( keyValuePairs: Array>, callback?: ?(errors: ?Array) => void, ): Promise { invariant(RCTAsyncStorage, 'RCTAsyncStorage not available'); return new Promise((resolve, reject) => { - RCTAsyncStorage.multiSet(keyValuePairs, function(errors) { + RCTAsyncStorage.multiSet(keyValuePairs, function (errors) { const error = convertErrors(errors); callback && callback(error); if (error) { @@ -295,13 +295,13 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#multiremove */ - multiRemove: function( + multiRemove: function ( keys: Array, callback?: ?(errors: ?Array) => void, ): Promise { invariant(RCTAsyncStorage, 'RCTAsyncStorage not available'); return new Promise((resolve, reject) => { - RCTAsyncStorage.multiRemove(keys, function(errors) { + RCTAsyncStorage.multiRemove(keys, function (errors) { const error = convertErrors(errors); callback && callback(error); if (error) { @@ -321,13 +321,13 @@ const AsyncStorage = { * * See https://reactnative.dev/docs/asyncstorage.html#multimerge */ - multiMerge: function( + multiMerge: function ( keyValuePairs: Array>, callback?: ?(errors: ?Array) => void, ): Promise { invariant(RCTAsyncStorage, 'RCTAsyncStorage not available'); return new Promise((resolve, reject) => { - RCTAsyncStorage.multiMerge(keyValuePairs, function(errors) { + RCTAsyncStorage.multiMerge(keyValuePairs, function (errors) { const error = convertErrors(errors); callback && callback(error); if (error) { diff --git a/Libraries/StyleSheet/StyleSheet.js b/Libraries/StyleSheet/StyleSheet.js index 785fbfe199e..208e49a9218 100644 --- a/Libraries/StyleSheet/StyleSheet.js +++ b/Libraries/StyleSheet/StyleSheet.js @@ -74,7 +74,8 @@ export type ImageStyleProp = ____ImageStyleProp_Internal; * through to an underlying component. Using this is almost always a mistake * and using one of the other more restrictive types is likely the right choice. */ -export type DangerouslyImpreciseStyleProp = ____DangerouslyImpreciseStyleProp_Internal; +export type DangerouslyImpreciseStyleProp = + ____DangerouslyImpreciseStyleProp_Internal; /** * Utility type for getting the values for specific style keys. diff --git a/Libraries/StyleSheet/StyleSheetTypes.js b/Libraries/StyleSheet/StyleSheetTypes.js index 5a32873e345..8b636caad80 100644 --- a/Libraries/StyleSheet/StyleSheetTypes.js +++ b/Libraries/StyleSheet/StyleSheetTypes.js @@ -673,7 +673,7 @@ export type ____ImageStyleProp_Internal = GenericStyleProp< export type ____Styles_Internal = { +[key: string]: $Shape<____DangerouslyImpreciseStyle_Internal>, - ..., + ... }; export type ____FlattenStyleProp_Internal<+TStyleProp> = $Call< diff --git a/Libraries/StyleSheet/__tests__/normalizeColor-test.js b/Libraries/StyleSheet/__tests__/normalizeColor-test.js index f07498751e2..175cfb23447 100644 --- a/Libraries/StyleSheet/__tests__/normalizeColor-test.js +++ b/Libraries/StyleSheet/__tests__/normalizeColor-test.js @@ -22,10 +22,10 @@ it('forwards calls to @react-native/normalize-color', () => { describe('iOS', () => { if (OS === 'ios') { - const PlatformColor = require('../PlatformColorValueTypes.ios') - .PlatformColor; - const DynamicColorIOS = require('../PlatformColorValueTypesIOS.ios') - .DynamicColorIOS; + const PlatformColor = + require('../PlatformColorValueTypes.ios').PlatformColor; + const DynamicColorIOS = + require('../PlatformColorValueTypesIOS.ios').DynamicColorIOS; it('should normalize iOS PlatformColor colors', () => { const color = PlatformColor('systemRedColor'); @@ -79,8 +79,8 @@ describe('iOS', () => { describe('Android', () => { if (OS === 'android') { - const PlatformColor = require('../PlatformColorValueTypes.android') - .PlatformColor; + const PlatformColor = + require('../PlatformColorValueTypes.android').PlatformColor; it('should normalize Android PlatformColor colors', () => { const color = PlatformColor('?attr/colorPrimary'); diff --git a/Libraries/StyleSheet/__tests__/processColor-test.js b/Libraries/StyleSheet/__tests__/processColor-test.js index d428b854e8f..eeb83fc7356 100644 --- a/Libraries/StyleSheet/__tests__/processColor-test.js +++ b/Libraries/StyleSheet/__tests__/processColor-test.js @@ -13,12 +13,12 @@ const {OS} = require('../../Utilities/Platform'); const processColor = require('../processColor'); -const PlatformColorIOS = require('../PlatformColorValueTypes.ios') - .PlatformColor; -const DynamicColorIOS = require('../PlatformColorValueTypesIOS.ios') - .DynamicColorIOS; -const PlatformColorAndroid = require('../PlatformColorValueTypes.android') - .PlatformColor; +const PlatformColorIOS = + require('../PlatformColorValueTypes.ios').PlatformColor; +const DynamicColorIOS = + require('../PlatformColorValueTypesIOS.ios').DynamicColorIOS; +const PlatformColorAndroid = + require('../PlatformColorValueTypes.android').PlatformColor; const platformSpecific = OS === 'android' diff --git a/Libraries/StyleSheet/__tests__/processColorArray-test.js b/Libraries/StyleSheet/__tests__/processColorArray-test.js index 3ccc582a116..a4d545d5f0a 100644 --- a/Libraries/StyleSheet/__tests__/processColorArray-test.js +++ b/Libraries/StyleSheet/__tests__/processColorArray-test.js @@ -13,12 +13,12 @@ const {OS} = require('../../Utilities/Platform'); const processColorArray = require('../processColorArray'); -const PlatformColorIOS = require('../PlatformColorValueTypes.ios') - .PlatformColor; -const DynamicColorIOS = require('../PlatformColorValueTypesIOS.ios') - .DynamicColorIOS; -const PlatformColorAndroid = require('../PlatformColorValueTypes.android') - .PlatformColor; +const PlatformColorIOS = + require('../PlatformColorValueTypes.ios').PlatformColor; +const DynamicColorIOS = + require('../PlatformColorValueTypesIOS.ios').DynamicColorIOS; +const PlatformColorAndroid = + require('../PlatformColorValueTypes.android').PlatformColor; const platformSpecific = OS === 'android' @@ -70,11 +70,7 @@ describe('processColorArray', () => { const colors = ['red', '???', null, undefined, false]; const colorFromStringArray = processColorArray(colors); const expectedIntArray = [ - 0xffff0000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, + 0xffff0000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, ].map(platformSpecific); expect(colorFromStringArray).toEqual(expectedIntArray); diff --git a/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js b/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js index bc400b56c94..15b40d95e03 100644 --- a/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js +++ b/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js @@ -13,22 +13,22 @@ const setNormalizedColorAlpha = require('../setNormalizedColorAlpha'); const normalizeColor = require('../normalizeColor'); -describe('setNormalizedColorAlpha', function() { - it('should adjust the alpha of the color passed in', function() { +describe('setNormalizedColorAlpha', function () { + it('should adjust the alpha of the color passed in', function () { expect(setNormalizedColorAlpha(0xffffffff, 0.4)).toBe(0xffffff66); expect(setNormalizedColorAlpha(0x204080ff, 0.6)).toBe(0x20408099); }); - it('should clamp invalid input', function() { + it('should clamp invalid input', function () { expect(setNormalizedColorAlpha(0xffffffff, 1.5)).toBe(0xffffffff); expect(setNormalizedColorAlpha(0xffffffff, -1)).toBe(0xffffff00); }); - it("should ignore the color's original alpha", function() { + it("should ignore the color's original alpha", function () { expect(setNormalizedColorAlpha(0x204080aa, 0.8)).toBe(0x204080cc); }); - it('should return the original color when alpha is unchanged', function() { + it('should return the original color when alpha is unchanged', function () { const originalColor = normalizeColor('blue'); expect(setNormalizedColorAlpha(originalColor, 1)).toBe(originalColor); }); diff --git a/Libraries/StyleSheet/processColor.js b/Libraries/StyleSheet/processColor.js index 93a5c383540..af24a1ecf52 100644 --- a/Libraries/StyleSheet/processColor.js +++ b/Libraries/StyleSheet/processColor.js @@ -31,8 +31,8 @@ function processColor(color?: ?(number | ColorValue)): ?ProcessedColorValue { } if (typeof normalizedColor === 'object') { - const processColorObject = require('./PlatformColorValueTypes') - .processColorObject; + const processColorObject = + require('./PlatformColorValueTypes').processColorObject; const processedColorObj = processColorObject(normalizedColor); diff --git a/Libraries/StyleSheet/splitLayoutProps.js b/Libraries/StyleSheet/splitLayoutProps.js index e871390a190..092c6935748 100644 --- a/Libraries/StyleSheet/splitLayoutProps.js +++ b/Libraries/StyleSheet/splitLayoutProps.js @@ -10,9 +10,7 @@ import type {____ViewStyle_Internal} from './StyleSheetTypes'; -export default function splitLayoutProps( - props: ?____ViewStyle_Internal, -): { +export default function splitLayoutProps(props: ?____ViewStyle_Internal): { outer: ?____ViewStyle_Internal, inner: ?____ViewStyle_Internal, } { diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index 22474f0711f..f57cb4eac7e 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -71,7 +71,8 @@ const Text: React.AbstractComponent< setHighlighted(false); onPressOut?.(event); }, - onResponderTerminationRequest_DEPRECATED: onResponderTerminationRequest, + onResponderTerminationRequest_DEPRECATED: + onResponderTerminationRequest, onStartShouldSetResponder_DEPRECATED: onStartShouldSetResponder, } : null, diff --git a/Libraries/Text/TextNativeComponent.js b/Libraries/Text/TextNativeComponent.js index 1263d953bb3..da238a1222a 100644 --- a/Libraries/Text/TextNativeComponent.js +++ b/Libraries/Text/TextNativeComponent.js @@ -21,9 +21,8 @@ type NativeTextProps = $ReadOnly<{ selectionColor?: ?ProcessedColorValue, }>; -export const NativeText: HostComponent = (createReactNativeComponentClass( - 'RCTText', - () => ({ +export const NativeText: HostComponent = + (createReactNativeComponentClass('RCTText', () => ({ validAttributes: { ...ReactNativeViewAttributes.UIView, isHighlighted: true, @@ -51,8 +50,7 @@ export const NativeText: HostComponent = (createReactNativeComp }, }, uiViewClassName: 'RCTText', - }), -): any); + })): any); export const NativeVirtualText: HostComponent = !global.RN$Bridgeless && !UIManager.hasViewManagerConfig('RCTVirtualText') diff --git a/Libraries/Utilities/Appearance.js b/Libraries/Utilities/Appearance.js index ea4c26ac7b3..b66bb92116b 100644 --- a/Libraries/Utilities/Appearance.js +++ b/Libraries/Utilities/Appearance.js @@ -30,11 +30,12 @@ type NativeAppearanceEventDefinitions = { }; if (NativeAppearance) { - const nativeEventEmitter = new NativeEventEmitter( - // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior - // If you want to use the native module on other platforms, please remove this condition and test its behavior - Platform.OS !== 'ios' ? null : NativeAppearance, - ); + const nativeEventEmitter = + new NativeEventEmitter( + // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior + // If you want to use the native module on other platforms, please remove this condition and test its behavior + Platform.OS !== 'ios' ? null : NativeAppearance, + ); nativeEventEmitter.addListener( 'appearanceChanged', (newAppearance: AppearancePreferences) => { diff --git a/Libraries/Utilities/BackHandler.android.js b/Libraries/Utilities/BackHandler.android.js index b4c14b1d783..0f2bcb5e4a3 100644 --- a/Libraries/Utilities/BackHandler.android.js +++ b/Libraries/Utilities/BackHandler.android.js @@ -17,7 +17,7 @@ type BackPressEventName = 'backPress' | 'hardwareBackPress'; const _backPressSubscriptions = []; -RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function() { +RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function () { for (let i = _backPressSubscriptions.length - 1; i >= 0; i--) { if (_backPressSubscriptions[i]()) { return; @@ -65,7 +65,7 @@ type TBackHandler = {| ) => void, |}; const BackHandler: TBackHandler = { - exitApp: function(): void { + exitApp: function (): void { if (!NativeDeviceEventManager) { return; } @@ -78,7 +78,7 @@ const BackHandler: TBackHandler = { * * - `hardwareBackPress`: Fires when the Android hardware back button is pressed. */ - addEventListener: function( + addEventListener: function ( eventName: BackPressEventName, handler: () => ?boolean, ): {remove: () => void, ...} { @@ -93,7 +93,7 @@ const BackHandler: TBackHandler = { /** * Removes the event handler. */ - removeEventListener: function( + removeEventListener: function ( eventName: BackPressEventName, handler: () => ?boolean, ): void { diff --git a/Libraries/Utilities/HMRClient.js b/Libraries/Utilities/HMRClient.js index e1d8f56c49a..30953b16182 100644 --- a/Libraries/Utilities/HMRClient.js +++ b/Libraries/Utilities/HMRClient.js @@ -308,8 +308,8 @@ function dismissRedbox() { ) { NativeRedBox.dismiss(); } else { - const NativeExceptionsManager = require('../Core/NativeExceptionsManager') - .default; + const NativeExceptionsManager = + require('../Core/NativeExceptionsManager').default; NativeExceptionsManager && NativeExceptionsManager.dismissRedbox && NativeExceptionsManager.dismissRedbox(); diff --git a/Libraries/Utilities/JSDevSupportModule.js b/Libraries/Utilities/JSDevSupportModule.js index 396f1a2fb81..c0d0b773fbf 100644 --- a/Libraries/Utilities/JSDevSupportModule.js +++ b/Libraries/Utilities/JSDevSupportModule.js @@ -12,13 +12,12 @@ import NativeJSDevSupport from './NativeJSDevSupport'; const ReactNative = require('../Renderer/shims/ReactNative'); const JSDevSupportModule = { - getJSHierarchy: function(tag: number) { + getJSHierarchy: function (tag: number) { if (NativeJSDevSupport) { const constants = NativeJSDevSupport.getConstants(); try { - const { - computeComponentStackForErrorReporting, - } = ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + const {computeComponentStackForErrorReporting} = + ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; const componentStack = computeComponentStackForErrorReporting(tag); if (!componentStack) { NativeJSDevSupport.onFailure( diff --git a/Libraries/Utilities/MatrixMath.js b/Libraries/Utilities/MatrixMath.js index d2d6421106b..aa25bf63c48 100755 --- a/Libraries/Utilities/MatrixMath.js +++ b/Libraries/Utilities/MatrixMath.js @@ -17,11 +17,11 @@ const invariant = require('invariant'); * matrices, which are reusable. */ const MatrixMath = { - createIdentityMatrix: function() { + createIdentityMatrix: function () { return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; }, - createCopy: function(m) { + createCopy: function (m) { return [ m[0], m[1], @@ -42,7 +42,7 @@ const MatrixMath = { ]; }, - createOrthographic: function(left, right, bottom, top, near, far) { + createOrthographic: function (left, right, bottom, top, near, far) { const a = 2 / (right - left); const b = 2 / (top - bottom); const c = -2 / (far - near); @@ -54,7 +54,7 @@ const MatrixMath = { return [a, 0, 0, 0, 0, b, 0, 0, 0, 0, c, 0, tx, ty, tz, 1]; }, - createFrustum: function(left, right, bottom, top, near, far) { + createFrustum: function (left, right, bottom, top, near, far) { const r_width = 1 / (right - left); const r_height = 1 / (top - bottom); const r_depth = 1 / (near - far); @@ -73,7 +73,7 @@ const MatrixMath = { * * @param fovInRadians - field of view in radians */ - createPerspective: function(fovInRadians, aspect, near, far) { + createPerspective: function (fovInRadians, aspect, near, far) { const h = 1 / Math.tan(fovInRadians / 2); const r_depth = 1 / (near - far); const C = (far + near) * r_depth; @@ -81,41 +81,41 @@ const MatrixMath = { return [h / aspect, 0, 0, 0, 0, h, 0, 0, 0, 0, C, -1, 0, 0, D, 0]; }, - createTranslate2d: function(x, y) { + createTranslate2d: function (x, y) { const mat = MatrixMath.createIdentityMatrix(); MatrixMath.reuseTranslate2dCommand(mat, x, y); return mat; }, - reuseTranslate2dCommand: function(matrixCommand, x, y) { + reuseTranslate2dCommand: function (matrixCommand, x, y) { matrixCommand[12] = x; matrixCommand[13] = y; }, - reuseTranslate3dCommand: function(matrixCommand, x, y, z) { + reuseTranslate3dCommand: function (matrixCommand, x, y, z) { matrixCommand[12] = x; matrixCommand[13] = y; matrixCommand[14] = z; }, - createScale: function(factor) { + createScale: function (factor) { const mat = MatrixMath.createIdentityMatrix(); MatrixMath.reuseScaleCommand(mat, factor); return mat; }, - reuseScaleCommand: function(matrixCommand, factor) { + reuseScaleCommand: function (matrixCommand, factor) { matrixCommand[0] = factor; matrixCommand[5] = factor; }, - reuseScale3dCommand: function(matrixCommand, x, y, z) { + reuseScale3dCommand: function (matrixCommand, x, y, z) { matrixCommand[0] = x; matrixCommand[5] = y; matrixCommand[10] = z; }, - reusePerspectiveCommand: function(matrixCommand, p) { + reusePerspectiveCommand: function (matrixCommand, p) { matrixCommand[11] = -1 / p; }, @@ -131,14 +131,14 @@ const MatrixMath = { matrixCommand[10] = factor; }, - reuseRotateXCommand: function(matrixCommand, radians) { + reuseRotateXCommand: function (matrixCommand, radians) { matrixCommand[5] = Math.cos(radians); matrixCommand[6] = Math.sin(radians); matrixCommand[9] = -Math.sin(radians); matrixCommand[10] = Math.cos(radians); }, - reuseRotateYCommand: function(matrixCommand, amount) { + reuseRotateYCommand: function (matrixCommand, amount) { matrixCommand[0] = Math.cos(amount); matrixCommand[2] = -Math.sin(amount); matrixCommand[8] = Math.sin(amount); @@ -146,28 +146,28 @@ const MatrixMath = { }, // http://www.w3.org/TR/css3-transforms/#recomposing-to-a-2d-matrix - reuseRotateZCommand: function(matrixCommand, radians) { + reuseRotateZCommand: function (matrixCommand, radians) { matrixCommand[0] = Math.cos(radians); matrixCommand[1] = Math.sin(radians); matrixCommand[4] = -Math.sin(radians); matrixCommand[5] = Math.cos(radians); }, - createRotateZ: function(radians) { + createRotateZ: function (radians) { const mat = MatrixMath.createIdentityMatrix(); MatrixMath.reuseRotateZCommand(mat, radians); return mat; }, - reuseSkewXCommand: function(matrixCommand, radians) { + reuseSkewXCommand: function (matrixCommand, radians) { matrixCommand[4] = Math.tan(radians); }, - reuseSkewYCommand: function(matrixCommand, radians) { + reuseSkewYCommand: function (matrixCommand, radians) { matrixCommand[1] = Math.tan(radians); }, - multiplyInto: function(out, a, b) { + multiplyInto: function (out, a, b) { const a00 = a[0], a01 = a[1], a02 = a[2], diff --git a/Libraries/Utilities/PerformanceLoggerContext.js b/Libraries/Utilities/PerformanceLoggerContext.js index 92b77788099..934147902c8 100644 --- a/Libraries/Utilities/PerformanceLoggerContext.js +++ b/Libraries/Utilities/PerformanceLoggerContext.js @@ -19,9 +19,8 @@ import type {IPerformanceLogger} from './createPerformanceLogger'; * should be available in every component. * See React docs about using Context: https://reactjs.org/docs/context.html */ -const PerformanceLoggerContext: React.Context = React.createContext( - GlobalPerformanceLogger, -); +const PerformanceLoggerContext: React.Context = + React.createContext(GlobalPerformanceLogger); if (__DEV__) { PerformanceLoggerContext.displayName = 'PerformanceLoggerContext'; } diff --git a/Libraries/Utilities/SceneTracker.js b/Libraries/Utilities/SceneTracker.js index 23b0c7dcae3..ce078ec6f90 100644 --- a/Libraries/Utilities/SceneTracker.js +++ b/Libraries/Utilities/SceneTracker.js @@ -26,9 +26,10 @@ const SceneTracker = { return _activeScene; }, - addActiveSceneChangedListener( - callback: (scene: Scene) => void, - ): {remove: () => void, ...} { + addActiveSceneChangedListener(callback: (scene: Scene) => void): { + remove: () => void, + ... + } { _listeners.push(callback); return { remove: () => { diff --git a/Libraries/Utilities/__mocks__/BackHandler.js b/Libraries/Utilities/__mocks__/BackHandler.js index b90bf09d870..ba8b111722d 100644 --- a/Libraries/Utilities/__mocks__/BackHandler.js +++ b/Libraries/Utilities/__mocks__/BackHandler.js @@ -14,7 +14,7 @@ const _backPressSubscriptions = new Set(); const BackHandler = { exitApp: jest.fn(), - addEventListener: function( + addEventListener: function ( eventName: BackPressEventName, handler: () => ?boolean, ): {remove: () => void} { @@ -24,14 +24,14 @@ const BackHandler = { }; }, - removeEventListener: function( + removeEventListener: function ( eventName: BackPressEventName, handler: () => ?boolean, ): void { _backPressSubscriptions.delete(handler); }, - mockPressBack: function() { + mockPressBack: function () { let invokeDefault = true; const subscriptions = [..._backPressSubscriptions].reverse(); for (let i = 0; i < subscriptions.length; ++i) { diff --git a/Libraries/Utilities/__tests__/MatrixMath-test.js b/Libraries/Utilities/__tests__/MatrixMath-test.js index f6b62319946..3b657ccb642 100644 --- a/Libraries/Utilities/__tests__/MatrixMath-test.js +++ b/Libraries/Utilities/__tests__/MatrixMath-test.js @@ -24,22 +24,7 @@ describe('MatrixMath', () => { it('decomposes a 4x4 matrix to produce accurate Z-axis angles', () => { expect( MatrixMath.decomposeMatrix([ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, + 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, ]).rotationDegrees, ).toEqual([0, 0, 0]); @@ -140,17 +125,13 @@ describe('MatrixMath', () => { mat = MatrixMath.createIdentityMatrix(); MatrixMath.reuseRotateYCommand(mat, degreesToRadians(222)); expect(MatrixMath.decomposeMatrix(mat).rotationDegrees).toEqual([ - 0, - -138, - 0, + 0, -138, 0, ]); mat = MatrixMath.createIdentityMatrix(); MatrixMath.reuseRotateYCommand(mat, degreesToRadians(270)); expect(MatrixMath.decomposeMatrix(mat).rotationDegrees).toEqual([ - 0, - -90, - 0, + 0, -90, 0, ]); mat = MatrixMath.createIdentityMatrix(); @@ -173,17 +154,13 @@ describe('MatrixMath', () => { mat = MatrixMath.createIdentityMatrix(); MatrixMath.reuseRotateXCommand(mat, degreesToRadians(222)); expect(MatrixMath.decomposeMatrix(mat).rotationDegrees).toEqual([ - -138, - 0, - 0, + -138, 0, 0, ]); mat = MatrixMath.createIdentityMatrix(); MatrixMath.reuseRotateXCommand(mat, degreesToRadians(270)); expect(MatrixMath.decomposeMatrix(mat).rotationDegrees).toEqual([ - -90, - 0, - 0, + -90, 0, 0, ]); mat = MatrixMath.createIdentityMatrix(); diff --git a/Libraries/Utilities/__tests__/SceneTracker-test.js b/Libraries/Utilities/__tests__/SceneTracker-test.js index 909da1685aa..b3530bf7638 100644 --- a/Libraries/Utilities/__tests__/SceneTracker-test.js +++ b/Libraries/Utilities/__tests__/SceneTracker-test.js @@ -12,8 +12,8 @@ const SceneTracker = require('../SceneTracker'); -describe('setActiveScene', function() { - it('can handle multiple listeners and unsubscribe', function() { +describe('setActiveScene', function () { + it('can handle multiple listeners and unsubscribe', function () { const listeners = [jest.fn(), jest.fn(), jest.fn()]; const subscriptions = listeners.map(listener => SceneTracker.addActiveSceneChangedListener(listener), diff --git a/Libraries/Utilities/__tests__/buildStyleInterpolator-test.js b/Libraries/Utilities/__tests__/buildStyleInterpolator-test.js index ef5cc10d42d..2c0a597086a 100644 --- a/Libraries/Utilities/__tests__/buildStyleInterpolator-test.js +++ b/Libraries/Utilities/__tests__/buildStyleInterpolator-test.js @@ -12,7 +12,7 @@ const buildStyleInterpolator = require('../buildStyleInterpolator'); -const validateEmpty = function(interpolator, value, validator) { +const validateEmpty = function (interpolator, value, validator) { const emptyObject = {}; let changed = interpolator(emptyObject, value); validator(emptyObject); @@ -20,8 +20,8 @@ const validateEmpty = function(interpolator, value, validator) { changed = interpolator(emptyObject, value); expect(changed).toBe(false); }; -describe('buildStyleInterpolator', function() { - it('should linearly interpolate without extrapolating', function() { +describe('buildStyleInterpolator', function () { + it('should linearly interpolate without extrapolating', function () { const testAnim = { opacity: { from: 100, @@ -45,35 +45,35 @@ describe('buildStyleInterpolator', function() { }, }; const interpolator = buildStyleInterpolator(testAnim); - validateEmpty(interpolator, 0, function(res) { + validateEmpty(interpolator, 0, function (res) { expect(res).toEqual({ opacity: 100, left: 200, top: 23.5, }); }); - validateEmpty(interpolator, 1, function(res) { + validateEmpty(interpolator, 1, function (res) { expect(res).toEqual({ opacity: 200, left: 300, top: 23.5, }); }); - validateEmpty(interpolator, -0.1, function(res) { + validateEmpty(interpolator, -0.1, function (res) { expect(res).toEqual({ opacity: 100, left: 200, top: 23.5, }); }); - validateEmpty(interpolator, 1.1, function(res) { + validateEmpty(interpolator, 1.1, function (res) { expect(res).toEqual({ opacity: 200, left: 300, top: 23.5, }); }); - validateEmpty(interpolator, 0.5, function(res) { + validateEmpty(interpolator, 0.5, function (res) { expect(res).toEqual({ opacity: 150, left: 250, @@ -81,7 +81,7 @@ describe('buildStyleInterpolator', function() { }); }); }); - it('should linearly interpolate with extrapolating', function() { + it('should linearly interpolate with extrapolating', function () { const testAnim = { opacity: { from: 100, @@ -107,35 +107,35 @@ describe('buildStyleInterpolator', function() { }, }; const interpolator = buildStyleInterpolator(testAnim); - validateEmpty(interpolator, 0, function(res) { + validateEmpty(interpolator, 0, function (res) { expect(res).toEqual({ opacity: 100, left: 200, top: 23.5, }); }); - validateEmpty(interpolator, 1, function(res) { + validateEmpty(interpolator, 1, function (res) { expect(res).toEqual({ opacity: 200, left: 300, top: 23.5, }); }); - validateEmpty(interpolator, -0.1, function(res) { + validateEmpty(interpolator, -0.1, function (res) { expect(res).toEqual({ opacity: 90, left: 190, top: 23.5, }); }); - validateEmpty(interpolator, 1.1, function(res) { + validateEmpty(interpolator, 1.1, function (res) { expect(res).toEqual({ opacity: 210, left: 310, top: 23.5, }); }); - validateEmpty(interpolator, 0.5, function(res) { + validateEmpty(interpolator, 0.5, function (res) { expect(res).toEqual({ opacity: 150, left: 250, @@ -143,7 +143,7 @@ describe('buildStyleInterpolator', function() { }); }); }); - it('should round accordingly', function() { + it('should round accordingly', function () { const testAnim = { opacity: { from: 0, @@ -156,38 +156,38 @@ describe('buildStyleInterpolator', function() { }, }; const interpolator = buildStyleInterpolator(testAnim); - validateEmpty(interpolator, 0, function(res) { + validateEmpty(interpolator, 0, function (res) { expect(res).toEqual({ opacity: 0, }); }); - validateEmpty(interpolator, 0.5, function(res) { + validateEmpty(interpolator, 0.5, function (res) { expect(res).toEqual({ opacity: 0.5, }); }); - validateEmpty(interpolator, 0.4, function(res) { + validateEmpty(interpolator, 0.4, function (res) { expect(res).toEqual({ opacity: 0.5, }); }); - validateEmpty(interpolator, 0.26, function(res) { + validateEmpty(interpolator, 0.26, function (res) { expect(res).toEqual({ opacity: 0.5, }); }); - validateEmpty(interpolator, 0.74, function(res) { + validateEmpty(interpolator, 0.74, function (res) { expect(res).toEqual({ opacity: 0.5, }); }); - validateEmpty(interpolator, 0.76, function(res) { + validateEmpty(interpolator, 0.76, function (res) { expect(res).toEqual({ opacity: 1.0, }); }); }); - it('should detect changes correctly', function() { + it('should detect changes correctly', function () { const testAnim = { opacity: { from: 0, @@ -228,7 +228,7 @@ describe('buildStyleInterpolator', function() { }); expect(res).toBe(false); }); - it('should handle identity', function() { + it('should handle identity', function () { const testAnim = { opacity: { type: 'identity', @@ -249,7 +249,7 @@ describe('buildStyleInterpolator', function() { }); expect(res).toBe(false); }); - it('should translate', function() { + it('should translate', function () { const testAnim = { transformTranslate: { from: {x: 1, y: 10, z: 100}, @@ -271,7 +271,7 @@ describe('buildStyleInterpolator', function() { }); expect(res).toBe(true); }); - it('should scale', function() { + it('should scale', function () { const testAnim = { transformScale: { from: {x: 1, y: 10, z: 100}, @@ -293,7 +293,7 @@ describe('buildStyleInterpolator', function() { }); expect(res).toBe(true); }); - it('should combine scale and translate', function() { + it('should combine scale and translate', function () { const testAnim = { transformScale: { from: {x: 1, y: 10, z: 100}, @@ -322,7 +322,7 @@ describe('buildStyleInterpolator', function() { }); expect(res).toBe(true); }); - it('should step', function() { + it('should step', function () { const testAnim = { opacity: { threshold: 13, diff --git a/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js b/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js index b813f2fbbd5..65cf9cd6b21 100644 --- a/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js +++ b/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js @@ -10,7 +10,7 @@ const deepFreezeAndThrowOnMutationInDev = require('../deepFreezeAndThrowOnMutationInDev'); -describe('deepFreezeAndThrowOnMutationInDev', function() { +describe('deepFreezeAndThrowOnMutationInDev', function () { it('should be a noop on non object values', () => { __DEV__ = true; expect(() => deepFreezeAndThrowOnMutationInDev('')).not.toThrow(); diff --git a/Libraries/Utilities/__tests__/mapWithSeparator-test.js b/Libraries/Utilities/__tests__/mapWithSeparator-test.js index 1adbc2bcb15..e1743c6c750 100644 --- a/Libraries/Utilities/__tests__/mapWithSeparator-test.js +++ b/Libraries/Utilities/__tests__/mapWithSeparator-test.js @@ -17,10 +17,10 @@ describe('mapWithSeparator', () => { const array = [1, 2, 3]; const result = mapWithSeparator( array, - function(value) { + function (value) { return value * 2; }, - function() { + function () { return 0; }, ); @@ -31,10 +31,10 @@ describe('mapWithSeparator', () => { const array = [1, 2, 3]; const result = mapWithSeparator( array, - function(value, index) { + function (value, index) { return index; }, - function(index) { + function (index) { return index; }, ); @@ -45,10 +45,10 @@ describe('mapWithSeparator', () => { const array = [3, 2, 1]; const result = mapWithSeparator( array, - function(value, index, arr) { + function (value, index, arr) { return arr[index]; }, - function(index) { + function (index) { return index; }, ); @@ -59,10 +59,10 @@ describe('mapWithSeparator', () => { const array = []; const result = mapWithSeparator( array, - function(value) { + function (value) { return value * 2; }, - function() { + function () { return 0; }, ); diff --git a/Libraries/Utilities/__tests__/stringifySafe-test.js b/Libraries/Utilities/__tests__/stringifySafe-test.js index f6cb307cf22..00aac657bad 100644 --- a/Libraries/Utilities/__tests__/stringifySafe-test.js +++ b/Libraries/Utilities/__tests__/stringifySafe-test.js @@ -25,7 +25,7 @@ describe('stringifySafe', () => { }); it('stringifySafe stringifies function values', () => { - expect(stringifySafe(function() {})).toEqual('function () {}'); + expect(stringifySafe(function () {})).toEqual('function () {}'); }); it('stringifySafe stringifies non-circular objects', () => { diff --git a/Libraries/Utilities/__tests__/useMergeRefs-test.js b/Libraries/Utilities/__tests__/useMergeRefs-test.js index 73627f3ee70..6aa105a5b8a 100644 --- a/Libraries/Utilities/__tests__/useMergeRefs-test.js +++ b/Libraries/Utilities/__tests__/useMergeRefs-test.js @@ -66,9 +66,11 @@ function mockRefRegistry(): { } { const registry = []; return { - mockCallbackRef: (name: string): (T => mixed) => current => { - registry.push({[name]: TestViewInstance.fromValue(current)}); - }, + mockCallbackRef: + (name: string): (T => mixed) => + current => { + registry.push({[name]: TestViewInstance.fromValue(current)}); + }, mockObjectRef: (name: string): {current: T, ...} => ({ // $FlowIgnore[unsafe-getters-setters] - Intentional. set current(current) { diff --git a/Libraries/Utilities/__tests__/verifyComponentAttributeEquivalence-test.js b/Libraries/Utilities/__tests__/verifyComponentAttributeEquivalence-test.js index 43a507335d3..6ba3bf70b84 100644 --- a/Libraries/Utilities/__tests__/verifyComponentAttributeEquivalence-test.js +++ b/Libraries/Utilities/__tests__/verifyComponentAttributeEquivalence-test.js @@ -12,8 +12,8 @@ jest.dontMock('../verifyComponentAttributeEquivalence'); -const verifyComponentAttributeEquivalence = require('../verifyComponentAttributeEquivalence') - .default; +const verifyComponentAttributeEquivalence = + require('../verifyComponentAttributeEquivalence').default; const TestComponentNativeViewConfig = { uiViewClassName: 'TestComponent', diff --git a/Libraries/Utilities/buildStyleInterpolator.js b/Libraries/Utilities/buildStyleInterpolator.js index ed86a32df6b..b647ed0f1a7 100644 --- a/Libraries/Utilities/buildStyleInterpolator.js +++ b/Libraries/Utilities/buildStyleInterpolator.js @@ -19,7 +19,7 @@ const InitialOperationField = { }; const InterpolateMatrix = { - transformScale: function(mat, x, y, z) { + transformScale: function (mat, x, y, z) { mat[0] = mat[0] * x; mat[1] = mat[1] * x; mat[2] = mat[2] * x; @@ -33,7 +33,7 @@ const InterpolateMatrix = { mat[10] = mat[10] * z; mat[11] = mat[11] * z; }, - transformTranslate: function(mat, x, y, z) { + transformTranslate: function (mat, x, y, z) { mat[12] = mat[0] * x + mat[4] * y + mat[8] * z + mat[12]; mat[13] = mat[1] * x + mat[5] * y + mat[9] * z + mat[13]; mat[14] = mat[2] * x + mat[6] * y + mat[10] * z + mat[14]; @@ -41,7 +41,7 @@ const InterpolateMatrix = { }, }; -const computeNextValLinear = function(anim, from, to, value) { +const computeNextValLinear = function (anim, from, to, value) { const hasRoundRatio = 'round' in anim; const roundRatio = anim.round; let ratio = (value - anim.min) / (anim.max - anim.min); @@ -58,11 +58,11 @@ const computeNextValLinear = function(anim, from, to, value) { return nextVal; }; -const computeNextValLinearScalar = function(anim, value) { +const computeNextValLinearScalar = function (anim, value) { return computeNextValLinear(anim, anim.from, anim.to, value); }; -const setNextValAndDetectChange = function(result, name, nextVal, didChange) { +const setNextValAndDetectChange = function (result, name, nextVal, didChange) { if (!didChange) { const prevVal = result[name]; result[name] = nextVal; @@ -73,7 +73,7 @@ const setNextValAndDetectChange = function(result, name, nextVal, didChange) { return didChange; }; -const initIdentity = function(mat) { +const initIdentity = function (mat) { mat[0] = 1; mat[1] = 0; mat[2] = 0; @@ -92,7 +92,7 @@ const initIdentity = function(mat) { mat[15] = 1; }; -const computeNextMatrixOperationField = function( +const computeNextMatrixOperationField = function ( anim, name, dim, @@ -106,7 +106,7 @@ const computeNextMatrixOperationField = function( } }; -const computeTransform = function( +const computeTransform = function ( anim, name, value, @@ -169,7 +169,7 @@ const computeTransform = function( * @return {function} Function accepting style object, that mutates that style * object and returns a boolean describing if any update was actually applied. */ -const buildStyleInterpolator = function(anims) { +const buildStyleInterpolator = function (anims) { function styleInterpolator(result, value) { let didChange = false; let didMatrix = false; diff --git a/Libraries/Utilities/codegenNativeComponent.js b/Libraries/Utilities/codegenNativeComponent.js index 129de1ad44a..eb1bf7f8ec2 100644 --- a/Libraries/Utilities/codegenNativeComponent.js +++ b/Libraries/Utilities/codegenNativeComponent.js @@ -43,8 +43,9 @@ function codegenNativeComponent( componentNameInUse = options.paperComponentNameDeprecated; } else { throw new Error( - `Failed to find native component for either ${componentName} or ${options.paperComponentNameDeprecated ?? - '(unknown)'}`, + `Failed to find native component for either ${componentName} or ${ + options.paperComponentNameDeprecated ?? '(unknown)' + }`, ); } } diff --git a/Libraries/Utilities/differ/__tests__/deepDiffer-test.js b/Libraries/Utilities/differ/__tests__/deepDiffer-test.js index d1a35a20589..a18c3bf3cf0 100644 --- a/Libraries/Utilities/differ/__tests__/deepDiffer-test.js +++ b/Libraries/Utilities/differ/__tests__/deepDiffer-test.js @@ -12,7 +12,7 @@ const deepDiffer = require('../deepDiffer'); -describe('deepDiffer', function() { +describe('deepDiffer', function () { it('should diff primitives of the same type', () => { expect(deepDiffer(1, 2)).toBe(true); expect(deepDiffer(42, 42)).toBe(false); diff --git a/Libraries/Utilities/differ/__tests__/matricesDiffer-test.js b/Libraries/Utilities/differ/__tests__/matricesDiffer-test.js index 26cc35ce3f5..9f740a498ce 100644 --- a/Libraries/Utilities/differ/__tests__/matricesDiffer-test.js +++ b/Libraries/Utilities/differ/__tests__/matricesDiffer-test.js @@ -12,7 +12,7 @@ const matricesDiffer = require('../matricesDiffer'); -describe('matricesDiffer', function() { +describe('matricesDiffer', function () { it('diffs matrices with single element', () => { var x = [1]; var y = [2]; diff --git a/Libraries/Utilities/differ/deepDiffer.js b/Libraries/Utilities/differ/deepDiffer.js index ff8bd4628d1..d6dc88c8cb3 100644 --- a/Libraries/Utilities/differ/deepDiffer.js +++ b/Libraries/Utilities/differ/deepDiffer.js @@ -25,7 +25,7 @@ function unstable_setLogListeners(listeners: ?LogListeners) { /* * @returns {bool} true if different, false if equal */ -const deepDiffer = function( +const deepDiffer = function ( one: any, two: any, maxDepthOrOptions: Options | number = -1, diff --git a/Libraries/Utilities/differ/insetsDiffer.js b/Libraries/Utilities/differ/insetsDiffer.js index 48aa7cac3c8..89b0f33a739 100644 --- a/Libraries/Utilities/differ/insetsDiffer.js +++ b/Libraries/Utilities/differ/insetsDiffer.js @@ -25,7 +25,7 @@ const dummyInsets = { bottom: undefined, }; -const insetsDiffer = function(one: Inset, two: Inset): boolean { +const insetsDiffer = function (one: Inset, two: Inset): boolean { one = one || dummyInsets; two = two || dummyInsets; return ( diff --git a/Libraries/Utilities/differ/matricesDiffer.js b/Libraries/Utilities/differ/matricesDiffer.js index 1726ad361e3..51bd170a03b 100644 --- a/Libraries/Utilities/differ/matricesDiffer.js +++ b/Libraries/Utilities/differ/matricesDiffer.js @@ -18,7 +18,7 @@ * @param {MatrixMath.Matrix} two Second matrix. * @return {boolean} Whether or not the two matrices differ. */ -const matricesDiffer = function(one, two) { +const matricesDiffer = function (one, two) { if (one === two) { return false; } diff --git a/Libraries/Utilities/differ/pointsDiffer.js b/Libraries/Utilities/differ/pointsDiffer.js index 28d94a3b706..7250ac9ecac 100644 --- a/Libraries/Utilities/differ/pointsDiffer.js +++ b/Libraries/Utilities/differ/pointsDiffer.js @@ -18,7 +18,7 @@ type Point = { const dummyPoint = {x: undefined, y: undefined}; -const pointsDiffer = function(one: ?Point, two: ?Point): boolean { +const pointsDiffer = function (one: ?Point, two: ?Point): boolean { one = one || dummyPoint; two = two || dummyPoint; return one !== two && (one.x !== two.x || one.y !== two.y); diff --git a/Libraries/Utilities/differ/sizesDiffer.js b/Libraries/Utilities/differ/sizesDiffer.js index 63ab71d3243..6b38bf7d46e 100644 --- a/Libraries/Utilities/differ/sizesDiffer.js +++ b/Libraries/Utilities/differ/sizesDiffer.js @@ -11,7 +11,7 @@ const dummySize = {width: undefined, height: undefined}; -const sizesDiffer = function(one, two) { +const sizesDiffer = function (one, two) { one = one || dummySize; two = two || dummySize; return one !== two && (one.width !== two.width || one.height !== two.height); diff --git a/Libraries/Utilities/logError.js b/Libraries/Utilities/logError.js index 45252c6d0f6..c8322d34a72 100644 --- a/Libraries/Utilities/logError.js +++ b/Libraries/Utilities/logError.js @@ -15,7 +15,7 @@ * `console.error` as a failure callback - it's not properly bound. If passes an * `Error` object, it will print the message and stack. */ -const logError = function(...args: $ReadOnlyArray) { +const logError = function (...args: $ReadOnlyArray) { if (args.length === 1 && args[0] instanceof Error) { const err = args[0]; console.error('Error: "' + err.message + '". Stack:\n' + err.stack); diff --git a/Libraries/Utilities/mergeIntoFast.js b/Libraries/Utilities/mergeIntoFast.js index 663f897ae5d..5a1a27c2e23 100644 --- a/Libraries/Utilities/mergeIntoFast.js +++ b/Libraries/Utilities/mergeIntoFast.js @@ -17,7 +17,7 @@ * @param {object} one Object to assign to. * @param {object} two Object to assign from. */ -const mergeIntoFast = function(one: Object, two: Object): void { +const mergeIntoFast = function (one: Object, two: Object): void { for (const keyTwo in two) { one[keyTwo] = two[keyTwo]; } diff --git a/Libraries/Utilities/truncate.js b/Libraries/Utilities/truncate.js index fb3814b4a5a..a06371a8052 100644 --- a/Libraries/Utilities/truncate.js +++ b/Libraries/Utilities/truncate.js @@ -24,7 +24,7 @@ const defaultOptions = { }; // maxChars (including ellipsis) -const truncate = function( +const truncate = function ( str: ?string, maxChars: number, options?: truncateOptions, diff --git a/Libraries/Vibration/Vibration.js b/Libraries/Vibration/Vibration.js index 797928a7d3d..dc315746298 100644 --- a/Libraries/Vibration/Vibration.js +++ b/Libraries/Vibration/Vibration.js @@ -70,7 +70,7 @@ const Vibration = { * * See https://reactnative.dev/docs/vibration.html#vibrate */ - vibrate: function( + vibrate: function ( pattern: number | Array = _default_vibration_length, repeat: boolean = false, ) { @@ -100,7 +100,7 @@ const Vibration = { * * See https://reactnative.dev/docs/vibration.html#cancel */ - cancel: function() { + cancel: function () { if (Platform.OS === 'ios') { _vibrating = false; } else { diff --git a/Libraries/WebSocket/WebSocketInterceptor.js b/Libraries/WebSocket/WebSocketInterceptor.js index db8c7d215e1..0e4a78d630b 100644 --- a/Libraries/WebSocket/WebSocketInterceptor.js +++ b/Libraries/WebSocket/WebSocketInterceptor.js @@ -142,7 +142,7 @@ const WebSocketInterceptor = { // Override `connect` method for all RCTWebSocketModule requests // to intercept the request url, protocols, options and socketId, // then pass them through the `connectCallback`. - NativeWebSocketModule.connect = function( + NativeWebSocketModule.connect = function ( url, protocols, options, @@ -156,7 +156,7 @@ const WebSocketInterceptor = { // Override `send` method for all RCTWebSocketModule requests to intercept // the data sent, then pass them through the `sendCallback`. - NativeWebSocketModule.send = function(data, socketId) { + NativeWebSocketModule.send = function (data, socketId) { if (sendCallback) { sendCallback(data, socketId); } @@ -165,7 +165,7 @@ const WebSocketInterceptor = { // Override `sendBinary` method for all RCTWebSocketModule requests to // intercept the data sent, then pass them through the `sendCallback`. - NativeWebSocketModule.sendBinary = function(data, socketId) { + NativeWebSocketModule.sendBinary = function (data, socketId) { if (sendCallback) { sendCallback(WebSocketInterceptor._arrayBufferToString(data), socketId); } @@ -174,7 +174,7 @@ const WebSocketInterceptor = { // Override `close` method for all RCTWebSocketModule requests to intercept // the close information, then pass them through the `closeCallback`. - NativeWebSocketModule.close = function() { + NativeWebSocketModule.close = function () { if (closeCallback) { if (arguments.length === 3) { closeCallback(arguments[0], arguments[1], arguments[2]); diff --git a/Libraries/WebSocket/__tests__/WebSocket-test.js b/Libraries/WebSocket/__tests__/WebSocket-test.js index 52d8fb5b375..a2e30b66cc7 100644 --- a/Libraries/WebSocket/__tests__/WebSocket-test.js +++ b/Libraries/WebSocket/__tests__/WebSocket-test.js @@ -20,7 +20,7 @@ jest.setMock('../../BatchedBridge/NativeModules', { const WebSocket = require('../WebSocket'); -describe('WebSocket', function() { +describe('WebSocket', function () { it('should have connection lifecycle constants defined on the class', () => { expect(WebSocket.CONNECTING).toEqual(0); }); diff --git a/Libraries/promiseRejectionTrackingOptions.js b/Libraries/promiseRejectionTrackingOptions.js index ac828127df5..caabab05e34 100644 --- a/Libraries/promiseRejectionTrackingOptions.js +++ b/Libraries/promiseRejectionTrackingOptions.js @@ -10,7 +10,7 @@ import typeof {enable} from 'promise/setimmediate/rejection-tracking'; -type ExtractOptionsType =

((options?: ?P) => void) => P; +type ExtractOptionsType =

(((options?: ?P) => void)) => P; let rejectionTrackingOptions: $Call = { allRejections: true, diff --git a/ReactAndroid/src/androidTest/js/Asserts.js b/ReactAndroid/src/androidTest/js/Asserts.js index 2c9710fbd93..ea6eca6248f 100644 --- a/ReactAndroid/src/androidTest/js/Asserts.js +++ b/ReactAndroid/src/androidTest/js/Asserts.js @@ -14,7 +14,7 @@ const {NativeModules} = require('react-native'); const {Assert} = NativeModules; const Asserts = { - assertEquals: function(expected, actual, msg) { + assertEquals: function (expected, actual, msg) { if (expected !== actual) { Assert.fail( msg || @@ -30,7 +30,7 @@ const Asserts = { Assert.success(); } }, - assertTrue: function(expr, msg) { + assertTrue: function (expr, msg) { Asserts.assertEquals(true, expr, msg); }, }; diff --git a/ReactAndroid/src/androidTest/js/CatalystRootViewTestModule.js b/ReactAndroid/src/androidTest/js/CatalystRootViewTestModule.js index dd02631da37..c2adb598214 100644 --- a/ReactAndroid/src/androidTest/js/CatalystRootViewTestModule.js +++ b/ReactAndroid/src/androidTest/js/CatalystRootViewTestModule.js @@ -41,7 +41,7 @@ class CatalystRootViewTestApp extends React.Component { } const ReactRootViewTestModule = { - setHeight: function(height) { + setHeight: function (height) { that.setState({height: height}); }, }; diff --git a/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js b/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js index dfca8095e2a..4e3d342ba0c 100644 --- a/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js +++ b/ReactAndroid/src/androidTest/js/MeasureLayoutTestModule.js @@ -71,90 +71,41 @@ function shouldNotCallThisCallback() { const MeasureLayoutTestModule = { MeasureLayoutTestApp: MeasureLayoutTestApp, - verifyMeasureOnViewA: function() { - UIManager.measure(A, function(a, b, width, height, x, y) { + verifyMeasureOnViewA: function () { + UIManager.measure(A, function (a, b, width, height, x, y) { assertEquals(500, width); assertEquals(500, height); assertEquals(0, x); assertEquals(0, y); }); }, - verifyMeasureOnViewC: function() { - UIManager.measure(C, function(a, b, width, height, x, y) { + verifyMeasureOnViewC: function () { + UIManager.measure(C, function (a, b, width, height, x, y) { assertEquals(50, width); assertEquals(150, height); assertEquals(150, x); assertEquals(150, y); }); }, - verifyMeasureLayoutCRelativeToA: function() { - UIManager.measureLayout(C, A, shouldNotCallThisCallback, function( - x, - y, - width, - height, - ) { - assertEquals(50, width); - assertEquals(150, height); - assertEquals(150, x); - assertEquals(150, y); - }); - }, - verifyMeasureLayoutCRelativeToB: function() { - UIManager.measureLayout(C, B, shouldNotCallThisCallback, function( - x, - y, - width, - height, - ) { - assertEquals(50, width); - assertEquals(150, height); - assertEquals(100, x); - assertEquals(70, y); - }); - }, - verifyMeasureLayoutCRelativeToSelf: function() { - UIManager.measureLayout(C, C, shouldNotCallThisCallback, function( - x, - y, - width, - height, - ) { - assertEquals(50, width); - assertEquals(150, height); - assertEquals(0, x); - assertEquals(0, y); - }); - }, - verifyMeasureLayoutRelativeToParentOnViewA: function() { - UIManager.measureLayoutRelativeToParent( + verifyMeasureLayoutCRelativeToA: function () { + UIManager.measureLayout( + C, A, shouldNotCallThisCallback, - function(x, y, width, height) { - assertEquals(500, width); - assertEquals(500, height); - assertEquals(0, x); - assertEquals(0, y); + function (x, y, width, height) { + assertEquals(50, width); + assertEquals(150, height); + assertEquals(150, x); + assertEquals(150, y); }, ); }, - verifyMeasureLayoutRelativeToParentOnViewB: function() { - UIManager.measureLayoutRelativeToParent( + verifyMeasureLayoutCRelativeToB: function () { + UIManager.measureLayout( + C, B, shouldNotCallThisCallback, - function(x, y, width, height) { - assertEquals(200, width); - assertEquals(300, height); - assertEquals(50, x); - assertEquals(80, y); - }, - ); - }, - verifyMeasureLayoutRelativeToParentOnViewC: function() { - UIManager.measureLayoutRelativeToParent( - C, - shouldNotCallThisCallback, - function(x, y, width, height) { + function (x, y, width, height) { assertEquals(50, width); assertEquals(150, height); assertEquals(100, x); @@ -162,40 +113,89 @@ const MeasureLayoutTestModule = { }, ); }, - verifyMeasureLayoutDRelativeToB: function() { + verifyMeasureLayoutCRelativeToSelf: function () { + UIManager.measureLayout( + C, + C, + shouldNotCallThisCallback, + function (x, y, width, height) { + assertEquals(50, width); + assertEquals(150, height); + assertEquals(0, x); + assertEquals(0, y); + }, + ); + }, + verifyMeasureLayoutRelativeToParentOnViewA: function () { + UIManager.measureLayoutRelativeToParent( + A, + shouldNotCallThisCallback, + function (x, y, width, height) { + assertEquals(500, width); + assertEquals(500, height); + assertEquals(0, x); + assertEquals(0, y); + }, + ); + }, + verifyMeasureLayoutRelativeToParentOnViewB: function () { + UIManager.measureLayoutRelativeToParent( + B, + shouldNotCallThisCallback, + function (x, y, width, height) { + assertEquals(200, width); + assertEquals(300, height); + assertEquals(50, x); + assertEquals(80, y); + }, + ); + }, + verifyMeasureLayoutRelativeToParentOnViewC: function () { + UIManager.measureLayoutRelativeToParent( + C, + shouldNotCallThisCallback, + function (x, y, width, height) { + assertEquals(50, width); + assertEquals(150, height); + assertEquals(100, x); + assertEquals(70, y); + }, + ); + }, + verifyMeasureLayoutDRelativeToB: function () { UIManager.measureLayout( D, B, - function() { + function () { assertEquals(true, true); }, shouldNotCallThisCallback, ); }, - verifyMeasureLayoutNonExistentTag: function() { + verifyMeasureLayoutNonExistentTag: function () { UIManager.measureLayout( 192, A, - function() { + function () { assertEquals(true, true); }, shouldNotCallThisCallback, ); }, - verifyMeasureLayoutNonExistentAncestor: function() { + verifyMeasureLayoutNonExistentAncestor: function () { UIManager.measureLayout( B, 192, - function() { + function () { assertEquals(true, true); }, shouldNotCallThisCallback, ); }, - verifyMeasureLayoutRelativeToParentNonExistentTag: function() { + verifyMeasureLayoutRelativeToParentNonExistentTag: function () { UIManager.measureLayoutRelativeToParent( 192, - function() { + function () { assertEquals(true, true); }, shouldNotCallThisCallback, diff --git a/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js b/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js index 655c747ee7c..42d85a20541 100644 --- a/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js +++ b/ReactAndroid/src/androidTest/js/ProgressBarTestModule.js @@ -40,7 +40,7 @@ class ProgressBarSampleApp extends React.Component { } const ProgressBarTestModule = { - renderProgressBarApplication: function(rootTag) { + renderProgressBarApplication: function (rootTag) { renderApplication(ProgressBarSampleApp, {}, rootTag); }, }; diff --git a/ReactAndroid/src/androidTest/js/ScrollViewTestModule.js b/ReactAndroid/src/androidTest/js/ScrollViewTestModule.js index 11ee033dc84..c138a80ddfc 100644 --- a/ReactAndroid/src/androidTest/js/ScrollViewTestModule.js +++ b/ReactAndroid/src/androidTest/js/ScrollViewTestModule.js @@ -51,7 +51,7 @@ class Item extends React.Component { } } -const getInitialState = function() { +const getInitialState = function () { const data = []; for (let i = 0; i < NUM_ITEMS; i++) { data[i] = {text: 'Item ' + i + '!'}; @@ -61,28 +61,28 @@ const getInitialState = function() { }; }; -const onScroll = function(e) { +const onScroll = function (e) { ScrollListener.onScroll( e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y, ); }; -const onScrollBeginDrag = function(e) { +const onScrollBeginDrag = function (e) { ScrollListener.onScrollBeginDrag( e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y, ); }; -const onScrollEndDrag = function(e) { +const onScrollEndDrag = function (e) { ScrollListener.onScrollEndDrag( e.nativeEvent.contentOffset.x, e.nativeEvent.contentOffset.y, ); }; -const onItemPress = function(itemNumber) { +const onItemPress = function (itemNumber) { ScrollListener.onItemPress(itemNumber); }; diff --git a/ReactAndroid/src/androidTest/js/ShareTestModule.js b/ReactAndroid/src/androidTest/js/ShareTestModule.js index fc80b761a12..b1409298c63 100644 --- a/ReactAndroid/src/androidTest/js/ShareTestModule.js +++ b/ReactAndroid/src/androidTest/js/ShareTestModule.js @@ -23,7 +23,7 @@ class ShareTestApp extends React.Component { const ShareTestModule = { ShareTestApp: ShareTestApp, - showShareDialog: function(content, options) { + showShareDialog: function (content, options) { Share.share(content, options).then( () => RecordingModule.recordOpened(), ({code, message}) => RecordingModule.recordError(), diff --git a/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js b/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js index ee2367f8b7c..6ee56d3bf49 100644 --- a/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js +++ b/ReactAndroid/src/androidTest/js/SubviewsClippingTestModule.js @@ -342,21 +342,21 @@ class SubviewsClippingTestApp extends React.Component { const SubviewsClippingTestModule = { App: SubviewsClippingTestApp, - renderClippingSample1: function() { + renderClippingSample1: function () { appInstance.setComponent(); }, - renderClippingSample2: function() { + renderClippingSample2: function () { appInstance.setComponent(); }, - renderUpdatingSample1: function(update1, update2) { + renderUpdatingSample1: function (update1, update2) { appInstance.setComponent( , ); }, - renderUpdatingSample2: function(update) { + renderUpdatingSample2: function (update) { appInstance.setComponent(); }, - renderScrollViewTest: function() { + renderScrollViewTest: function () { appInstance.setComponent(); }, }; diff --git a/ReactAndroid/src/androidTest/js/SwipeRefreshLayoutTestModule.js b/ReactAndroid/src/androidTest/js/SwipeRefreshLayoutTestModule.js index 2feb21e37e9..14f81bbb3db 100644 --- a/ReactAndroid/src/androidTest/js/SwipeRefreshLayoutTestModule.js +++ b/ReactAndroid/src/androidTest/js/SwipeRefreshLayoutTestModule.js @@ -77,7 +77,7 @@ class SwipeRefreshLayoutTestApp extends React.Component { const SwipeRefreshLayoutTestModule = { SwipeRefreshLayoutTestApp, - setRows: function(rows) { + setRows: function (rows) { if (app != null) { app.setState({rows}); } diff --git a/ReactAndroid/src/androidTest/js/TestJSLocaleModule.js b/ReactAndroid/src/androidTest/js/TestJSLocaleModule.js index 756846f9761..b15d1646bb0 100644 --- a/ReactAndroid/src/androidTest/js/TestJSLocaleModule.js +++ b/ReactAndroid/src/androidTest/js/TestJSLocaleModule.js @@ -15,10 +15,10 @@ const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridg const {Recording} = NativeModules; const TestJSLocaleModule = { - toUpper: function(s) { + toUpper: function (s) { Recording.record(s.toUpperCase()); }, - toLower: function(s) { + toLower: function (s) { Recording.record(s.toLowerCase()); }, }; diff --git a/ReactAndroid/src/androidTest/js/TestJSToJavaParametersModule.js b/ReactAndroid/src/androidTest/js/TestJSToJavaParametersModule.js index cf602236522..6053ebf57f6 100644 --- a/ReactAndroid/src/androidTest/js/TestJSToJavaParametersModule.js +++ b/ReactAndroid/src/androidTest/js/TestJSToJavaParametersModule.js @@ -15,26 +15,26 @@ const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridg const {Recording} = NativeModules; const TestJSToJavaParametersModule = { - returnBasicTypes: function() { + returnBasicTypes: function () { Recording.receiveBasicTypes('foo', 3.14, true, null); }, - returnBoxedTypes: function() { + returnBoxedTypes: function () { Recording.receiveBoxedTypes(42, 3.14, true); }, - returnDynamicTypes: function() { + returnDynamicTypes: function () { Recording.receiveDynamic('foo'); Recording.receiveDynamic(3.14); }, - returnArrayWithBasicTypes: function() { + returnArrayWithBasicTypes: function () { Recording.receiveArray(['foo', 3.14, -111, true, null]); }, - returnNestedArray: function() { + returnNestedArray: function () { Recording.receiveArray(['we', ['have', ['to', ['go', ['deeper']]]]]); }, - returnArrayWithMaps: function() { + returnArrayWithMaps: function () { Recording.receiveArray([{m1k1: 'm1v1', m1k2: 'm1v2'}, {m2k1: 'm2v1'}]); }, - returnMapWithBasicTypes: function() { + returnMapWithBasicTypes: function () { Recording.receiveMap({ stringKey: 'stringValue', doubleKey: 3.14, @@ -43,24 +43,24 @@ const TestJSToJavaParametersModule = { nullKey: null, }); }, - returnNestedMap: function() { + returnNestedMap: function () { Recording.receiveMap({ weHaveToGoDeeper: { inception: true, }, }); }, - returnMapWithArrays: function() { + returnMapWithArrays: function () { Recording.receiveMap({ empty: [], ints: [43, 44], mixed: [77, 'string', ['another', 'array']], }); }, - returnArrayWithStringDoubleIntMapArrayBooleanNull: function() { + returnArrayWithStringDoubleIntMapArrayBooleanNull: function () { Recording.receiveArray(['string', 3.14, 555, {}, [], true, null]); }, - returnMapWithStringDoubleIntMapArrayBooleanNull: function() { + returnMapWithStringDoubleIntMapArrayBooleanNull: function () { Recording.receiveMap({ string: 'string', double: 3, @@ -71,13 +71,13 @@ const TestJSToJavaParametersModule = { null: null, }); }, - returnArrayWithLargeInts: function() { + returnArrayWithLargeInts: function () { Recording.receiveArray([2147483648, -5555555555]); }, - returnMapWithLargeInts: function() { + returnMapWithLargeInts: function () { Recording.receiveMap({first: -2147483649, second: 5551231231}); }, - returnMapForMerge1: function() { + returnMapForMerge1: function () { Recording.receiveMap({ a: 1, b: 41, @@ -87,7 +87,7 @@ const TestJSToJavaParametersModule = { f: null, }); }, - returnMapForMerge2: function() { + returnMapForMerge2: function () { Recording.receiveMap({ a: 'overwrite', d: 77, @@ -96,7 +96,7 @@ const TestJSToJavaParametersModule = { newkey: 'newvalue', }); }, - returnMapWithMultibyteUTF8CharacterString: function() { + returnMapWithMultibyteUTF8CharacterString: function () { Recording.receiveMap({ 'one-byte': 'a', 'two-bytes': '\u00A2', @@ -106,7 +106,7 @@ const TestJSToJavaParametersModule = { '\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107', }); }, - returnArrayWithMultibyteUTF8CharacterString: function() { + returnArrayWithMultibyteUTF8CharacterString: function () { Recording.receiveArray([ 'a', '\u00A2', diff --git a/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js b/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js index 9340844166a..fc30e4bd100 100644 --- a/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js +++ b/ReactAndroid/src/androidTest/js/TestJavaToJSArgumentsModule.js @@ -29,20 +29,20 @@ function assertStrictStringEquals(a, b) { } const TestJavaToJSArgumentsModule = { - receiveBasicTypes: function(str, dbl, bool, null_arg) { + receiveBasicTypes: function (str, dbl, bool, null_arg) { assertEquals('foo', str); assertEquals(3.14, dbl); assertEquals(true, bool); assertEquals(null, null_arg); }, - receiveArrayWithBasicTypes: function(arr) { + receiveArrayWithBasicTypes: function (arr) { assertEquals(4, arr.length); assertEquals('red panda', arr[0]); assertEquals(1.19, arr[1]); assertEquals(true, arr[2]); assertEquals(null, arr[3]); }, - receiveNestedArray: function(arr) { + receiveNestedArray: function (arr) { assertEquals(2, arr.length); assertEquals('level1', arr[0]); const arr2 = arr[1]; @@ -50,7 +50,7 @@ const TestJavaToJSArgumentsModule = { const arr3 = arr2[1]; assertEquals('level3', arr3[0]); }, - receiveArrayWithMaps: function(arr) { + receiveArrayWithMaps: function (arr) { assertEquals(2, arr.length); const m1 = arr[0]; const m2 = arr[1]; @@ -58,17 +58,17 @@ const TestJavaToJSArgumentsModule = { assertEquals('m1v2', m1.m1k2); assertEquals('m2v1', m2.m2k1); }, - receiveMapWithBasicTypes: function(map) { + receiveMapWithBasicTypes: function (map) { assertEquals('stringValue', map.stringKey); assertEquals(3.14, map.doubleKey); assertEquals(true, map.booleanKey); assertEquals(null, map.nullKey); }, - receiveNestedMap: function(map) { + receiveNestedMap: function (map) { const nestedMap = map.nestedMap; assertEquals('foxes', nestedMap.animals); }, - receiveMapWithArrays: function(map) { + receiveMapWithArrays: function (map) { const a1 = map.array1; const a2 = map.array2; assertEquals(3, a1.length); @@ -76,7 +76,7 @@ const TestJavaToJSArgumentsModule = { assertEquals(3, a1[0]); assertEquals(9, a2[1]); }, - receiveMapAndArrayWithNullValues: function(map, array) { + receiveMapAndArrayWithNullValues: function (map, array) { assertEquals(null, map.string); assertEquals(null, map.array); assertEquals(null, map.map); @@ -85,7 +85,7 @@ const TestJavaToJSArgumentsModule = { assertEquals(null, array[1]); assertEquals(null, array[2]); }, - receiveMapWithMultibyteUTF8CharacterString: function(map) { + receiveMapWithMultibyteUTF8CharacterString: function (map) { assertStrictStringEquals('\u00A2', map['two-bytes']); assertStrictStringEquals('\u20AC', map['three-bytes']); assertStrictStringEquals('\uD83D\uDE1C', map['four-bytes']); @@ -94,7 +94,7 @@ const TestJavaToJSArgumentsModule = { map.mixed, ); }, - receiveArrayWithMultibyteUTF8CharacterString: function(array) { + receiveArrayWithMultibyteUTF8CharacterString: function (array) { assertTrue(true); assertStrictStringEquals('\u00A2', array[0]); assertStrictStringEquals('\u20AC', array[1]); diff --git a/ReactAndroid/src/androidTest/js/TestJavaToJSReturnValuesModule.js b/ReactAndroid/src/androidTest/js/TestJavaToJSReturnValuesModule.js index 7cfac525898..d6b00e3000e 100644 --- a/ReactAndroid/src/androidTest/js/TestJavaToJSReturnValuesModule.js +++ b/ReactAndroid/src/androidTest/js/TestJavaToJSReturnValuesModule.js @@ -16,13 +16,13 @@ const {assertEquals, assertTrue} = require('./Asserts'); const {TestModule} = NativeModules; const TestJavaToJSReturnValuesModule = { - callMethod: function(methodName, expectedType, expectedJSON) { + callMethod: function (methodName, expectedType, expectedJSON) { const result = TestModule[methodName](); assertEquals(expectedType, typeof result); assertEquals(expectedJSON, JSON.stringify(result)); }, - triggerException: function() { + triggerException: function () { try { TestModule.triggerException(); } catch (ex) { diff --git a/ReactAndroid/src/androidTest/js/TextInputTestModule.js b/ReactAndroid/src/androidTest/js/TextInputTestModule.js index 606d1ffd24f..82dd39772a4 100644 --- a/ReactAndroid/src/androidTest/js/TextInputTestModule.js +++ b/ReactAndroid/src/androidTest/js/TextInputTestModule.js @@ -176,7 +176,7 @@ const styles = StyleSheet.create({ const TextInputTestModule = { TextInputTestApp, - setValueRef: function(ref, value) { + setValueRef: function (ref, value) { app.refs[ref].setNativeProps({ text: value, }); diff --git a/ReactAndroid/src/androidTest/js/ViewRenderingTestModule.js b/ReactAndroid/src/androidTest/js/ViewRenderingTestModule.js index f0806d7e4fe..f004a4e8419 100644 --- a/ReactAndroid/src/androidTest/js/ViewRenderingTestModule.js +++ b/ReactAndroid/src/androidTest/js/ViewRenderingTestModule.js @@ -64,19 +64,19 @@ class TransformSampleApp extends React.Component { } const ViewRenderingTestModule = { - renderViewApplication: function(rootTag) { + renderViewApplication: function (rootTag) { renderApplication(ViewSampleApp, {}, rootTag); }, - renderMarginApplication: function(rootTag) { + renderMarginApplication: function (rootTag) { renderApplication(MarginSampleApp, {}, rootTag); }, - renderBorderApplication: function(rootTag) { + renderBorderApplication: function (rootTag) { renderApplication(BorderSampleApp, {}, rootTag); }, - renderTransformApplication: function(rootTag) { + renderTransformApplication: function (rootTag) { renderApplication(TransformSampleApp, {}, rootTag); }, - updateMargins: function() { + updateMargins: function () { updateMargins(); }, }; diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/HeaderWriter.js b/ReactCommon/hermes/inspector/tools/msggen/src/HeaderWriter.js index d217c2e86b4..a5f951783ab 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/HeaderWriter.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/HeaderWriter.js @@ -70,7 +70,7 @@ export class HeaderWriter { this.stream.write('struct UnknownRequest;\n\n'); const namespaceMap: Map> = new Map(); - const addToMap = function(type) { + const addToMap = function (type) { const domain = type.domain; let types = namespaceMap.get(domain); if (!types) { diff --git a/ReactCommon/hermes/inspector/tools/msggen/src/index.js b/ReactCommon/hermes/inspector/tools/msggen/src/index.js index b1452d509f9..b9a420c592f 100644 --- a/ReactCommon/hermes/inspector/tools/msggen/src/index.js +++ b/ReactCommon/hermes/inspector/tools/msggen/src/index.js @@ -83,7 +83,7 @@ function buildGraph(desc: Descriptor): Graph { const commands = desc.commands; const events = desc.events; - const maybeAddPropEdges = function(nodeId: string, props: ?Array) { + const maybeAddPropEdges = function (nodeId: string, props: ?Array) { if (props) { for (const prop of props) { const refId = prop.getRefDebuggerName(); diff --git a/bots/code-analysis-bot.js b/bots/code-analysis-bot.js index 5da10c52175..bdcaec1befc 100644 --- a/bots/code-analysis-bot.js +++ b/bots/code-analysis-bot.js @@ -30,8 +30,7 @@ function push(arr, key, value) { const converterSummary = { eslint: '`eslint` found some issues. Run `yarn lint --fix` to automatically fix problems.', - flow: - '`flow` found some issues. Run `yarn flow check` to analyze your code and address any errors.', + flow: '`flow` found some issues. Run `yarn flow check` to analyze your code and address any errors.', shellcheck: '`shellcheck` found some issues. Run `yarn shellcheck` to analyze shell scripts.', 'google-java-format': @@ -51,20 +50,20 @@ const converterSummary = { * is an array of objects of the shape message and line. */ const converters = { - raw: function(output, input) { + raw: function (output, input) { for (let key in input) { - input[key].forEach(function(message) { + input[key].forEach(function (message) { push(output, key, message); }); } }, - 'google-java-format': function(output, input) { + 'google-java-format': function (output, input) { if (!input) { return; } - input.forEach(function(change) { + input.forEach(function (change) { push(output, change.file, { message: `\`google-java-format\` suggested changes: \`\`\`diff @@ -77,12 +76,12 @@ ${change.description} }); }, - flow: function(output, input) { + flow: function (output, input) { if (!input || !input.errors) { return; } - input.errors.forEach(function(error) { + input.errors.forEach(function (error) { push(output, error.message[0].path, { message: error.message.map(message => message.descr).join(' '), line: error.message[0].line, @@ -91,13 +90,13 @@ ${change.description} }); }, - eslint: function(output, input) { + eslint: function (output, input) { if (!input) { return; } - input.forEach(function(file) { - file.messages.forEach(function(message) { + input.forEach(function (file) { + file.messages.forEach(function (message) { push(output, file.filePath, { message: message.ruleId + ': ' + message.message, line: message.line, @@ -107,12 +106,12 @@ ${change.description} }); }, - shellcheck: function(output, input) { + shellcheck: function (output, input) { if (!input) { return; } - input.forEach(function(report) { + input.forEach(function (report) { push(output, report.file, { message: '**[SC' + @@ -285,10 +284,10 @@ async function main(messages, owner, repo, pull_number) { let content = ''; process.stdin.resume(); -process.stdin.on('data', function(buf) { +process.stdin.on('data', function (buf) { content += buf.toString(); }); -process.stdin.on('end', function() { +process.stdin.on('end', function () { let messages = {}; // Since we send a few http requests to setup the process, we don't want diff --git a/bots/dangerfile.js b/bots/dangerfile.js index 428652b8020..91803ed1298 100644 --- a/bots/dangerfile.js +++ b/bots/dangerfile.js @@ -51,7 +51,8 @@ if (!includesTestPlan) { } // Regex looks for given categories, types, a file/framework/component, and a message - broken into 4 capture groups -const changelogRegex = /\[\s?(ANDROID|GENERAL|IOS|JS|JAVASCRIPT|INTERNAL)\s?\]\s?\[\s?(ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY)\s?\]\s*?-?\s*?(.*)/gi; +const changelogRegex = + /\[\s?(ANDROID|GENERAL|IOS|JS|JAVASCRIPT|INTERNAL)\s?\]\s?\[\s?(ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY)\s?\]\s*?-?\s*?(.*)/gi; const internalChangelogRegex = /\[\s?(INTERNAL)\s?\].*/gi; const includesChangelog = danger.github.pr.body && diff --git a/bots/make-comment.js b/bots/make-comment.js index 0ab9b4f2b59..7d07076b6df 100644 --- a/bots/make-comment.js +++ b/bots/make-comment.js @@ -56,12 +56,8 @@ async function updateComment(octokit, issueParams, body, replacePattern) { * @param {string} replacePattern Pattern for finding the comment to update */ async function createOrUpdateComment(body, replacePattern) { - const { - GITHUB_TOKEN, - GITHUB_OWNER, - GITHUB_REPO, - GITHUB_PR_NUMBER, - } = process.env; + const {GITHUB_TOKEN, GITHUB_OWNER, GITHUB_REPO, GITHUB_PR_NUMBER} = + process.env; if (!GITHUB_TOKEN || !GITHUB_OWNER || !GITHUB_REPO || !GITHUB_PR_NUMBER) { if (!GITHUB_TOKEN) { console.error( diff --git a/jest/assetFileTransformer.js b/jest/assetFileTransformer.js index 03b018ffb7c..c4730114f46 100644 --- a/jest/assetFileTransformer.js +++ b/jest/assetFileTransformer.js @@ -12,8 +12,8 @@ /* eslint-env node */ const path = require('path'); -const createCacheKeyFunction = require('@jest/create-cache-key-function') - .default; +const createCacheKeyFunction = + require('@jest/create-cache-key-function').default; module.exports = { // Mocks asset requires to return the filename. Makes it possible to test that diff --git a/jest/preprocessor.js b/jest/preprocessor.js index e209750d697..c6b78449600 100644 --- a/jest/preprocessor.js +++ b/jest/preprocessor.js @@ -14,8 +14,8 @@ const babelRegisterOnly = require('metro-babel-register'); const nullthrows = require('nullthrows'); -const createCacheKeyFunction = require('@jest/create-cache-key-function') - .default; +const createCacheKeyFunction = + require('@jest/create-cache-key-function').default; const t = require('@babel/types'); const {statements} = require('@babel/template').default; diff --git a/jest/setup.js b/jest/setup.js index 8aed65f3b82..69e937fdd3a 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -25,10 +25,10 @@ global.Promise = jest.requireActual('promise'); global.regeneratorRuntime = jest.requireActual('regenerator-runtime/runtime'); global.window = global; -global.requestAnimationFrame = function(callback) { +global.requestAnimationFrame = function (callback) { return setTimeout(callback, 0); }; -global.cancelAnimationFrame = function(id) { +global.cancelAnimationFrame = function (id) { clearTimeout(id); }; @@ -353,7 +353,7 @@ jest }) .mock( '../Libraries/Utilities/verifyComponentAttributeEquivalence', - () => function() {}, + () => function () {}, ) .mock('../Libraries/Components/View/ViewNativeComponent', () => { const React = require('react'); diff --git a/packages/babel-plugin-codegen/__test_fixtures__/failures.js b/packages/babel-plugin-codegen/__test_fixtures__/failures.js index 6ba62d5a2c6..40e46fd5b58 100644 --- a/packages/babel-plugin-codegen/__test_fixtures__/failures.js +++ b/packages/babel-plugin-codegen/__test_fixtures__/failures.js @@ -82,7 +82,9 @@ export default (codegenNativeComponent('Module'): NativeType); `; module.exports = { - 'CommandsExportedWithDifferentNameNativeComponent.js': COMMANDS_EXPORTED_WITH_DIFFERENT_NAME, - 'CommandsExportedWithShorthandNativeComponent.js': COMMANDS_EXPORTED_WITH_SHORTHAND, + 'CommandsExportedWithDifferentNameNativeComponent.js': + COMMANDS_EXPORTED_WITH_DIFFERENT_NAME, + 'CommandsExportedWithShorthandNativeComponent.js': + COMMANDS_EXPORTED_WITH_SHORTHAND, 'OtherCommandsExportNativeComponent.js': OTHER_COMMANDS_EXPORT, }; diff --git a/packages/babel-plugin-codegen/index.js b/packages/babel-plugin-codegen/index.js index 235eb667969..2e59816d9d2 100644 --- a/packages/babel-plugin-codegen/index.js +++ b/packages/babel-plugin-codegen/index.js @@ -53,7 +53,7 @@ function isCodegenDeclaration(declaration) { return false; } -module.exports = function({parse, types: t}) { +module.exports = function ({parse, types: t}) { return { pre(state) { this.code = state.code; diff --git a/packages/eslint-plugin-codegen/react-native-modules.js b/packages/eslint-plugin-codegen/react-native-modules.js index 476624d024b..c5f19fc0c30 100644 --- a/packages/eslint-plugin-codegen/react-native-modules.js +++ b/packages/eslint-plugin-codegen/react-native-modules.js @@ -99,7 +99,7 @@ function rule(context) { let isModule = false; return { - 'Program:exit': function(node) { + 'Program:exit': function (node) { if (!isModule) { return; } @@ -112,10 +112,8 @@ function rule(context) { }); } - const { - buildModuleSchema, - createParserErrorCapturer, - } = requireModuleParser(); + const {buildModuleSchema, createParserErrorCapturer} = + requireModuleParser(); const flowParser = require('flow-parser'); const [parsingErrors, tryParse] = createParserErrorCapturer(); diff --git a/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js b/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js index 75343c25864..6e3ee40f91c 100644 --- a/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js +++ b/packages/eslint-plugin-react-native-community/__tests__/platform-colors-test.js @@ -29,23 +29,19 @@ eslintTester.run('../platform-colors', rule, { errors: [{message: rule.meta.messages.platformColorArgsLength}], }, { - code: - "const labelColor = 'labelColor'; const color = PlatformColor(labelColor);", + code: "const labelColor = 'labelColor'; const color = PlatformColor(labelColor);", errors: [{message: rule.meta.messages.platformColorArgTypes}], }, { - code: - "const tuple = {light: 'black', dark: 'white'}; const color = DynamicColorIOS(tuple);", + code: "const tuple = {light: 'black', dark: 'white'}; const color = DynamicColorIOS(tuple);", errors: [{message: rule.meta.messages.dynamicColorIOSArg}], }, { - code: - "const black = 'black'; const color = DynamicColorIOS({light: black, dark: 'white'});", + code: "const black = 'black'; const color = DynamicColorIOS({light: black, dark: 'white'});", errors: [{message: rule.meta.messages.dynamicColorIOSLight}], }, { - code: - "const white = 'white'; const color = DynamicColorIOS({light: 'black', dark: white});", + code: "const white = 'white'; const color = DynamicColorIOS({light: 'black', dark: white});", errors: [{message: rule.meta.messages.dynamicColorIOSDark}], }, ], diff --git a/packages/eslint-plugin-react-native-community/platform-colors.js b/packages/eslint-plugin-react-native-community/platform-colors.js index 12e8f908f90..e24e7b7aaa2 100644 --- a/packages/eslint-plugin-react-native-community/platform-colors.js +++ b/packages/eslint-plugin-react-native-community/platform-colors.js @@ -29,9 +29,9 @@ module.exports = { schema: [], }, - create: function(context) { + create: function (context) { return { - CallExpression: function(node) { + CallExpression: function (node) { if (node.callee.name === 'PlatformColor') { const args = node.arguments; if (args.length === 0) { diff --git a/packages/normalize-color/index.js b/packages/normalize-color/index.js index 15f50bd788f..fb8a8bb5675 100644 --- a/packages/normalize-color/index.js +++ b/packages/normalize-color/index.js @@ -40,8 +40,8 @@ function normalizeColor(color) { if ((match = matchers.rgb.exec(color))) { return ( ((parse255(match[1]) << 24) | // r - (parse255(match[2]) << 16) | // g - (parse255(match[3]) << 8) | // b + (parse255(match[2]) << 16) | // g + (parse255(match[3]) << 8) | // b 0x000000ff) >>> // a 0 ); @@ -50,8 +50,8 @@ function normalizeColor(color) { if ((match = matchers.rgba.exec(color))) { return ( ((parse255(match[1]) << 24) | // r - (parse255(match[2]) << 16) | // g - (parse255(match[3]) << 8) | // b + (parse255(match[2]) << 16) | // g + (parse255(match[3]) << 8) | // b parse1(match[4])) >>> // a 0 ); @@ -61,11 +61,11 @@ function normalizeColor(color) { return ( parseInt( match[1] + - match[1] + // r - match[2] + - match[2] + // g - match[3] + - match[3] + // b + match[1] + // r + match[2] + + match[2] + // g + match[3] + + match[3] + // b 'ff', // a 16, ) >>> 0 @@ -81,11 +81,11 @@ function normalizeColor(color) { return ( parseInt( match[1] + - match[1] + // r - match[2] + - match[2] + // g - match[3] + - match[3] + // b + match[1] + // r + match[2] + + match[2] + // g + match[3] + + match[3] + // b match[4] + match[4], // a 16, diff --git a/packages/react-native-codegen/scripts/build.js b/packages/react-native-codegen/scripts/build.js index 9eefd4fdbb8..c3f8f2ae788 100644 --- a/packages/react-native-codegen/scripts/build.js +++ b/packages/react-native-codegen/scripts/build.js @@ -47,10 +47,7 @@ const fixedWidth = str => { if (lastString.length < WIDTH) { lastString += Array(WIDTH - lastString.length).join(chalk.dim('.')); } - return strs - .slice(0, -1) - .concat(lastString) - .join('\n'); + return strs.slice(0, -1).concat(lastString).join('\n'); }; function getBuildPath(file, buildFolder) { diff --git a/packages/react-native-codegen/src/generators/components/CppHelpers.js b/packages/react-native-codegen/src/generators/components/CppHelpers.js index bbf8a48347b..2b42636dc73 100644 --- a/packages/react-native-codegen/src/generators/components/CppHelpers.js +++ b/packages/react-native-codegen/src/generators/components/CppHelpers.js @@ -20,10 +20,7 @@ function upperCaseFirst(inString: string): string { } function toSafeCppString(input: string): string { - return input - .split('-') - .map(upperCaseFirst) - .join(''); + return input.split('-').map(upperCaseFirst).join(''); } function toIntEnumValueName(propName: string, value: number): string { diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js index 171cb5bb517..a747240c19c 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterCpp.js @@ -24,7 +24,7 @@ type FilesOutput = Map; type ComponentCollection = $ReadOnly<{ [component: string]: ComponentShape, - ..., + ... }>; const FileTemplate = ({ diff --git a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js index 8ada23c7a92..e61f103ae5a 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js +++ b/packages/react-native-codegen/src/generators/components/GenerateEventEmitterH.js @@ -32,7 +32,7 @@ type StructsMap = Map; type ComponentCollection = $ReadOnly<{ [component: string]: ComponentShape, - ..., + ... }>; const FileTemplate = ({componentEmitters}: {componentEmitters: string}) => ` diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js index 03015faee37..be65aedca7b 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsCpp.js @@ -160,10 +160,7 @@ module.exports = { const replacedTemplate = FileTemplate({ componentClasses: componentProps, libraryName, - imports: Array.from(allImports) - .sort() - .join('\n') - .trim(), + imports: Array.from(allImports).sort().join('\n').trim(), }); return new Map([[fileName, replacedTemplate]]); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js index 72a31c67f1e..ad4760c1f2d 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsH.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsH.js @@ -660,7 +660,7 @@ function generateStructs( elementProperties, nameParts.concat([prop.name]), ); - nestedStructs.forEach(function(value, key) { + nestedStructs.forEach(function (value, key) { structs.set(key, value); }); @@ -684,7 +684,7 @@ function generateStructs( elementProperties, nameParts.concat([prop.name]), ); - nestedStructs.forEach(function(value, key) { + nestedStructs.forEach(function (value, key) { structs.set(key, value); }); @@ -725,7 +725,7 @@ function generateStructs( elementProperties, nameParts.concat([prop.name]), ); - nestedStructs.forEach(function(value, key) { + nestedStructs.forEach(function (value, key) { structs.set(key, value); }); @@ -906,9 +906,7 @@ module.exports = { const replacedTemplate = FileTemplate({ componentClasses, - imports: Array.from(allImports) - .sort() - .join('\n'), + imports: Array.from(allImports).sort().join('\n'), }); return new Map([[fileName, replacedTemplate]]); diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js index 030abcd6d71..b01eeac4be2 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js @@ -322,9 +322,7 @@ module.exports = { const extendString = getClassExtendString(component); const replacedTemplate = FileTemplate({ - imports: Array.from(imports) - .sort() - .join('\n'), + imports: Array.from(imports).sort().join('\n'), packageName: normalizedPackageName, className, extendClasses: extendString, diff --git a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js index 31e27513a2d..d1fbdfb9a24 100644 --- a/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js +++ b/packages/react-native-codegen/src/generators/components/GeneratePropsJavaInterface.js @@ -266,9 +266,7 @@ module.exports = { const extendString = getClassExtendString(component); const replacedTemplate = FileTemplate({ - imports: Array.from(imports) - .sort() - .join('\n'), + imports: Array.from(imports).sort().join('\n'), packageName: normalizedPackageName, className, extendClasses: extendString, diff --git a/packages/react-native-codegen/src/generators/components/GenerateTests.js b/packages/react-native-codegen/src/generators/components/GenerateTests.js index 4da5c40c2d9..d3f65ea3522 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateTests.js +++ b/packages/react-native-codegen/src/generators/components/GenerateTests.js @@ -202,10 +202,7 @@ module.exports = { .filter(Boolean) .join(''); - const imports = Array.from(allImports) - .sort() - .join('\n') - .trim(); + const imports = Array.from(allImports).sort().join('\n').trim(); const replacedTemplate = FileTemplate({ imports, diff --git a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js index 035ba93efce..b68b5919c78 100644 --- a/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js +++ b/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js @@ -432,9 +432,7 @@ module.exports = { const replacedTemplate = FileTemplate({ componentConfig: moduleResults, - imports: Array.from(imports) - .sort() - .join('\n'), + imports: Array.from(imports).sort().join('\n'), }); return new Map([[fileName, replacedTemplate]]); diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js index 27eba9c32f1..908c88ee2a4 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleCpp.js @@ -162,11 +162,8 @@ function serializePropertyIntoHostFunction( property: NativeModulePropertyShape, resolveAlias: AliasResolver, ): string { - const [ - propertyTypeAnnotation, - ] = unwrapNullable( - property.typeAnnotation, - ); + const [propertyTypeAnnotation] = + unwrapNullable(property.typeAnnotation); const isVoid = propertyTypeAnnotation.returnTypeAnnotation.type === 'VoidTypeAnnotation'; diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js index fe919e910ce..21da201a7c7 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleH.js @@ -138,11 +138,10 @@ module.exports = { const traversedProperties = properties .map(prop => { - const [ - propTypeAnnotation, - ] = unwrapNullable( - prop.typeAnnotation, - ); + const [propTypeAnnotation] = + unwrapNullable( + prop.typeAnnotation, + ); const traversedArgs = propTypeAnnotation.params .map(param => { const translatedParam = translatePrimitiveJSTypeToCpp( diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js index 60b7274b786..d0969a6bffe 100644 --- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js +++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniCpp.js @@ -184,10 +184,8 @@ function translateParamTypeToJniType( resolveAlias: AliasResolver, ): string { const {optional, typeAnnotation: nullableTypeAnnotation} = param; - const [ - typeAnnotation, - nullable, - ] = unwrapNullable(nullableTypeAnnotation); + const [typeAnnotation, nullable] = + unwrapNullable(nullableTypeAnnotation); const isRequired = !optional && !nullable; let realTypeAnnotation = typeAnnotation; @@ -291,9 +289,8 @@ function translateMethodTypeToJniSignature( resolveAlias: AliasResolver, ): string { const {name, typeAnnotation} = property; - let [ - {returnTypeAnnotation, params}, - ] = unwrapNullable(typeAnnotation); + let [{returnTypeAnnotation, params}] = + unwrapNullable(typeAnnotation); params = [...params]; let processedReturnTypeAnnotation = returnTypeAnnotation; @@ -330,11 +327,8 @@ function translateMethodForImplementation( property: NativeModulePropertyShape, resolveAlias: AliasResolver, ): string { - const [ - propertyTypeAnnotation, - ] = unwrapNullable( - property.typeAnnotation, - ); + const [propertyTypeAnnotation] = + unwrapNullable(property.typeAnnotation); const {returnTypeAnnotation} = propertyTypeAnnotation; if ( @@ -395,11 +389,10 @@ module.exports = { hasteModuleName, methods: properties .map(({name: propertyName, typeAnnotation}) => { - const [ - {returnTypeAnnotation, params}, - ] = unwrapNullable( - typeAnnotation, - ); + const [{returnTypeAnnotation, params}] = + unwrapNullable( + typeAnnotation, + ); if ( propertyName === 'getConstants' && diff --git a/packages/react-native-codegen/src/parsers/flow/components/events.js b/packages/react-native-codegen/src/parsers/flow/components/events.js index b950f824559..f6c68c80fcd 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/events.js +++ b/packages/react-native-codegen/src/parsers/flow/components/events.js @@ -191,11 +191,8 @@ function buildEventSchema( return null; } - const { - argumentProps, - bubblingType, - paperTopLevelNameDeprecated, - } = findEventArgumentsAndType(typeAnnotation, types); + const {argumentProps, bubblingType, paperTopLevelNameDeprecated} = + findEventArgumentsAndType(typeAnnotation, types); if (bubblingType && argumentProps) { if (paperTopLevelNameDeprecated != null) { @@ -237,7 +234,7 @@ type EventTypeAST = Object; type TypeMap = { // $FlowFixMe[unclear-type] there's no flowtype for ASTs [string]: Object, - ..., + ... }; function getEvents( diff --git a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js index ef3354df45f..411890dec51 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/__tests__/module-parser-e2e-test.js @@ -155,10 +155,8 @@ describe('Flow Module Parser', () => { expect(param).not.toBe(null); expect(param.name).toBe(paramName); expect(param.optional).toBe(optional); - const [ - paramTypeAnnotation, - isParamTypeAnnotationNullable, - ] = unwrapNullable(param.typeAnnotation); + const [paramTypeAnnotation, isParamTypeAnnotationNullable] = + unwrapNullable(param.typeAnnotation); expect(isParamTypeAnnotationNullable).toBe(nullable); return [paramTypeAnnotation, module]; @@ -232,12 +230,10 @@ describe('Flow Module Parser', () => { expect(paramTypeAnnotation.elementType).not.toBe(null); invariant(paramTypeAnnotation.elementType != null, ''); - const [ - elementType, - isElementTypeNullable, - ] = unwrapNullable( - paramTypeAnnotation.elementType, - ); + const [elementType, isElementTypeNullable] = + unwrapNullable( + paramTypeAnnotation.elementType, + ); expect(isElementTypeNullable).toBe(false); return [elementType, module]; } @@ -371,10 +367,8 @@ describe('Flow Module Parser', () => { expect(param.optional).toBe(optional); // The TypeAliasAnnotation is called Animal, and is nullable - const [ - paramTypeAnnotation, - isParamTypeAnnotationNullable, - ] = unwrapNullable(param.typeAnnotation); + const [paramTypeAnnotation, isParamTypeAnnotationNullable] = + unwrapNullable(param.typeAnnotation); expect(paramTypeAnnotation.type).toBe('TypeAliasTypeAnnotation'); invariant( paramTypeAnnotation.type === 'TypeAliasTypeAnnotation', @@ -446,10 +440,8 @@ describe('Flow Module Parser', () => { expect(properties[0].name).toBe(propName); expect(properties[0].optional).toBe(isPropOptional); - const [ - propertyTypeAnnotation, - isPropertyTypeAnnotationNullable, - ] = unwrapNullable(properties[0].typeAnnotation); + const [propertyTypeAnnotation, isPropertyTypeAnnotationNullable] = + unwrapNullable(properties[0].typeAnnotation); expect(propertyTypeAnnotation).not.toBe(null); expect(isPropertyTypeAnnotationNullable).toBe(isPropNullable); @@ -537,18 +529,15 @@ describe('Flow Module Parser', () => { '', ); - const { - elementType: nullableElementType, - } = property.typeAnnotation; + const {elementType: nullableElementType} = + property.typeAnnotation; expect(nullableElementType).not.toBe(null); invariant(nullableElementType != null, ''); - const [ - elementType, - isElementTypeNullable, - ] = unwrapNullable( - nullableElementType, - ); + const [elementType, isElementTypeNullable] = + unwrapNullable( + nullableElementType, + ); expect(isElementTypeNullable).toBe(false); @@ -709,16 +698,12 @@ describe('Flow Module Parser', () => { expect(module.spec.properties[0]).not.toBe(null); - const [ - functionTypeAnnotation, - isFunctionTypeAnnotationNullable, - ] = unwrapNullable(module.spec.properties[0].typeAnnotation); + const [functionTypeAnnotation, isFunctionTypeAnnotationNullable] = + unwrapNullable(module.spec.properties[0].typeAnnotation); expect(isFunctionTypeAnnotationNullable).toBe(false); - const [ - returnTypeAnnotation, - isReturnTypeAnnotationNullable, - ] = unwrapNullable(functionTypeAnnotation.returnTypeAnnotation); + const [returnTypeAnnotation, isReturnTypeAnnotationNullable] = + unwrapNullable(functionTypeAnnotation.returnTypeAnnotation); expect(returnTypeAnnotation.type).toBe('VoidTypeAnnotation'); expect(isReturnTypeAnnotationNullable).toBe(false); }); @@ -746,16 +731,12 @@ describe('Flow Module Parser', () => { `); expect(module.spec.properties[0]).not.toBe(null); - const [ - functionTypeAnnotation, - isFunctionTypeAnnotationNullable, - ] = unwrapNullable(module.spec.properties[0].typeAnnotation); + const [functionTypeAnnotation, isFunctionTypeAnnotationNullable] = + unwrapNullable(module.spec.properties[0].typeAnnotation); expect(isFunctionTypeAnnotationNullable).toBe(false); - const [ - returnTypeAnnotation, - isReturnTypeAnnotationNullable, - ] = unwrapNullable(functionTypeAnnotation.returnTypeAnnotation); + const [returnTypeAnnotation, isReturnTypeAnnotationNullable] = + unwrapNullable(functionTypeAnnotation.returnTypeAnnotation); expect(isReturnTypeAnnotationNullable).toBe(IS_RETURN_TYPE_NULLABLE); return [returnTypeAnnotation, module]; @@ -823,10 +804,8 @@ describe('Flow Module Parser', () => { expect(elementType).not.toBe(null); invariant(elementType != null, ''); - const [ - elementTypeAnnotation, - isElementTypeAnnotation, - ] = unwrapNullable(elementType); + const [elementTypeAnnotation, isElementTypeAnnotation] = + unwrapNullable(elementType); expect(isElementTypeAnnotation).toBe(false); return [elementTypeAnnotation, module]; @@ -837,9 +816,8 @@ describe('Flow Module Parser', () => { describe('Primitive Element Types', () => { PRIMITIVES.forEach(([FLOW_TYPE, PARSED_TYPE_NAME]) => { it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Array<${FLOW_TYPE}>'`, () => { - const [elementType, module] = parseArrayElementReturnType( - FLOW_TYPE, - ); + const [elementType, module] = + parseArrayElementReturnType(FLOW_TYPE); expect(elementType.type).toBe(PARSED_TYPE_NAME); }); }); @@ -863,9 +841,8 @@ describe('Flow Module Parser', () => { }); it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return type of some array of an alias`, () => { - const [elementType, module] = parseArrayElementReturnType( - 'Animal', - ); + const [elementType, module] = + parseArrayElementReturnType('Animal'); expect(elementType.type).toBe('TypeAliasTypeAnnotation'); invariant(elementType.type === 'TypeAliasTypeAnnotation', ''); expect(elementType.name).toBe('Animal'); @@ -873,9 +850,8 @@ describe('Flow Module Parser', () => { }); it(`should parse methods that have ${RETURN_TYPE_DESCRIPTION} return of type 'Array<{foo: ?string}>'`, () => { - const [elementType] = parseArrayElementReturnType( - '{foo: ?string}', - ); + const [elementType] = + parseArrayElementReturnType('{foo: ?string}'); expect(elementType.type).toBe('ObjectTypeAnnotation'); invariant(elementType.type === 'ObjectTypeAnnotation', ''); @@ -887,10 +863,8 @@ describe('Flow Module Parser', () => { expect(properties[0].name).toBe('foo'); expect(properties[0].typeAnnotation).not.toBe(null); - const [ - propertyTypeAnnotation, - isPropertyTypeAnnotationNullable, - ] = unwrapNullable(properties[0].typeAnnotation); + const [propertyTypeAnnotation, isPropertyTypeAnnotationNullable] = + unwrapNullable(properties[0].typeAnnotation); expect(propertyTypeAnnotation.type).toBe('StringTypeAnnotation'); expect(isPropertyTypeAnnotationNullable).toBe(true); @@ -1084,13 +1058,11 @@ describe('Flow Module Parser', () => { propName: string, arrayElementType: string, ): [NativeModuleBaseTypeAnnotation, NativeModuleSchema] { - const [ - property, - module, - ] = parseObjectLiteralReturnTypeProp( - propName, - `Array<${arrayElementType}>`, - ); + const [property, module] = + parseObjectLiteralReturnTypeProp( + propName, + `Array<${arrayElementType}>`, + ); expect(property.name).toBe(propName); expect(property.typeAnnotation.type).toBe( 'ArrayTypeAnnotation', @@ -1100,18 +1072,15 @@ describe('Flow Module Parser', () => { '', ); - const { - elementType: nullableElementType, - } = property.typeAnnotation; + const {elementType: nullableElementType} = + property.typeAnnotation; expect(nullableElementType).not.toBe(null); invariant(nullableElementType != null, ''); - const [ - elementType, - isElementTypeNullable, - ] = unwrapNullable( - nullableElementType, - ); + const [elementType, isElementTypeNullable] = + unwrapNullable( + nullableElementType, + ); expect(isElementTypeNullable).toBe(false); return [elementType, module]; diff --git a/packages/react-native-codegen/src/parsers/flow/modules/index.js b/packages/react-native-codegen/src/parsers/flow/modules/index.js index ffbb50af398..63e14547608 100644 --- a/packages/react-native-codegen/src/parsers/flow/modules/index.js +++ b/packages/react-native-codegen/src/parsers/flow/modules/index.js @@ -71,11 +71,8 @@ function translateTypeAnnotation( aliasMap: {...NativeModuleAliasMap}, tryParse: ParserErrorCapturer, ): Nullable { - const { - nullable, - typeAnnotation, - typeAliasResolutionStatus, - } = resolveTypeAnnotation(flowTypeAnnotation, types); + const {nullable, typeAnnotation, typeAliasResolutionStatus} = + resolveTypeAnnotation(flowTypeAnnotation, types); switch (typeAnnotation.type) { case 'GenericTypeAnnotation': { @@ -234,18 +231,16 @@ function translateTypeAnnotation( const {optional, key} = property; - const [ - propertyTypeAnnotation, - isPropertyNullable, - ] = unwrapNullable( - translateTypeAnnotation( - hasteModuleName, - property.value, - types, - aliasMap, - tryParse, - ), - ); + const [propertyTypeAnnotation, isPropertyNullable] = + unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + property.value, + types, + aliasMap, + tryParse, + ), + ); if (propertyTypeAnnotation.type === 'FunctionTypeAnnotation') { throw new UnsupportedObjectPropertyValueTypeAnnotationParserError( @@ -417,18 +412,16 @@ function translateFunctionTypeAnnotation( } const paramName = flowParam.name.name; - const [ - paramTypeAnnotation, - isParamTypeAnnotationNullable, - ] = unwrapNullable( - translateTypeAnnotation( - hasteModuleName, - flowParam.typeAnnotation, - types, - aliasMap, - tryParse, - ), - ); + const [paramTypeAnnotation, isParamTypeAnnotationNullable] = + unwrapNullable( + translateTypeAnnotation( + hasteModuleName, + flowParam.typeAnnotation, + types, + aliasMap, + tryParse, + ), + ); if (paramTypeAnnotation.type === 'VoidTypeAnnotation') { throw new UnsupportedFunctionParamTypeAnnotationParserError( diff --git a/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js b/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js index f9a30031b15..e10b75c7e17 100644 --- a/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js +++ b/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js @@ -26,8 +26,7 @@ type NativeProps = $ReadOnly<{| testIdentifier?: ?string, |}>; -const RCTSnapshotNativeComponent: HostComponent = requireNativeComponent( - 'RCTSnapshot', -); +const RCTSnapshotNativeComponent: HostComponent = + requireNativeComponent('RCTSnapshot'); module.exports = RCTSnapshotNativeComponent; diff --git a/packages/rn-tester/RNTesterUnitTests/RNTesterUnitTestsBundle.js b/packages/rn-tester/RNTesterUnitTests/RNTesterUnitTestsBundle.js index 20f4cc8caa1..251bb2711b5 100644 --- a/packages/rn-tester/RNTesterUnitTests/RNTesterUnitTestsBundle.js +++ b/packages/rn-tester/RNTesterUnitTests/RNTesterUnitTestsBundle.js @@ -11,7 +11,7 @@ // eslint-disable-next-line no-unused-vars const __fbBatchedBridge = { - flushedQueue: function() { + flushedQueue: function () { return null; }, }; diff --git a/packages/rn-tester/e2e/test-init.js b/packages/rn-tester/e2e/test-init.js index 5120acdf1b2..4f913d449b9 100644 --- a/packages/rn-tester/e2e/test-init.js +++ b/packages/rn-tester/e2e/test-init.js @@ -35,7 +35,7 @@ beforeAll(async () => { }); }); -beforeEach(async function() { +beforeEach(async function () { await adapter.beforeEach(); }); diff --git a/packages/rn-tester/js/components/RNTesterTheme.js b/packages/rn-tester/js/components/RNTesterTheme.js index 25697d21419..0d671f7a89c 100644 --- a/packages/rn-tester/js/components/RNTesterTheme.js +++ b/packages/rn-tester/js/components/RNTesterTheme.js @@ -109,6 +109,7 @@ export const RNTesterDarkTheme = { }; export const themes = {light: RNTesterLightTheme, dark: RNTesterDarkTheme}; -export const RNTesterThemeContext: React.Context = React.createContext( - Appearance.getColorScheme() === 'dark' ? themes.dark : themes.light, -); +export const RNTesterThemeContext: React.Context = + React.createContext( + Appearance.getColorScheme() === 'dark' ? themes.dark : themes.light, + ); diff --git a/packages/rn-tester/js/components/TextLegend.js b/packages/rn-tester/js/components/TextLegend.js index 68f5fba87be..72db39bbf02 100644 --- a/packages/rn-tester/js/components/TextLegend.js +++ b/packages/rn-tester/js/components/TextLegend.js @@ -23,8 +23,7 @@ const PANGRAMS = { hebrew: 'דג סקרן שט בים מאוכזב ולפתע מצא חברה', hindi: 'ऋषियों को सताने वाले दुष्ट राक्षसों के राजा रावण का सर्वनाश करने वाले विष्णुवतार भगवान श्रीराम, अयोध्या के महाराज दशरथ के बड़े सपुत्र थे।', - igbo: - 'Nne, nna, wepụ he’l’ụjọ dum n’ime ọzụzụ ụmụ, vufesi obi nye Chukwu, ṅụrịanụ, gbakọọnụ kpaa, kwee ya ka o guzoshie ike; ọ ghaghị ito, nwapụta ezi agwa', + igbo: 'Nne, nna, wepụ he’l’ụjọ dum n’ime ọzụzụ ụmụ, vufesi obi nye Chukwu, ṅụrịanụ, gbakọọnụ kpaa, kwee ya ka o guzoshie ike; ọ ghaghị ito, nwapụta ezi agwa', irish: 'D’fhuascail Íosa Úrmhac na hÓighe Beannaithe pór Éava agus Ádhaimh', japanese: '色は匂へど 散りぬるを 我が世誰ぞ 常ならむ 有為の奥山 今日越えて 浅き夢見じ 酔ひもせず', @@ -35,8 +34,7 @@ const PANGRAMS = { romanian: 'Muzicologă în bej vând whisky și tequila, preț fix.', russian: 'Эх, чужак, общий съём цен шляп (юфть) – вдрызг!', swedish: 'Yxskaftbud, ge vår WC-zonmö IQ-hjälp.', - thai: - 'เป็นมนุษย์สุดประเสริฐเลิศคุณค่า กว่าบรรดาฝูงสัตว์เดรัจฉาน จงฝ่าฟันพัฒนาวิชาการ อย่าล้างผลาญฤๅเข่นฆ่าบีฑาใคร ไม่ถือโทษโกรธแช่งซัดฮึดฮัดด่า หัดอภัยเหมือนกีฬาอัชฌาสัย ปฏิบัติประพฤติกฎกำหนดใจ พูดจาให้จ๊ะๆ จ๋าๆ น่าฟังเอยฯ', + thai: 'เป็นมนุษย์สุดประเสริฐเลิศคุณค่า กว่าบรรดาฝูงสัตว์เดรัจฉาน จงฝ่าฟันพัฒนาวิชาการ อย่าล้างผลาญฤๅเข่นฆ่าบีฑาใคร ไม่ถือโทษโกรธแช่งซัดฮึดฮัดด่า หัดอภัยเหมือนกีฬาอัชฌาสัย ปฏิบัติประพฤติกฎกำหนดใจ พูดจาให้จ๊ะๆ จ๋าๆ น่าฟังเอยฯ', }; export default function TextLegend(): React.Node { diff --git a/packages/rn-tester/js/components/createExamplePage.js b/packages/rn-tester/js/components/createExamplePage.js index 477717fef1f..596e73b4b5f 100644 --- a/packages/rn-tester/js/components/createExamplePage.js +++ b/packages/rn-tester/js/components/createExamplePage.js @@ -15,7 +15,7 @@ const React = require('react'); import RNTesterModuleContainer from './RNTesterModuleContainer'; import type {RNTesterModule} from '../types/RNTesterTypes'; -const createExamplePage = function( +const createExamplePage = function ( title: ?string, exampleModule: RNTesterModule, ): React.ComponentType { diff --git a/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExApp.js b/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExApp.js index 2bebbe67ad0..aa40b1ea520 100644 --- a/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExApp.js +++ b/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExApp.js @@ -241,7 +241,7 @@ class AnExApp extends React.Component { } else { let onLayout = null; if (!this.state.restLayouts[idx]) { - onLayout = function(index, e) { + onLayout = function (index, e) { const layout = e.nativeEvent.layout; this.setState(state => { state.restLayouts[index] = layout; diff --git a/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExScroll.js b/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExScroll.js index 35c98ee89b8..4183459262d 100644 --- a/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExScroll.js +++ b/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExScroll.js @@ -113,12 +113,10 @@ const styles = StyleSheet.create({ }); const HAWK_PIC = { - uri: - 'https://scontent-sea1-1.xx.fbcdn.net/hphotos-xfa1/t39.1997-6/10734304_1562225620659674_837511701_n.png', + uri: 'https://scontent-sea1-1.xx.fbcdn.net/hphotos-xfa1/t39.1997-6/10734304_1562225620659674_837511701_n.png', }; const BUNNY_PIC = { - uri: - 'https://scontent-sea1-1.xx.fbcdn.net/hphotos-xaf1/t39.1997-6/851564_531111380292237_1898871086_n.png', + uri: 'https://scontent-sea1-1.xx.fbcdn.net/hphotos-xaf1/t39.1997-6/851564_531111380292237_1898871086_n.png', }; module.exports = AnExScroll; diff --git a/packages/rn-tester/js/examples/Button/ButtonExample.js b/packages/rn-tester/js/examples/Button/ButtonExample.js index f3b3e057832..017997df1b1 100644 --- a/packages/rn-tester/js/examples/Button/ButtonExample.js +++ b/packages/rn-tester/js/examples/Button/ButtonExample.js @@ -29,7 +29,7 @@ exports.description = 'Simple React Native button component.'; exports.examples = [ { title: 'Button with default styling', - render: function(): React.Node { + render: function (): React.Node { return (