Skip to content

Commit

Permalink
fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
priley86 committed Jun 5, 2019
1 parent 9156534 commit 367189c
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,17 @@ ContextBody.propTypes = {
headerData: PropTypes.array,
rows: PropTypes.array,
rowKey: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
onRowClick: PropTypes.func
onRowClick: PropTypes.func,
onRow: PropTypes.func
};

ContextBody.defaultProps = {
className: '',
children: null,
headerData: [],
rows: [],
onRowClick: () => undefined
onRowClick: () => undefined,
onRow: () => undefined
};

const TableBody = props => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import mergeProps from './merge-props';
import { tableBodyRowDefaults, tableBodyRowTypes } from './types';

class BodyRow extends React.Component {
shouldComponentUpdate(nextProps) { // eslint-disable-line no-unused-vars
shouldComponentUpdate(nextProps) {
// eslint-disable-line no-unused-vars
const previousProps = this.props;

// Check for row based override.
Expand All @@ -29,25 +30,19 @@ class BodyRow extends React.Component {
}

return !(
columnsAreEqual(previousProps.columns, nextProps.columns) &&
isEqual(previousProps.rowData, nextProps.rowData)
columnsAreEqual(previousProps.columns, nextProps.columns) && isEqual(previousProps.rowData, nextProps.rowData)
);
}
render() {
const {
columns, renderers, onRow, rowKey, rowIndex, rowData
} = this.props;
const { columns, renderers, onRow, rowKey, rowIndex, rowData } = this.props;

return React.createElement(
renderers.row,
onRow(rowData, { rowIndex, rowKey }),
columns.map((column, columnIndex) => {
const { property, cell, props } = column;
const evaluatedProperty = property || (cell && cell.property);
const {
transforms = [],
formatters = []
} = cell || {}; // TODO: test against this case
const { transforms = [], formatters = [] } = cell || {}; // TODO: test against this case
const extraParameters = {
columnIndex,
property: evaluatedProperty,
Expand All @@ -66,14 +61,13 @@ class BodyRow extends React.Component {
renderers.cell,
{
key: `${columnIndex}-cell`,
...mergeProps(
props,
cell && cell.props,
transformed
)
...mergeProps(props, cell && cell.props, transformed)
},
transformed.children || evaluateFormatters(formatters)(rowData[`_${evaluatedProperty}`] ||
rowData[evaluatedProperty], extraParameters)
transformed.children ||
evaluateFormatters(formatters)(
rowData[`_${evaluatedProperty}`] || rowData[evaluatedProperty],
extraParameters
)
);
})
);
Expand All @@ -82,4 +76,4 @@ class BodyRow extends React.Component {
BodyRow.defaultProps = tableBodyRowDefaults;
BodyRow.propTypes = tableBodyRowTypes;

export default BodyRow;
export default BodyRow;
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ function resolveRowKey({ rowData, rowIndex, rowKey }) {
} else if (process.env.NODE_ENV !== 'production') {
// Arrays cannot have rowKeys by definition so we have to go by index there.
if (!isArray(rowData) && rowData[rowKey] === undefined) {
console.warn(
// eslint-disable-line no-console
'Table.Body - Missing valid rowKey!',
rowData,
rowKey
);
// eslint-disable-next-line no-console
console.warn('Table.Body - Missing valid rowKey!', rowData, rowKey);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @flow */
/* eslint-disable */

import type {
CellRenderer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @flow */
/* eslint-disable */

import * as React from 'react';
import type {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @flow */
/* eslint-disable */

import type { CellRangeRendererParams } from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as React from 'react';
import ScalingCellSizeAndPositionManager from './utils/ScalingCellSizeAndPositionManager';

export type CellPosition = {columnIndex: number, rowIndex: number};
export type CellPosition = { columnIndex: number, rowIndex: number };

export type CellRendererParams = {
columnIndex: number,
Expand All @@ -12,13 +12,13 @@ export type CellRendererParams = {
key: string,
parent: Object,
rowIndex: number,
style: Object,
style: Object
};

export type CellRenderer = (props: CellRendererParams) => React.Element<*>;

export type CellCache = {[key: string]: React.Element<*>};
export type StyleCache = {[key: string]: Object};
export type CellCache = { [key: string]: React.Element<*> };
export type StyleCache = { [key: string]: Object };

export type CellRangeRendererParams = {
cellCache: CellCache,
Expand All @@ -39,14 +39,12 @@ export type CellRangeRendererParams = {
styleCache: StyleCache,
verticalOffsetAdjustment: number,
visibleColumnIndices: Object,
visibleRowIndices: Object,
visibleRowIndices: Object
};

export type CellRangeRenderer = (
params: CellRangeRendererParams,
) => React.Element<*>[];
export type CellRangeRenderer = (params: CellRangeRendererParams) => React.Element<*>[];

export type CellSizeGetter = (params: {index: number}) => number;
export type CellSizeGetter = (params: { index: number }) => number;

export type CellSize = CellSizeGetter | number;

Expand All @@ -58,13 +56,13 @@ export type Scroll = {
scrollHeight: number,
scrollLeft: number,
scrollTop: number,
scrollWidth: number,
scrollWidth: number
};

export type ScrollbarPresenceChange = {
horizontal: boolean,
vertical: boolean,
size: number,
size: number
};

export type RenderedSection = {
Expand All @@ -75,7 +73,7 @@ export type RenderedSection = {
rowOverscanStartIndex: number,
rowOverscanStopIndex: number,
rowStartIndex: number,
rowStopIndex: number,
rowStopIndex: number
};

export type OverscanIndicesGetterParams = {
Expand All @@ -95,21 +93,19 @@ export type OverscanIndicesGetterParams = {
startIndex: number,

// End of range of visible cells
stopIndex: number,
stopIndex: number
};

export type OverscanIndices = {
overscanStartIndex: number,
overscanStopIndex: number,
overscanStopIndex: number
};

export type OverscanIndicesGetter = (
params: OverscanIndicesGetterParams,
) => OverscanIndices;
export type OverscanIndicesGetter = (params: OverscanIndicesGetterParams) => OverscanIndices;

export type Alignment = 'auto' | 'end' | 'start' | 'center';

export type VisibleCellRange = {
start?: number,
stop?: number,
stop?: number
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @flow */
/* eslint-disable */

import LinearLayoutVector from 'linear-layout-vector';
import type { Alignment, CellSizeGetter, VisibleCellRange } from '../types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @flow */
/* eslint-disable */

import type { Alignment, CellSizeGetter, VisibleCellRange } from '../types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export default function createCallbackMemoizer(requireAllKeys = true) {
let cachedIndices = {};

return ({callback, indices}) => {
return ({ callback, indices }) => {
const keys = Object.keys(indices);
const allInitialized =
!requireAllKeys ||
Expand All @@ -18,9 +18,7 @@ export default function createCallbackMemoizer(requireAllKeys = true) {
const cachedValue = cachedIndices[key];
const value = indices[key];

return Array.isArray(value)
? cachedValue.join(',') !== value.join(',')
: cachedValue !== value;
return Array.isArray(value) ? cachedValue.join(',') !== value.join(',') : cachedValue !== value;
});

cachedIndices = indices;
Expand All @@ -29,4 +27,4 @@ export default function createCallbackMemoizer(requireAllKeys = true) {
callback(indices);
}
};
}
}

0 comments on commit 367189c

Please sign in to comment.