RN: Follow-up Format w/ Prettier v2.x
Summary: When I upgraded React Native to Prettier v2.x, I removed `format` from a few files to reduce the number of changes. This is a follow-up to bring back `format` and fix any remaining issues. Changelog: [Internal] Reviewed By: zertosh Differential Revision: D32287259 fbshipit-source-id: 37ea6d2c973b1db5d37c46d73675bdf436fb9a9d
This commit is contained in:
Родитель
cf763cdf81
Коммит
10f9ab4d69
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @noformat
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
@ -72,19 +72,17 @@ class MessageQueue {
|
|||
}
|
||||
|
||||
// $FlowFixMe[cannot-write]
|
||||
this.callFunctionReturnFlushedQueue =
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.callFunctionReturnFlushedQueue = this.callFunctionReturnFlushedQueue.bind(
|
||||
this,
|
||||
);
|
||||
this.callFunctionReturnFlushedQueue.bind(this);
|
||||
// $FlowFixMe[cannot-write]
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.flushedQueue = this.flushedQueue.bind(this);
|
||||
|
||||
// $FlowFixMe[cannot-write]
|
||||
this.invokeCallbackAndReturnFlushedQueue =
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
this.invokeCallbackAndReturnFlushedQueue = this.invokeCallbackAndReturnFlushedQueue.bind(
|
||||
this,
|
||||
);
|
||||
this.invokeCallbackAndReturnFlushedQueue.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @noformat
|
||||
* @format
|
||||
*/
|
||||
|
||||
const React = require('react');
|
||||
|
@ -100,7 +100,8 @@ const ProgressBarAndroid = (
|
|||
|
||||
const ProgressBarAndroidToExport = React.forwardRef(ProgressBarAndroid);
|
||||
|
||||
/* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an
|
||||
module.exports =
|
||||
/* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment suppresses an
|
||||
* error found when Flow v0.89 was deployed. To see the error, delete this
|
||||
* comment and run Flow. */
|
||||
module.exports = (ProgressBarAndroidToExport: typeof ProgressBarAndroidNativeComponent);
|
||||
(ProgressBarAndroidToExport: typeof ProgressBarAndroidNativeComponent);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow
|
||||
* @noformat
|
||||
* @format
|
||||
*/
|
||||
|
||||
/* eslint-env jest */
|
||||
|
@ -26,13 +26,14 @@ export type ReactTestInstance = $PropertyType<ReactTestRendererType, 'root'>;
|
|||
export type Predicate = (node: ReactTestInstance) => boolean;
|
||||
|
||||
type $ReturnType<Fn> = $Call<<Ret, A>((...A) => Ret) => Ret, Fn>;
|
||||
/* $FlowFixMe[prop-missing] (>=0.125.1 site=react_native_fb) This comment
|
||||
* suppresses an error found when Flow v0.125.1 was deployed. To see the error,
|
||||
* delete this comment and run Flow. */
|
||||
/* $FlowFixMe[value-as-type] (>=0.125.1 site=react_native_fb) This comment
|
||||
* suppresses an error found when Flow v0.125.1 was deployed. To see the error,
|
||||
* delete this comment and run Flow. */
|
||||
export type ReactTestRendererJSON = $ReturnType<ReactTestRenderer.create.toJSON>;
|
||||
export type ReactTestRendererJSON =
|
||||
/* $FlowFixMe[prop-missing] (>=0.125.1 site=react_native_fb) This comment
|
||||
* suppresses an error found when Flow v0.125.1 was deployed. To see the error,
|
||||
* delete this comment and run Flow. */
|
||||
$ReturnType<ReactTestRenderer.create.toJSON>;
|
||||
|
||||
const {
|
||||
Switch,
|
||||
|
@ -199,10 +200,8 @@ function tap(instance: ReactTestInstance) {
|
|||
} else if (
|
||||
touchable?.props?.onStartShouldSetResponder?.testOnly_pressabilityConfig
|
||||
) {
|
||||
const {
|
||||
onPress,
|
||||
disabled,
|
||||
} = touchable.props.onStartShouldSetResponder.testOnly_pressabilityConfig();
|
||||
const {onPress, disabled} =
|
||||
touchable.props.onStartShouldSetResponder.testOnly_pressabilityConfig();
|
||||
if (!disabled) {
|
||||
onPress({nativeEvent: {}});
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @noformat
|
||||
* @format
|
||||
* @polyfill
|
||||
* @nolint
|
||||
*/
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
@ -19,7 +19,7 @@
|
|||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries
|
||||
*/
|
||||
if (typeof Object.entries !== 'function') {
|
||||
Object.entries = function(object) {
|
||||
Object.entries = function (object) {
|
||||
// `null` and `undefined` values are not allowed.
|
||||
if (object == null) {
|
||||
throw new TypeError('Object.entries called on non-object');
|
||||
|
@ -40,7 +40,7 @@
|
|||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values
|
||||
*/
|
||||
if (typeof Object.values !== 'function') {
|
||||
Object.values = function(object) {
|
||||
Object.values = function (object) {
|
||||
// `null` and `undefined` values are not allowed.
|
||||
if (object == null) {
|
||||
throw new TypeError('Object.values called on non-object');
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* @polyfill
|
||||
* @nolint
|
||||
* @noformat
|
||||
* @format
|
||||
*/
|
||||
|
||||
/* eslint-disable no-shadow, eqeqeq, curly, no-unused-vars, no-void, no-control-regex */
|
||||
|
@ -15,7 +15,7 @@
|
|||
* This pipes all of our console logging functions to native logging so that
|
||||
* JavaScript errors in required modules show up in Xcode via NSLog.
|
||||
*/
|
||||
const inspect = (function() {
|
||||
const inspect = (function () {
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -55,7 +55,7 @@ const inspect = (function() {
|
|||
function arrayToHash(array) {
|
||||
var hash = {};
|
||||
|
||||
array.forEach(function(val, idx) {
|
||||
array.forEach(function (val, idx) {
|
||||
hash[val] = true;
|
||||
});
|
||||
|
||||
|
@ -153,7 +153,7 @@ const inspect = (function() {
|
|||
if (array) {
|
||||
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
||||
} else {
|
||||
output = keys.map(function(key) {
|
||||
output = keys.map(function (key) {
|
||||
return formatProperty(
|
||||
ctx,
|
||||
value,
|
||||
|
@ -210,7 +210,7 @@ const inspect = (function() {
|
|||
output.push('');
|
||||
}
|
||||
}
|
||||
keys.forEach(function(key) {
|
||||
keys.forEach(function (key) {
|
||||
if (!key.match(/^\d+$/)) {
|
||||
output.push(
|
||||
formatProperty(ctx, value, recurseTimes, visibleKeys, key, true),
|
||||
|
@ -248,7 +248,7 @@ const inspect = (function() {
|
|||
if (array) {
|
||||
str = str
|
||||
.split('\n')
|
||||
.map(function(line) {
|
||||
.map(function (line) {
|
||||
return ' ' + line;
|
||||
})
|
||||
.join('\n')
|
||||
|
@ -258,7 +258,7 @@ const inspect = (function() {
|
|||
'\n' +
|
||||
str
|
||||
.split('\n')
|
||||
.map(function(line) {
|
||||
.map(function (line) {
|
||||
return ' ' + line;
|
||||
})
|
||||
.join('\n');
|
||||
|
@ -290,7 +290,7 @@ const inspect = (function() {
|
|||
|
||||
function reduceToSingleString(output, base, braces) {
|
||||
var numLinesEst = 0;
|
||||
var length = output.reduce(function(prev, cur) {
|
||||
var length = output.reduce(function (prev, cur) {
|
||||
numLinesEst++;
|
||||
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
||||
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
||||
|
@ -396,13 +396,13 @@ INSPECTOR_LEVELS[LOG_LEVELS.error] = 'error';
|
|||
const INSPECTOR_FRAMES_TO_SKIP = __DEV__ ? 2 : 1;
|
||||
|
||||
function getNativeLogFunction(level) {
|
||||
return function() {
|
||||
return function () {
|
||||
let str;
|
||||
if (arguments.length === 1 && typeof arguments[0] === 'string') {
|
||||
str = arguments[0];
|
||||
} else {
|
||||
str = Array.prototype.map
|
||||
.call(arguments, function(arg) {
|
||||
.call(arguments, function (arg) {
|
||||
return inspect(arg, {depth: 10});
|
||||
})
|
||||
.join(', ');
|
||||
|
@ -443,7 +443,7 @@ function getNativeLogFunction(level) {
|
|||
}
|
||||
|
||||
function repeat(element, n) {
|
||||
return Array.apply(null, Array(n)).map(function() {
|
||||
return Array.apply(null, Array(n)).map(function () {
|
||||
return element;
|
||||
});
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ function consoleTablePolyfill(rows) {
|
|||
|
||||
// Convert each cell to a string. Also
|
||||
// figure out max cell width for each column
|
||||
columns.forEach(function(k, i) {
|
||||
columns.forEach(function (k, i) {
|
||||
columnWidths[i] = k.length;
|
||||
for (var j = 0; j < rows.length; j++) {
|
||||
var cellStr = (rows[j][k] || '?').toString();
|
||||
|
@ -485,7 +485,7 @@ function consoleTablePolyfill(rows) {
|
|||
// Join all elements in the row into a single string with | separators
|
||||
// (appends extra spaces to each cell to make separators | aligned)
|
||||
function joinRow(row, space) {
|
||||
var cells = row.map(function(cell, i) {
|
||||
var cells = row.map(function (cell, i) {
|
||||
var extraSpaces = repeat(' ', columnWidths[i] - cell.length).join('');
|
||||
return cell + extraSpaces;
|
||||
});
|
||||
|
@ -493,7 +493,7 @@ function consoleTablePolyfill(rows) {
|
|||
return cells.join(space + '|' + space);
|
||||
}
|
||||
|
||||
var separators = columnWidths.map(function(columnWidth) {
|
||||
var separators = columnWidths.map(function (columnWidth) {
|
||||
return repeat('-', columnWidth).join('');
|
||||
});
|
||||
var separatorRow = joinRow(separators, '-');
|
||||
|
@ -579,7 +579,7 @@ if (global.nativeLoggingHook) {
|
|||
Object.keys(console).forEach(methodName => {
|
||||
const reactNativeMethod = console[methodName];
|
||||
if (originalConsole[methodName]) {
|
||||
console[methodName] = function() {
|
||||
console[methodName] = function () {
|
||||
originalConsole[methodName](...arguments);
|
||||
reactNativeMethod.apply(console, arguments);
|
||||
};
|
||||
|
@ -591,7 +591,7 @@ if (global.nativeLoggingHook) {
|
|||
// supported by it.
|
||||
['clear', 'dir', 'dirxml', 'profile', 'profileEnd'].forEach(methodName => {
|
||||
if (typeof originalConsole[methodName] === 'function') {
|
||||
console[methodName] = function() {
|
||||
console[methodName] = function () {
|
||||
originalConsole[methodName](...arguments);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict
|
||||
* @noformat
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
@ -100,10 +100,8 @@ function translateFunctionParamToJavaType(
|
|||
imports: Set<string>,
|
||||
): string {
|
||||
const {optional, typeAnnotation: nullableTypeAnnotation} = param;
|
||||
const [
|
||||
typeAnnotation,
|
||||
nullable,
|
||||
] = unwrapNullable<NativeModuleParamTypeAnnotation>(nullableTypeAnnotation);
|
||||
const [typeAnnotation, nullable] =
|
||||
unwrapNullable<NativeModuleParamTypeAnnotation>(nullableTypeAnnotation);
|
||||
const isRequired = !optional && !nullable;
|
||||
|
||||
function wrapIntoNullableIfNeeded(generatedType: string) {
|
||||
|
@ -169,10 +167,8 @@ function translateFunctionReturnTypeToJavaType(
|
|||
resolveAlias: AliasResolver,
|
||||
imports: Set<string>,
|
||||
): string {
|
||||
const [
|
||||
returnTypeAnnotation,
|
||||
nullable,
|
||||
] = unwrapNullable<NativeModuleReturnTypeAnnotation>(
|
||||
const [returnTypeAnnotation, nullable] =
|
||||
unwrapNullable<NativeModuleReturnTypeAnnotation>(
|
||||
nullableReturnTypeAnnotation,
|
||||
);
|
||||
|
||||
|
@ -234,10 +230,8 @@ function getFalsyReturnStatementFromReturnType(
|
|||
createErrorMessage: (typeName: string) => string,
|
||||
resolveAlias: AliasResolver,
|
||||
): string {
|
||||
const [
|
||||
returnTypeAnnotation,
|
||||
nullable,
|
||||
] = unwrapNullable<NativeModuleReturnTypeAnnotation>(
|
||||
const [returnTypeAnnotation, nullable] =
|
||||
unwrapNullable<NativeModuleReturnTypeAnnotation>(
|
||||
nullableReturnTypeAnnotation,
|
||||
);
|
||||
|
||||
|
@ -288,9 +282,8 @@ function buildGetConstantsMethod(
|
|||
method: NativeModulePropertyShape,
|
||||
imports: Set<string>,
|
||||
): string {
|
||||
const [
|
||||
methodTypeAnnotation,
|
||||
] = unwrapNullable<NativeModuleFunctionTypeAnnotation>(method.typeAnnotation);
|
||||
const [methodTypeAnnotation] =
|
||||
unwrapNullable<NativeModuleFunctionTypeAnnotation>(method.typeAnnotation);
|
||||
if (
|
||||
methodTypeAnnotation.returnTypeAnnotation.type === 'ObjectTypeAnnotation'
|
||||
) {
|
||||
|
@ -405,9 +398,8 @@ module.exports = {
|
|||
return buildGetConstantsMethod(method, imports);
|
||||
}
|
||||
|
||||
const [
|
||||
methodTypeAnnotation,
|
||||
] = unwrapNullable<NativeModuleFunctionTypeAnnotation>(
|
||||
const [methodTypeAnnotation] =
|
||||
unwrapNullable<NativeModuleFunctionTypeAnnotation>(
|
||||
method.typeAnnotation,
|
||||
);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче