Upgrade Prettier from 1.17 to 2.0.2.

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
This commit is contained in:
Michael Bolin
2020-03-24 20:24:47 -07:00
committed by Facebook GitHub Bot
parent 79c69bea02
commit cf44650b3f
383 changed files with 2051 additions and 2072 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ const {NativeModules} = require('react-native');
const {Assert} = NativeModules;
const Asserts = {
assertEquals: function(expected, actual, msg) {
assertEquals: function (expected, actual, msg) {
if (expected !== actual) {
Assert.fail(
msg ||
@@ -30,7 +30,7 @@ const Asserts = {
Assert.success();
}
},
assertTrue: function(expr, msg) {
assertTrue: function (expr, msg) {
Asserts.assertEquals(true, expr, msg);
},
};
@@ -41,7 +41,7 @@ class CatalystRootViewTestApp extends React.Component {
}
const ReactRootViewTestModule = {
setHeight: function(height) {
setHeight: function (height) {
that.setState({height: height});
},
};
@@ -23,7 +23,7 @@ class DatePickerDialogTestApp extends React.Component {
const DatePickerDialogTestModule = {
DatePickerDialogTestApp: DatePickerDialogTestApp,
showDatePickerDialog: function(options) {
showDatePickerDialog: function (options) {
DatePickerAndroid.open(options).then(
({action, year, month, day}) => {
if (action === DatePickerAndroid.dateSetAction) {
@@ -15,7 +15,7 @@ const {Image, NativeModules, StyleSheet, View} = require('react-native');
const {Recording: RecordingModule} = NativeModules;
class ImageErrorTestApp extends React.Component {
onError = e => {
onError = (e) => {
RecordingModule.record('Got error: ' + e.nativeEvent.error);
};
@@ -30,7 +30,7 @@ class LayoutEventsTestApp extends React.Component {
this.numParentLayouts = 0;
}
handleOnLayout = e => {
handleOnLayout = (e) => {
const layout = e.nativeEvent.layout;
RecordingModule.record(
layout.x + ',' + layout.y + '-' + layout.width + 'x' + layout.height,
@@ -46,7 +46,7 @@ class LayoutEventsTestApp extends React.Component {
}
};
handleParentOnLayout = e => {
handleParentOnLayout = (e) => {
if (this.numParentLayouts > 0) {
// This will cause the test to fail - the parent's layout doesn't change
// so we should only get the event once.
@@ -71,24 +71,24 @@ function shouldNotCallThisCallback() {
const MeasureLayoutTestModule = {
MeasureLayoutTestApp: MeasureLayoutTestApp,
verifyMeasureOnViewA: function() {
UIManager.measure(A, function(a, b, width, height, x, y) {
verifyMeasureOnViewA: function () {
UIManager.measure(A, function (a, b, width, height, x, y) {
assertEquals(500, width);
assertEquals(500, height);
assertEquals(0, x);
assertEquals(0, y);
});
},
verifyMeasureOnViewC: function() {
UIManager.measure(C, function(a, b, width, height, x, y) {
verifyMeasureOnViewC: function () {
UIManager.measure(C, function (a, b, width, height, x, y) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(150, x);
assertEquals(150, y);
});
},
verifyMeasureLayoutCRelativeToA: function() {
UIManager.measureLayout(C, A, shouldNotCallThisCallback, function(
verifyMeasureLayoutCRelativeToA: function () {
UIManager.measureLayout(C, A, shouldNotCallThisCallback, function (
x,
y,
width,
@@ -100,8 +100,8 @@ const MeasureLayoutTestModule = {
assertEquals(150, y);
});
},
verifyMeasureLayoutCRelativeToB: function() {
UIManager.measureLayout(C, B, shouldNotCallThisCallback, function(
verifyMeasureLayoutCRelativeToB: function () {
UIManager.measureLayout(C, B, shouldNotCallThisCallback, function (
x,
y,
width,
@@ -113,8 +113,8 @@ const MeasureLayoutTestModule = {
assertEquals(70, y);
});
},
verifyMeasureLayoutCRelativeToSelf: function() {
UIManager.measureLayout(C, C, shouldNotCallThisCallback, function(
verifyMeasureLayoutCRelativeToSelf: function () {
UIManager.measureLayout(C, C, shouldNotCallThisCallback, function (
x,
y,
width,
@@ -126,11 +126,11 @@ const MeasureLayoutTestModule = {
assertEquals(0, y);
});
},
verifyMeasureLayoutRelativeToParentOnViewA: function() {
verifyMeasureLayoutRelativeToParentOnViewA: function () {
UIManager.measureLayoutRelativeToParent(
A,
shouldNotCallThisCallback,
function(x, y, width, height) {
function (x, y, width, height) {
assertEquals(500, width);
assertEquals(500, height);
assertEquals(0, x);
@@ -138,11 +138,11 @@ const MeasureLayoutTestModule = {
},
);
},
verifyMeasureLayoutRelativeToParentOnViewB: function() {
verifyMeasureLayoutRelativeToParentOnViewB: function () {
UIManager.measureLayoutRelativeToParent(
B,
shouldNotCallThisCallback,
function(x, y, width, height) {
function (x, y, width, height) {
assertEquals(200, width);
assertEquals(300, height);
assertEquals(50, x);
@@ -150,11 +150,11 @@ const MeasureLayoutTestModule = {
},
);
},
verifyMeasureLayoutRelativeToParentOnViewC: function() {
verifyMeasureLayoutRelativeToParentOnViewC: function () {
UIManager.measureLayoutRelativeToParent(
C,
shouldNotCallThisCallback,
function(x, y, width, height) {
function (x, y, width, height) {
assertEquals(50, width);
assertEquals(150, height);
assertEquals(100, x);
@@ -162,40 +162,40 @@ const MeasureLayoutTestModule = {
},
);
},
verifyMeasureLayoutDRelativeToB: function() {
verifyMeasureLayoutDRelativeToB: function () {
UIManager.measureLayout(
D,
B,
function() {
function () {
assertEquals(true, true);
},
shouldNotCallThisCallback,
);
},
verifyMeasureLayoutNonExistentTag: function() {
verifyMeasureLayoutNonExistentTag: function () {
UIManager.measureLayout(
192,
A,
function() {
function () {
assertEquals(true, true);
},
shouldNotCallThisCallback,
);
},
verifyMeasureLayoutNonExistentAncestor: function() {
verifyMeasureLayoutNonExistentAncestor: function () {
UIManager.measureLayout(
B,
192,
function() {
function () {
assertEquals(true, true);
},
shouldNotCallThisCallback,
);
},
verifyMeasureLayoutRelativeToParentNonExistentTag: function() {
verifyMeasureLayoutRelativeToParentNonExistentTag: function () {
UIManager.measureLayoutRelativeToParent(
192,
function() {
function () {
assertEquals(true, true);
},
shouldNotCallThisCallback,
@@ -14,7 +14,7 @@ const {NativeModules, StyleSheet, View} = require('react-native');
const {Recording} = NativeModules;
const extractSingleTouch = nativeEvent => {
const extractSingleTouch = (nativeEvent) => {
const touches = nativeEvent.touches;
const changedTouches = nativeEvent.changedTouches;
const hasTouches = touches && touches.length > 0;
@@ -28,16 +28,16 @@ const extractSingleTouch = nativeEvent => {
};
class TouchTestApp extends React.Component {
handleStartShouldSetResponder = e => {
handleStartShouldSetResponder = (e) => {
return true;
};
handleOnResponderMove = e => {
handleOnResponderMove = (e) => {
e = extractSingleTouch(e.nativeEvent);
Recording.record('move;' + e.touches.length);
};
handleResponderStart = e => {
handleResponderStart = (e) => {
e = extractSingleTouch(e.nativeEvent);
if (e.touches) {
Recording.record('start;' + e.touches.length);
@@ -46,7 +46,7 @@ class TouchTestApp extends React.Component {
}
};
handleResponderEnd = e => {
handleResponderEnd = (e) => {
e = extractSingleTouch(e.nativeEvent);
if (e.touches) {
Recording.record('end;' + e.touches.length);
@@ -62,7 +62,7 @@ class PickerAndroidTestApp extends React.Component {
);
}
onValueChange = value => {
onValueChange = (value) => {
this.setState({selected: value});
RecordingModule.recordSelection(value);
};
@@ -70,13 +70,13 @@ class PickerAndroidTestApp extends React.Component {
const PickerAndroidTestModule = {
PickerAndroidTestApp: PickerAndroidTestApp,
selectItem: function(value) {
selectItem: function (value) {
appInstance.setState({selected: value});
},
setMode: function(mode) {
setMode: function (mode) {
appInstance.setState({mode: mode});
},
setPrimaryColor: function(color) {
setPrimaryColor: function (color) {
appInstance.setState({style: {color}});
},
};
@@ -40,7 +40,7 @@ class ProgressBarSampleApp extends React.Component {
}
const ProgressBarTestModule = {
renderProgressBarApplication: function(rootTag) {
renderProgressBarApplication: function (rootTag) {
renderApplication(ProgressBarSampleApp, {}, rootTag);
},
};
@@ -51,7 +51,7 @@ class Item extends React.Component<ItemProps, ItemState> {
}
}
const getInitialState = function() {
const getInitialState = function () {
const data = [];
for (let i = 0; i < NUM_ITEMS; i++) {
data[i] = {text: 'Item ' + i + '!'};
@@ -61,28 +61,28 @@ const getInitialState = function() {
};
};
const onScroll = function(e) {
const onScroll = function (e) {
ScrollListener.onScroll(
e.nativeEvent.contentOffset.x,
e.nativeEvent.contentOffset.y,
);
};
const onScrollBeginDrag = function(e) {
const onScrollBeginDrag = function (e) {
ScrollListener.onScrollBeginDrag(
e.nativeEvent.contentOffset.x,
e.nativeEvent.contentOffset.y,
);
};
const onScrollEndDrag = function(e) {
const onScrollEndDrag = function (e) {
ScrollListener.onScrollEndDrag(
e.nativeEvent.contentOffset.x,
e.nativeEvent.contentOffset.y,
);
};
const onItemPress = function(itemNumber) {
const onItemPress = function (itemNumber) {
ScrollListener.onItemPress(itemNumber);
};
@@ -23,7 +23,7 @@ class ShareTestApp extends React.Component {
const ShareTestModule = {
ShareTestApp: ShareTestApp,
showShareDialog: function(content, options) {
showShareDialog: function (content, options) {
Share.share(content, options).then(
() => RecordingModule.recordOpened(),
({code, message}) => RecordingModule.recordError(),
@@ -330,7 +330,7 @@ class SubviewsClippingTestApp extends React.Component {
appInstance = this;
}
setComponent = component => {
setComponent = (component) => {
this.setState({component: component});
};
@@ -342,21 +342,21 @@ class SubviewsClippingTestApp extends React.Component {
const SubviewsClippingTestModule = {
App: SubviewsClippingTestApp,
renderClippingSample1: function() {
renderClippingSample1: function () {
appInstance.setComponent(<ClippingSample1 />);
},
renderClippingSample2: function() {
renderClippingSample2: function () {
appInstance.setComponent(<ClippingSample2 />);
},
renderUpdatingSample1: function(update1, update2) {
renderUpdatingSample1: function (update1, update2) {
appInstance.setComponent(
<UpdatingSample1 update1={update1} update2={update2} />,
);
},
renderUpdatingSample2: function(update) {
renderUpdatingSample2: function (update) {
appInstance.setComponent(<UpdatingSample2 update={update} />);
},
renderScrollViewTest: function() {
renderScrollViewTest: function () {
appInstance.setComponent(<ScrollViewTest />);
},
};
@@ -77,7 +77,7 @@ class SwipeRefreshLayoutTestApp extends React.Component {
const SwipeRefreshLayoutTestModule = {
SwipeRefreshLayoutTestApp,
setRows: function(rows) {
setRows: function (rows) {
if (app != null) {
app.setState({rows});
}
@@ -15,10 +15,10 @@ const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridg
const {Recording} = NativeModules;
const TestJSLocaleModule = {
toUpper: function(s) {
toUpper: function (s) {
Recording.record(s.toUpperCase());
},
toLower: function(s) {
toLower: function (s) {
Recording.record(s.toLowerCase());
},
};
@@ -15,26 +15,26 @@ const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridg
const {Recording} = NativeModules;
const TestJSToJavaParametersModule = {
returnBasicTypes: function() {
returnBasicTypes: function () {
Recording.receiveBasicTypes('foo', 3.14, true, null);
},
returnBoxedTypes: function() {
returnBoxedTypes: function () {
Recording.receiveBoxedTypes(42, 3.14, true);
},
returnDynamicTypes: function() {
returnDynamicTypes: function () {
Recording.receiveDynamic('foo');
Recording.receiveDynamic(3.14);
},
returnArrayWithBasicTypes: function() {
returnArrayWithBasicTypes: function () {
Recording.receiveArray(['foo', 3.14, -111, true, null]);
},
returnNestedArray: function() {
returnNestedArray: function () {
Recording.receiveArray(['we', ['have', ['to', ['go', ['deeper']]]]]);
},
returnArrayWithMaps: function() {
returnArrayWithMaps: function () {
Recording.receiveArray([{m1k1: 'm1v1', m1k2: 'm1v2'}, {m2k1: 'm2v1'}]);
},
returnMapWithBasicTypes: function() {
returnMapWithBasicTypes: function () {
Recording.receiveMap({
stringKey: 'stringValue',
doubleKey: 3.14,
@@ -43,24 +43,24 @@ const TestJSToJavaParametersModule = {
nullKey: null,
});
},
returnNestedMap: function() {
returnNestedMap: function () {
Recording.receiveMap({
weHaveToGoDeeper: {
inception: true,
},
});
},
returnMapWithArrays: function() {
returnMapWithArrays: function () {
Recording.receiveMap({
empty: [],
ints: [43, 44],
mixed: [77, 'string', ['another', 'array']],
});
},
returnArrayWithStringDoubleIntMapArrayBooleanNull: function() {
returnArrayWithStringDoubleIntMapArrayBooleanNull: function () {
Recording.receiveArray(['string', 3.14, 555, {}, [], true, null]);
},
returnMapWithStringDoubleIntMapArrayBooleanNull: function() {
returnMapWithStringDoubleIntMapArrayBooleanNull: function () {
Recording.receiveMap({
string: 'string',
double: 3,
@@ -71,13 +71,13 @@ const TestJSToJavaParametersModule = {
null: null,
});
},
returnArrayWithLargeInts: function() {
returnArrayWithLargeInts: function () {
Recording.receiveArray([2147483648, -5555555555]);
},
returnMapWithLargeInts: function() {
returnMapWithLargeInts: function () {
Recording.receiveMap({first: -2147483649, second: 5551231231});
},
returnMapForMerge1: function() {
returnMapForMerge1: function () {
Recording.receiveMap({
a: 1,
b: 41,
@@ -87,7 +87,7 @@ const TestJSToJavaParametersModule = {
f: null,
});
},
returnMapForMerge2: function() {
returnMapForMerge2: function () {
Recording.receiveMap({
a: 'overwrite',
d: 77,
@@ -96,7 +96,7 @@ const TestJSToJavaParametersModule = {
newkey: 'newvalue',
});
},
returnMapWithMultibyteUTF8CharacterString: function() {
returnMapWithMultibyteUTF8CharacterString: function () {
Recording.receiveMap({
'one-byte': 'a',
'two-bytes': '\u00A2',
@@ -106,7 +106,7 @@ const TestJSToJavaParametersModule = {
'\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107',
});
},
returnArrayWithMultibyteUTF8CharacterString: function() {
returnArrayWithMultibyteUTF8CharacterString: function () {
Recording.receiveArray([
'a',
'\u00A2',
@@ -29,20 +29,20 @@ function assertStrictStringEquals(a, b) {
}
const TestJavaToJSArgumentsModule = {
receiveBasicTypes: function(str, dbl, bool, null_arg) {
receiveBasicTypes: function (str, dbl, bool, null_arg) {
assertEquals('foo', str);
assertEquals(3.14, dbl);
assertEquals(true, bool);
assertEquals(null, null_arg);
},
receiveArrayWithBasicTypes: function(arr) {
receiveArrayWithBasicTypes: function (arr) {
assertEquals(4, arr.length);
assertEquals('red panda', arr[0]);
assertEquals(1.19, arr[1]);
assertEquals(true, arr[2]);
assertEquals(null, arr[3]);
},
receiveNestedArray: function(arr) {
receiveNestedArray: function (arr) {
assertEquals(2, arr.length);
assertEquals('level1', arr[0]);
const arr2 = arr[1];
@@ -50,7 +50,7 @@ const TestJavaToJSArgumentsModule = {
const arr3 = arr2[1];
assertEquals('level3', arr3[0]);
},
receiveArrayWithMaps: function(arr) {
receiveArrayWithMaps: function (arr) {
assertEquals(2, arr.length);
const m1 = arr[0];
const m2 = arr[1];
@@ -58,17 +58,17 @@ const TestJavaToJSArgumentsModule = {
assertEquals('m1v2', m1.m1k2);
assertEquals('m2v1', m2.m2k1);
},
receiveMapWithBasicTypes: function(map) {
receiveMapWithBasicTypes: function (map) {
assertEquals('stringValue', map.stringKey);
assertEquals(3.14, map.doubleKey);
assertEquals(true, map.booleanKey);
assertEquals(null, map.nullKey);
},
receiveNestedMap: function(map) {
receiveNestedMap: function (map) {
const nestedMap = map.nestedMap;
assertEquals('foxes', nestedMap.animals);
},
receiveMapWithArrays: function(map) {
receiveMapWithArrays: function (map) {
const a1 = map.array1;
const a2 = map.array2;
assertEquals(3, a1.length);
@@ -76,7 +76,7 @@ const TestJavaToJSArgumentsModule = {
assertEquals(3, a1[0]);
assertEquals(9, a2[1]);
},
receiveMapAndArrayWithNullValues: function(map, array) {
receiveMapAndArrayWithNullValues: function (map, array) {
assertEquals(null, map.string);
assertEquals(null, map.array);
assertEquals(null, map.map);
@@ -85,7 +85,7 @@ const TestJavaToJSArgumentsModule = {
assertEquals(null, array[1]);
assertEquals(null, array[2]);
},
receiveMapWithMultibyteUTF8CharacterString: function(map) {
receiveMapWithMultibyteUTF8CharacterString: function (map) {
assertStrictStringEquals('\u00A2', map['two-bytes']);
assertStrictStringEquals('\u20AC', map['three-bytes']);
assertStrictStringEquals('\uD83D\uDE1C', map['four-bytes']);
@@ -94,7 +94,7 @@ const TestJavaToJSArgumentsModule = {
map.mixed,
);
},
receiveArrayWithMultibyteUTF8CharacterString: function(array) {
receiveArrayWithMultibyteUTF8CharacterString: function (array) {
assertTrue(true);
assertStrictStringEquals('\u00A2', array[0]);
assertStrictStringEquals('\u20AC', array[1]);
@@ -16,13 +16,13 @@ const {assertEquals, assertTrue} = require('./Asserts');
const {TestModule} = NativeModules;
const TestJavaToJSReturnValuesModule = {
callMethod: function(methodName, expectedType, expectedJSON) {
callMethod: function (methodName, expectedType, expectedJSON) {
const result = TestModule[methodName]();
assertEquals(expectedType, typeof result);
assertEquals(expectedJSON, JSON.stringify(result));
},
triggerException: function() {
triggerException: function () {
try {
TestModule.triggerException();
} catch (ex) {
@@ -55,7 +55,7 @@ class TokenizedTextExample extends React.Component {
parts.push(_text);
//highlight hashtags
parts = parts.map(text => {
parts = parts.map((text) => {
if (/^#/.test(text)) {
return (
<Text key={text} style={styles.hashtag}>
@@ -74,7 +74,7 @@ class TokenizedTextExample extends React.Component {
testID="tokenizedInput"
multiline={true}
style={styles.multiline}
onChangeText={text => {
onChangeText={(text) => {
this.setState({text});
}}>
<Text>{parts}</Text>
@@ -89,7 +89,7 @@ class TextInputTestApp extends React.Component {
app = this;
}
handleOnSubmitEditing = record => {
handleOnSubmitEditing = (record) => {
Recording.record(record);
};
@@ -176,7 +176,7 @@ const styles = StyleSheet.create({
const TextInputTestModule = {
TextInputTestApp,
setValueRef: function(ref, value) {
setValueRef: function (ref, value) {
app.refs[ref].setNativeProps({
text: value,
});
@@ -20,7 +20,7 @@ const {
const {Recording} = NativeModules;
class TouchBubblingTestApp extends React.Component {
handlePress = record => {
handlePress = (record) => {
Recording.record(record);
};
@@ -64,19 +64,19 @@ class TransformSampleApp extends React.Component {
}
const ViewRenderingTestModule = {
renderViewApplication: function(rootTag) {
renderViewApplication: function (rootTag) {
renderApplication(ViewSampleApp, {}, rootTag);
},
renderMarginApplication: function(rootTag) {
renderMarginApplication: function (rootTag) {
renderApplication(MarginSampleApp, {}, rootTag);
},
renderBorderApplication: function(rootTag) {
renderBorderApplication: function (rootTag) {
renderApplication(BorderSampleApp, {}, rootTag);
},
renderTransformApplication: function(rootTag) {
renderTransformApplication: function (rootTag) {
renderApplication(TransformSampleApp, {}, rootTag);
},
updateMargins: function() {
updateMargins: function () {
updateMargins();
},
};