Codemod prettier to 1.5.2
Differential Revision: D5339725 fbshipit-source-id: 631338436a7d69b0ab0721507bdab4ae4e207065
This commit is contained in:
parent
2f193b9bc1
commit
c848c3820b
|
@ -456,8 +456,7 @@ const JSTimers = {
|
|||
*/
|
||||
callImmediates() {
|
||||
errors = null;
|
||||
while (JSTimers.callImmediatesPass()) {
|
||||
}
|
||||
while (JSTimers.callImmediatesPass()) {}
|
||||
if (errors) {
|
||||
errors.forEach(error =>
|
||||
JSTimers.setTimeout(() => {
|
||||
|
|
|
@ -115,13 +115,13 @@ class FillRateHelper {
|
|||
const derived = {
|
||||
avg_blankness: this._info.pixels_blank / this._info.pixels_sampled,
|
||||
avg_speed: this._info.pixels_scrolled / (total_time_spent / 1000),
|
||||
avg_speed_when_any_blank: this._info.any_blank_speed_sum /
|
||||
this._info.any_blank_count,
|
||||
any_blank_per_min: this._info.any_blank_count /
|
||||
(total_time_spent / 1000 / 60),
|
||||
avg_speed_when_any_blank:
|
||||
this._info.any_blank_speed_sum / this._info.any_blank_count,
|
||||
any_blank_per_min:
|
||||
this._info.any_blank_count / (total_time_spent / 1000 / 60),
|
||||
any_blank_time_frac: this._info.any_blank_ms / total_time_spent,
|
||||
mostly_blank_per_min: this._info.mostly_blank_count /
|
||||
(total_time_spent / 1000 / 60),
|
||||
mostly_blank_per_min:
|
||||
this._info.mostly_blank_count / (total_time_spent / 1000 / 60),
|
||||
mostly_blank_time_frac: this._info.mostly_blank_ms / total_time_spent,
|
||||
};
|
||||
for (const key in derived) {
|
||||
|
|
|
@ -304,8 +304,11 @@ type DefaultProps = typeof defaultProps;
|
|||
* Alternatively, you can provide a custom `keyExtractor` prop.
|
||||
*
|
||||
*/
|
||||
class FlatList<ItemT>
|
||||
extends React.PureComponent<DefaultProps, Props<ItemT>, void> {
|
||||
class FlatList<ItemT> extends React.PureComponent<
|
||||
DefaultProps,
|
||||
Props<ItemT>,
|
||||
void,
|
||||
> {
|
||||
static defaultProps: DefaultProps = defaultProps;
|
||||
props: Props<ItemT>;
|
||||
/**
|
||||
|
|
|
@ -524,8 +524,8 @@ var ListView = React.createClass({
|
|||
ref: this._setScrollComponentRef,
|
||||
onContentSizeChange: this._onContentSizeChange,
|
||||
onLayout: this._onLayout,
|
||||
DEPRECATED_sendUpdatedChildFrames: typeof props.onChangeVisibleRows !==
|
||||
undefined,
|
||||
DEPRECATED_sendUpdatedChildFrames:
|
||||
typeof props.onChangeVisibleRows !== undefined,
|
||||
},
|
||||
header,
|
||||
bodyComponents,
|
||||
|
|
|
@ -183,9 +183,8 @@ class MetroListView extends React.Component {
|
|||
);
|
||||
return renderSectionHeader({section});
|
||||
};
|
||||
_renderSeparator = (sID, rID) => (
|
||||
<this.props.SeparatorComponent key={sID + rID} />
|
||||
);
|
||||
_renderSeparator = (sID, rID) =>
|
||||
<this.props.SeparatorComponent key={sID + rID} />;
|
||||
}
|
||||
|
||||
module.exports = MetroListView;
|
||||
|
|
|
@ -18,9 +18,7 @@ const React = require('React');
|
|||
const VirtualizedSectionList = require('VirtualizedSectionList');
|
||||
|
||||
import type {ViewToken} from 'ViewabilityHelper';
|
||||
import type {
|
||||
Props as VirtualizedSectionListProps,
|
||||
} from 'VirtualizedSectionList';
|
||||
import type {Props as VirtualizedSectionListProps} from 'VirtualizedSectionList';
|
||||
|
||||
type Item = any;
|
||||
|
||||
|
@ -253,8 +251,11 @@ type DefaultProps = typeof defaultProps;
|
|||
* Alternatively, you can provide a custom `keyExtractor` prop.
|
||||
*
|
||||
*/
|
||||
class SectionList<SectionT: SectionBase<any>>
|
||||
extends React.PureComponent<DefaultProps, Props<SectionT>, void> {
|
||||
class SectionList<SectionT: SectionBase<any>> extends React.PureComponent<
|
||||
DefaultProps,
|
||||
Props<SectionT>,
|
||||
void,
|
||||
> {
|
||||
props: Props<SectionT>;
|
||||
static defaultProps: DefaultProps = defaultProps;
|
||||
|
||||
|
|
|
@ -105,9 +105,8 @@ function computeWindowedRenderLimits(
|
|||
// Considering velocity seems to introduce more churn than it's worth.
|
||||
const leadFactor = 0.5; // Math.max(0, Math.min(1, velocity / 25 + 0.5));
|
||||
|
||||
const fillPreference = velocity > 1
|
||||
? 'after'
|
||||
: velocity < -1 ? 'before' : 'none';
|
||||
const fillPreference =
|
||||
velocity > 1 ? 'after' : velocity < -1 ? 'before' : 'none';
|
||||
|
||||
const overscanBegin = Math.max(
|
||||
0,
|
||||
|
@ -124,7 +123,8 @@ function computeWindowedRenderLimits(
|
|||
overscanFirst = overscanFirst == null ? 0 : overscanFirst;
|
||||
first = first == null ? Math.max(0, overscanFirst) : first;
|
||||
overscanLast = overscanLast == null ? itemCount - 1 : overscanLast;
|
||||
last = last == null
|
||||
last =
|
||||
last == null
|
||||
? Math.min(overscanLast, first + maxToRenderPerBatch - 1)
|
||||
: last;
|
||||
const visible = {first, last};
|
||||
|
@ -174,13 +174,15 @@ function computeWindowedRenderLimits(
|
|||
}
|
||||
}
|
||||
if (
|
||||
!(last >= first &&
|
||||
!(
|
||||
last >= first &&
|
||||
first >= 0 &&
|
||||
last < itemCount &&
|
||||
first >= overscanFirst &&
|
||||
last <= overscanLast &&
|
||||
first <= visible.first &&
|
||||
last >= visible.last)
|
||||
last >= visible.last
|
||||
)
|
||||
) {
|
||||
throw new Error(
|
||||
'Bad window calculation ' +
|
||||
|
|
|
@ -385,7 +385,8 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
|
|||
);
|
||||
this.state = {
|
||||
first: this.props.initialScrollIndex || 0,
|
||||
last: Math.min(
|
||||
last:
|
||||
Math.min(
|
||||
this.props.getItemCount(this.props.data),
|
||||
(this.props.initialScrollIndex || 0) + this.props.initialNumToRender,
|
||||
) - 1,
|
||||
|
@ -496,8 +497,9 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
|
|||
|
||||
_isNestedWithSameOrientation(): boolean {
|
||||
const nestedContext = this.context.virtualizedList;
|
||||
return !!(nestedContext &&
|
||||
!!nestedContext.horizontal === !!this.props.horizontal);
|
||||
return !!(
|
||||
nestedContext && !!nestedContext.horizontal === !!this.props.horizontal
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -680,7 +682,12 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
|
|||
cells,
|
||||
);
|
||||
if (this.props.debug) {
|
||||
return <View style={{flex: 1}}>{ret}{this._renderDebugOverlay()}</View>;
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
{ret}
|
||||
{this._renderDebugOverlay()}
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
|
@ -840,7 +847,7 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
|
|||
borderColor: 'blue',
|
||||
borderWidth: 1,
|
||||
}}>
|
||||
{framesInLayout.map((f, ii) => (
|
||||
{framesInLayout.map((f, ii) =>
|
||||
<View
|
||||
key={'f' + ii}
|
||||
style={{
|
||||
|
@ -850,8 +857,8 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
|
|||
height: f.length * normalize,
|
||||
backgroundColor: 'orange',
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
/>,
|
||||
)}
|
||||
<View
|
||||
style={{
|
||||
...baseStyle,
|
||||
|
@ -1047,8 +1054,8 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
|
|||
} else {
|
||||
const {contentLength, offset, visibleLength} = this._scrollMetrics;
|
||||
const distanceFromEnd = contentLength - visibleLength - offset;
|
||||
const renderAhead = distanceFromEnd <
|
||||
onEndReachedThreshold * visibleLength
|
||||
const renderAhead =
|
||||
distanceFromEnd < onEndReachedThreshold * visibleLength
|
||||
? this.props.maxToRenderPerBatch
|
||||
: 0;
|
||||
newState = {
|
||||
|
@ -1121,7 +1128,7 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
|
|||
{frame: frameType},
|
||||
{frame},
|
||||
'frame',
|
||||
'VirtualizedList.getItemLayout'
|
||||
'VirtualizedList.getItemLayout',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1221,9 +1228,8 @@ class CellRenderer extends React.Component {
|
|||
index,
|
||||
separators: this._separators,
|
||||
});
|
||||
const onLayout = getItemLayout &&
|
||||
!parentProps.debug &&
|
||||
!fillRateHelper.enabled()
|
||||
const onLayout =
|
||||
getItemLayout && !parentProps.debug && !fillRateHelper.enabled()
|
||||
? undefined
|
||||
: this.props.onLayout;
|
||||
// NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
|
||||
|
|
|
@ -133,8 +133,11 @@ type State = {childProps: VirtualizedListProps};
|
|||
* hood. The only operation that might not scale well is concatting the data arrays of all the
|
||||
* sections when new props are received, which should be plenty fast for up to ~10,000 items.
|
||||
*/
|
||||
class VirtualizedSectionList<SectionT: SectionBase>
|
||||
extends React.PureComponent<DefaultProps, Props<SectionT>, State> {
|
||||
class VirtualizedSectionList<SectionT: SectionBase> extends React.PureComponent<
|
||||
DefaultProps,
|
||||
Props<SectionT>,
|
||||
State,
|
||||
> {
|
||||
props: Props<SectionT>;
|
||||
|
||||
state: State;
|
||||
|
@ -459,7 +462,11 @@ class ItemWithSeparator extends React.Component {
|
|||
SeparatorComponent &&
|
||||
<SeparatorComponent {...this.state.separatorProps} />;
|
||||
return leadingSeparator || separator
|
||||
? <View>{leadingSeparator}{element}{separator}</View>
|
||||
? <View>
|
||||
{leadingSeparator}
|
||||
{element}
|
||||
{separator}
|
||||
</View>
|
||||
: element;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,8 @@ function renderMyListItem(info: {item: {title: string}, index: number}) {
|
|||
return <span />;
|
||||
}
|
||||
|
||||
const renderMyHeader = ({section}: {section: {fooNumber: number} & Object}) => (
|
||||
<span />
|
||||
);
|
||||
const renderMyHeader = ({section}: {section: {fooNumber: number} & Object}) =>
|
||||
<span />;
|
||||
|
||||
module.exports = {
|
||||
testGoodDataWithGoodItem() {
|
||||
|
|
|
@ -40,23 +40,20 @@ describe('SectionList', () => {
|
|||
const component = ReactTestRenderer.create(
|
||||
<SectionList
|
||||
initialNumToRender={Infinity}
|
||||
ItemSeparatorComponent={props => (
|
||||
<defaultItemSeparator v={propStr(props)} />
|
||||
)}
|
||||
ItemSeparatorComponent={props =>
|
||||
<defaultItemSeparator v={propStr(props)} />}
|
||||
ListEmptyComponent={props => <empty v={propStr(props)} />}
|
||||
ListFooterComponent={props => <footer v={propStr(props)} />}
|
||||
ListHeaderComponent={props => <header v={propStr(props)} />}
|
||||
SectionSeparatorComponent={props => (
|
||||
<sectionSeparator v={propStr(props)} />
|
||||
)}
|
||||
SectionSeparatorComponent={props =>
|
||||
<sectionSeparator v={propStr(props)} />}
|
||||
sections={[
|
||||
{
|
||||
renderItem: props => <itemForSection1 v={propStr(props)} />,
|
||||
key: 's1',
|
||||
keyExtractor: (item, index) => item.id,
|
||||
ItemSeparatorComponent: props => (
|
||||
<itemSeparatorForSection1 v={propStr(props)} />
|
||||
),
|
||||
ItemSeparatorComponent: props =>
|
||||
<itemSeparatorForSection1 v={propStr(props)} />,
|
||||
data: [{id: 'i1s1'}, {id: 'i2s1'}],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -140,7 +140,7 @@ describe('VirtualizedList', () => {
|
|||
const component = ReactTestRenderer.create(
|
||||
<VirtualizedList
|
||||
data={[{key: 'outer0'}, {key: 'outer1'}]}
|
||||
renderItem={outerInfo => (
|
||||
renderItem={outerInfo =>
|
||||
<VirtualizedList
|
||||
data={[
|
||||
{key: outerInfo.item.key + ':inner0'},
|
||||
|
@ -152,8 +152,7 @@ describe('VirtualizedList', () => {
|
|||
}}
|
||||
getItem={(data, index) => data[index]}
|
||||
getItemCount={data => data.length}
|
||||
/>
|
||||
)}
|
||||
/>}
|
||||
getItem={(data, index) => data[index]}
|
||||
getItemCount={data => data.length}
|
||||
/>,
|
||||
|
|
|
@ -111,7 +111,11 @@ class AppContainer extends React.Component {
|
|||
|
||||
const Wrapper = this.props.WrapperComponent;
|
||||
if (Wrapper) {
|
||||
innerView = <Wrapper>{innerView}</Wrapper>;
|
||||
innerView = (
|
||||
<Wrapper>
|
||||
{innerView}
|
||||
</Wrapper>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={styles.appContainer} pointerEvents="box-none">
|
||||
|
|
|
@ -45,12 +45,16 @@ class CameraRollExample extends React.Component {
|
|||
onValueChange={this._onSwitchChange}
|
||||
value={this.state.bigImages}
|
||||
/>
|
||||
<Text>{(this.state.bigImages ? 'Big' : 'Small') + ' Images'}</Text>
|
||||
<Text>
|
||||
{(this.state.bigImages ? 'Big' : 'Small') + ' Images'}
|
||||
</Text>
|
||||
<Slider
|
||||
value={this.state.sliderValue}
|
||||
onValueChange={this._onSliderChange}
|
||||
/>
|
||||
<Text>{'Group Type: ' + this.state.groupTypes}</Text>
|
||||
<Text>
|
||||
{'Group Type: ' + this.state.groupTypes}
|
||||
</Text>
|
||||
<CameraRollView
|
||||
ref={ref => {
|
||||
this._cameraRollView = ref;
|
||||
|
@ -86,10 +90,18 @@ class CameraRollExample extends React.Component {
|
|||
<View style={styles.row}>
|
||||
<Image source={asset.node.image} style={imageStyle} />
|
||||
<View style={styles.info}>
|
||||
<Text style={styles.url}>{asset.node.image.uri}</Text>
|
||||
<Text>{locationStr}</Text>
|
||||
<Text>{asset.node.group_name}</Text>
|
||||
<Text>{new Date(asset.node.timestamp).toString()}</Text>
|
||||
<Text style={styles.url}>
|
||||
{asset.node.image.uri}
|
||||
</Text>
|
||||
<Text>
|
||||
{locationStr}
|
||||
</Text>
|
||||
<Text>
|
||||
{asset.node.group_name}
|
||||
</Text>
|
||||
<Text>
|
||||
{new Date(asset.node.timestamp).toString()}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
|
Loading…
Reference in New Issue