Skip to content

Commit

Permalink
Upgrade Prettier from 1.17 to 2.0.2.
Browse files Browse the repository at this point in the history
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
  • Loading branch information
bolinfest authored and facebook-github-bot committed Mar 25, 2020
1 parent 79c69be commit cf44650
Show file tree
Hide file tree
Showing 383 changed files with 2,051 additions and 2,072 deletions.
2 changes: 1 addition & 1 deletion IntegrationTests/AccessibilityManagerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down
19 changes: 11 additions & 8 deletions IntegrationTests/AsyncStorageTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
};
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/ImageCachePolicyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ImageCachePolicyTest extends React.Component<Props, $FlowFixMeState> {
state: $FlowFixMe | {...} = {};

shouldComponentUpdate(nextProps: Props, nextState: State): boolean {
const results: Array<?boolean> = TESTS.map(x => nextState[x]);
const results: Array<?boolean> = TESTS.map((x) => nextState[x]);

if (!results.includes(undefined)) {
const result: boolean = results.reduce(
Expand Down
4 changes: 2 additions & 2 deletions IntegrationTests/IntegrationTestsApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,7 +76,7 @@ class IntegrationTestsApp extends React.Component<{...}, $FlowFixMeState> {
</Text>
<View style={styles.separator} />
<ScrollView>
{TESTS.map(test => [
{TESTS.map((test) => [
<TouchableOpacity
onPress={() => this.setState({test})}
/* $FlowFixMe(>=0.115.0 site=react_native_fb) This comment
Expand Down
6 changes: 3 additions & 3 deletions IntegrationTests/LayoutEventsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,21 @@ class LayoutEventsTest extends React.Component<Props, State> {
return (
<View style={[styles.container, this.state.containerStyle]}>
<View
ref={ref => {
ref={(ref) => {
this._view = ref;
}}
onLayout={this.onViewLayout}
style={viewStyle}>
<Image
ref={ref => {
ref={(ref) => {
this._img = ref;
}}
onLayout={this.onImageLayout}
style={styles.image}
source={{uri: 'uie_thumb_big.png'}}
/>
<Text
ref={ref => {
ref={(ref) => {
this._txt = ref;
}}
onLayout={this.onTextLayout}
Expand Down
14 changes: 7 additions & 7 deletions IntegrationTests/LoggingTestModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
};
Expand Down
4 changes: 2 additions & 2 deletions IntegrationTests/RCTRootViewIntegrationTestApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const TESTS = [
require('./SizeFlexibilityUpdateTest'),
];

TESTS.forEach(test =>
TESTS.forEach((test) =>
AppRegistry.registerComponent(test.displayName, () => test),
);

Expand All @@ -54,7 +54,7 @@ class RCTRootViewIntegrationTestApp extends React.Component {
</Text>
<View style={styles.separator} />
<ScrollView>
{TESTS.map(test => [
{TESTS.map((test) => [
<TouchableOpacity
onPress={() => this.setState({test})}
style={styles.row}>
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/SyncMethodTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/TimersTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class TimersTest extends React.Component<Props, State> {
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);
Expand Down
10 changes: 5 additions & 5 deletions IntegrationTests/WebSocketTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
});
};
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Alert/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Alert/RCTAlertManager.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions Libraries/Animated/release/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var babelOpts = {
}),
};

var buildDist = function(opts) {
var buildDist = function (opts) {
var webpackOpts = {
debug: opts.debug,
externals: {
Expand Down Expand Up @@ -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);
}
Expand All @@ -101,19 +101,19 @@ 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))
.pipe(flatten())
.pipe(gulp.dest(paths.lib));
});

gulp.task('dist', ['modules'], function() {
gulp.task('dist', ['modules'], function () {
var distOpts = {
debug: true,
output: 'animated.js',
Expand All @@ -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',
Expand All @@ -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);
});
10 changes: 6 additions & 4 deletions Libraries/Animated/src/AnimatedEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -70,7 +70,7 @@ function attachNativeEvent(
return {
detach() {
if (viewTag != null) {
eventMappings.forEach(mapping => {
eventMappings.forEach((mapping) => {
NativeAnimatedHelper.API.removeAnimatedEventFromView(
viewTag,
eventName,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -226,7 +228,7 @@ class AnimatedEvent {
}

_callListeners(...args: any) {
this._listeners.forEach(listener => listener(...args));
this._listeners.forEach((listener) => listener(...args));
}
}

Expand Down
Loading

0 comments on commit cf44650

Please sign in to comment.