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