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