Skip to content

Commit

Permalink
Codemod prettier to 1.5.2
Browse files Browse the repository at this point in the history
Differential Revision: D5339725

fbshipit-source-id: 631338436a7d69b0ab0721507bdab4ae4e207065
  • Loading branch information
vjeux authored and facebook-github-bot committed Jun 28, 2017
1 parent 2f193b9 commit c848c38
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 77 deletions.
3 changes: 1 addition & 2 deletions Libraries/Core/Timers/JSTimers.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,7 @@ const JSTimers = {
*/
callImmediates() {
errors = null;
while (JSTimers.callImmediatesPass()) {
}
while (JSTimers.callImmediatesPass()) {}
if (errors) {
errors.forEach(error =>
JSTimers.setTimeout(() => {
Expand Down
12 changes: 6 additions & 6 deletions Libraries/Lists/FillRateHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
/**
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Lists/ListView/ListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions Libraries/Lists/MetroListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
11 changes: 6 additions & 5 deletions Libraries/Lists/SectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
18 changes: 10 additions & 8 deletions Libraries/Lists/VirtualizeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -124,9 +123,10 @@ function computeWindowedRenderLimits(
overscanFirst = overscanFirst == null ? 0 : overscanFirst;
first = first == null ? Math.max(0, overscanFirst) : first;
overscanLast = overscanLast == null ? itemCount - 1 : overscanLast;
last = last == null
? Math.min(overscanLast, first + maxToRenderPerBatch - 1)
: last;
last =
last == null
? Math.min(overscanLast, first + maxToRenderPerBatch - 1)
: last;
const visible = {first, last};

// We want to limit the number of new cells we're rendering per batch so that we can fill the
Expand Down Expand Up @@ -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 ' +
Expand Down
50 changes: 28 additions & 22 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,11 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
);
this.state = {
first: this.props.initialScrollIndex || 0,
last: Math.min(
this.props.getItemCount(this.props.data),
(this.props.initialScrollIndex || 0) + this.props.initialNumToRender,
) - 1,
last:
Math.min(
this.props.getItemCount(this.props.data),
(this.props.initialScrollIndex || 0) + this.props.initialNumToRender,
) - 1,
};
}

Expand Down Expand Up @@ -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() {
Expand All @@ -519,8 +521,8 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
const isVirtualizationDisabled = this._isVirtualizationDisabled();
const inversionStyle = this.props.inverted
? this.props.horizontal
? styles.horizontallyInverted
: styles.verticallyInverted
? styles.horizontallyInverted
: styles.verticallyInverted
: null;
const cells = [];
const stickyIndicesFromProps = new Set(this.props.stickyHeaderIndices);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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={{
Expand All @@ -850,8 +857,8 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
height: f.length * normalize,
backgroundColor: 'orange',
}}
/>
))}
/>,
)}
<View
style={{
...baseStyle,
Expand Down Expand Up @@ -1047,10 +1054,10 @@ 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
? this.props.maxToRenderPerBatch
: 0;
const renderAhead =
distanceFromEnd < onEndReachedThreshold * visibleLength
? this.props.maxToRenderPerBatch
: 0;
newState = {
first: 0,
last: Math.min(state.last + renderAhead, getItemCount(data) - 1),
Expand Down Expand Up @@ -1121,7 +1128,7 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
{frame: frameType},
{frame},
'frame',
'VirtualizedList.getItemLayout'
'VirtualizedList.getItemLayout',
);
}
}
Expand Down Expand Up @@ -1221,11 +1228,10 @@ class CellRenderer extends React.Component {
index,
separators: this._separators,
});
const onLayout = getItemLayout &&
!parentProps.debug &&
!fillRateHelper.enabled()
? undefined
: this.props.onLayout;
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
// called explicitly by `ScrollViewStickyHeader`.
return (
Expand Down
13 changes: 10 additions & 3 deletions Libraries/Lists/VirtualizedSectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
5 changes: 2 additions & 3 deletions Libraries/Lists/__flowtests__/SectionList-flowtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
15 changes: 6 additions & 9 deletions Libraries/Lists/__tests__/SectionList-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}],
},
{
Expand Down
5 changes: 2 additions & 3 deletions Libraries/Lists/__tests__/VirtualizedList-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand All @@ -152,8 +152,7 @@ describe('VirtualizedList', () => {
}}
getItem={(data, index) => data[index]}
getItemCount={data => data.length}
/>
)}
/>}
getItem={(data, index) => data[index]}
getItemCount={data => data.length}
/>,
Expand Down
6 changes: 5 additions & 1 deletion Libraries/ReactNative/AppContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
24 changes: 18 additions & 6 deletions RNTester/js/CameraRollExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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>
Expand Down
Loading

0 comments on commit c848c38

Please sign in to comment.