From f1699777ec5f067aed3d0bee9446d9bdb9e3d661 Mon Sep 17 00:00:00 2001 From: Aman Mahajan Date: Mon, 26 Nov 2018 16:43:32 -0600 Subject: [PATCH] More auto fix eslint rules (#1399) * Enable a few more eslint rules * Enable the object-curly-spacing rule --- .eslintrc | 15 ++ .../cells/headerCells/FilterableHeaderCell.js | 6 +- .../cells/headerCells/SortableHeaderCell.js | 2 +- .../__tests__/SortableHeaderCell.spec.js | 6 +- .../editors/__tests__/CheckboxEditor.spec.js | 2 +- .../__tests__/SimpleTextEditor.spec.js | 2 +- .../src/__tests__/Grid.spec.js | 48 ++-- .../headerCells/filters/AutoCompleteFilter.js | 10 +- .../headerCells/filters/NumericFilter.js | 2 +- .../__tests__/AutoCompleteFilter.spec.js | 24 +- .../src/data/RowFilterer.js | 2 +- .../src/data/RowGrouper.js | 4 +- .../src/data/RowGrouperResolver.js | 4 +- .../src/data/RowSorter.js | 2 +- .../src/data/Selectors.js | 2 +- .../src/data/__tests__/RowFilterer.spec.js | 8 +- .../src/data/__tests__/RowSorter.spec.js | 2 +- .../src/data/__tests__/Selectors.spec.js | 8 +- .../react-data-grid-addons/src/data/index.js | 2 +- .../src/draggable/DropTargetRowContainer.js | 4 +- .../src/draggable/RowActionsCell.js | 4 +- .../src/draggable/RowDragLayer.js | 16 +- .../__tests__/DropTargetRowContainer.spec.js | 10 +- .../src/editors/AutoCompleteEditor.js | 2 +- .../src/editors/AutoCompleteTokensEditor.js | 8 +- .../src/editors/DateRangeEditor.js | 2 +- .../AutoCompleteEditor-integration.spec.js | 2 +- .../__tests__/AutoCompleteEditor.spec.js | 24 +- .../__tests__/ContainerEditorWrapper.spec.js | 2 +- .../src/editors/widgets/DateRangeFilter.js | 8 +- .../src/formatters/DateRangeFormatter.js | 2 +- packages/react-data-grid-addons/src/index.js | 4 +- .../src/menu/ContextMenu.js | 40 ++-- .../src/menu/__tests__/ContextMenu.spec.js | 2 +- .../react-data-grid-addons/src/menu/index.js | 4 +- .../src/toolbars/AdvancedToolbar.js | 58 ++--- .../src/toolbars/GroupedColumnButton.js | 2 +- .../src/toolbars/GroupedColumnsPanel.js | 6 +- .../src/toolbars/Toolbar.js | 2 +- .../src/toolbars/index.js | 2 +- packages/react-data-grid/src/Cell.js | 14 +- packages/react-data-grid/src/CellAction.js | 2 +- packages/react-data-grid/src/CellExpander.js | 2 +- .../src/ChildRowDeleteButton.js | 2 +- packages/react-data-grid/src/ColumnMetrics.js | 4 +- packages/react-data-grid/src/Draggable.js | 4 +- packages/react-data-grid/src/Grid.js | 4 +- packages/react-data-grid/src/Header.js | 10 +- packages/react-data-grid/src/HeaderCell.js | 16 +- packages/react-data-grid/src/HeaderRow.js | 2 +- packages/react-data-grid/src/ReactDataGrid.js | 48 ++-- packages/react-data-grid/src/Row.js | 2 +- packages/react-data-grid/src/Viewport.js | 4 +- .../src/__tests__/Canvas.spec.js | 20 +- .../src/__tests__/Cell.spec.js | 34 +-- .../src/__tests__/CellAction.spec.js | 208 +++++++++--------- .../src/__tests__/ColumnMetrics.spec.js | 6 +- .../src/__tests__/ColumnUtils.spec.js | 2 +- .../__tests__/FocusableComponentTestRunner.js | 4 +- .../src/__tests__/Grid.spec.js | 8 +- .../src/__tests__/Header.spec.js | 8 +- .../src/__tests__/HeaderCell.spec.js | 32 +-- .../src/__tests__/HeaderRow.spec.js | 24 +- .../react-data-grid/src/__tests__/Row.spec.js | 44 ++-- .../src/__tests__/RowComparer.spec.js | 2 +- .../src/__tests__/RowUtils.spec.js | 12 +- .../src/__tests__/Viewport.spec.js | 10 +- .../src/focusableComponentWrapper.js | 4 +- packages/react-data-grid/src/getWindowSize.js | 2 +- .../src/masks/InteractionMasks.js | 2 +- .../src/masks/SelectionMask.js | 2 +- .../src/masks/SelectionRangeMask.js | 2 +- .../src/utils/SelectedCellUtils.js | 2 +- .../src/utils/viewportUtils.js | 12 +- 74 files changed, 462 insertions(+), 447 deletions(-) diff --git a/.eslintrc b/.eslintrc index 585b0ddafd..b3d993591f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -46,6 +46,8 @@ }], "no-use-before-define": 2, // http://eslint.org/docs/rules/no-use-before-define, "no-undef": 2, + "no-delete-var": 2, + "no-label-var": 2, /** * Possible errors @@ -71,6 +73,10 @@ "no-unreachable": 2, // http://eslint.org/docs/rules/no-unreachable "use-isnan": 2, // http://eslint.org/docs/rules/use-isnan "block-scoped-var": 2, // http://eslint.org/docs/rules/block-scoped-var + "no-dupe-args": 2, + "no-template-curly-in-string": 2, + "valid-typeof": [2, { "requireStringLiterals": true }], + /** * Best practices */ @@ -114,6 +120,13 @@ "wrap-iife": [2, "any"], // http://eslint.org/docs/rules/wrap-iife "yoda": 2, // http://eslint.org/docs/rules/yoda, "prefer-const": 2, + "no-empty-pattern": 2, + "no-extra-label": 2, + "no-global-assign": 2, + "no-self-assign": 2, + "no-unmodified-loop-condition": 2, + "no-unused-expressions": [2, { "allowShortCircuit": true }], + "no-useless-call": 2, /** * Style @@ -166,6 +179,8 @@ "keyword-spacing": 0, // http://eslint.org/docs/rules/space-return-throw-case "spaced-comment": 2, // http://eslint.org/docs/rules/spaced-comment, "no-whitespace-before-property": 2, + "no-array-constructor": 2, + "object-curly-spacing": [1, "always"], /** * JSX style diff --git a/packages/common/cells/headerCells/FilterableHeaderCell.js b/packages/common/cells/headerCells/FilterableHeaderCell.js index 54dab2e4c2..6925cc19e9 100644 --- a/packages/common/cells/headerCells/FilterableHeaderCell.js +++ b/packages/common/cells/headerCells/FilterableHeaderCell.js @@ -8,12 +8,12 @@ class FilterableHeaderCell extends React.Component { column: PropTypes.shape(Column) }; - state = {filterTerm: ''}; + state = { filterTerm: '' }; handleChange = (e) => { const val = e.target.value; - this.setState({filterTerm: val }); - this.props.onChange({filterTerm: val, column: this.props.column}); + this.setState({ filterTerm: val }); + this.props.onChange({ filterTerm: val, column: this.props.column }); }; renderInput = () => { diff --git a/packages/common/cells/headerCells/SortableHeaderCell.js b/packages/common/cells/headerCells/SortableHeaderCell.js index 1f6ae082c5..c38a6ffadf 100644 --- a/packages/common/cells/headerCells/SortableHeaderCell.js +++ b/packages/common/cells/headerCells/SortableHeaderCell.js @@ -57,7 +57,7 @@ class SortableHeaderCell extends React.Component { return (
+ style={{ cursor: 'pointer' }}> {this.getSortByText()} {content}
diff --git a/packages/common/cells/headerCells/__tests__/SortableHeaderCell.spec.js b/packages/common/cells/headerCells/__tests__/SortableHeaderCell.spec.js index e79764695e..0e3dbfd8c2 100644 --- a/packages/common/cells/headerCells/__tests__/SortableHeaderCell.spec.js +++ b/packages/common/cells/headerCells/__tests__/SortableHeaderCell.spec.js @@ -1,5 +1,5 @@ import React from 'react'; -import SortableHeaderCell, {DEFINE_SORT} from '../SortableHeaderCell'; +import SortableHeaderCell, { DEFINE_SORT } from '../SortableHeaderCell'; import { shallow } from 'enzyme'; const defaultProps = { @@ -31,7 +31,7 @@ describe('', () => { describe('When sortDescendingFirst is true', () => { it('should set sort descending first when clicked', () => { - const { wrapper, props } = setup({sortDescendingFirst: true}); + const { wrapper, props } = setup({ sortDescendingFirst: true }); wrapper.simulate('click'); expect(props.onSort).toHaveBeenCalledWith(props.columnKey, DEFINE_SORT.DESC); }); @@ -40,7 +40,7 @@ describe('', () => { describe('When headerRenderer of column is set', () => { it('should render the header renderer', () => { const HeaderRenderer = () => (Custom); - const { wrapper } = setup({headerRenderer: }); + const { wrapper } = setup({ headerRenderer: }); expect(wrapper.find(HeaderRenderer).length).toBe(1); }); }); diff --git a/packages/common/editors/__tests__/CheckboxEditor.spec.js b/packages/common/editors/__tests__/CheckboxEditor.spec.js index 416b2d160d..d1b2407ff6 100644 --- a/packages/common/editors/__tests__/CheckboxEditor.spec.js +++ b/packages/common/editors/__tests__/CheckboxEditor.spec.js @@ -33,7 +33,7 @@ describe('CheckboxEditor', () => { }); it('should not be selected if value prop is false', () => { - componentWrapper.setProps({value: false}); + componentWrapper.setProps({ value: false }); const Input = TestUtils.findRenderedDOMComponentWithTag(component, 'input'); const checkboxNode = ReactDOM.findDOMNode(Input); expect(checkboxNode.checked).toBe(false); diff --git a/packages/common/editors/__tests__/SimpleTextEditor.spec.js b/packages/common/editors/__tests__/SimpleTextEditor.spec.js index 2c900567e2..58e134b613 100644 --- a/packages/common/editors/__tests__/SimpleTextEditor.spec.js +++ b/packages/common/editors/__tests__/SimpleTextEditor.spec.js @@ -6,7 +6,7 @@ describe('SimpleTextEditor', () => { describe('Basic tests', () => { let component; - const fakeColumn = { key: 'text', name: 'name', width: 0}; + const fakeColumn = { key: 'text', name: 'name', width: 0 }; function fakeBlurCb() { return true; } function fakeFunction() { } beforeEach(() => { diff --git a/packages/react-data-grid-addons/src/__tests__/Grid.spec.js b/packages/react-data-grid-addons/src/__tests__/Grid.spec.js index f37fa6cf9b..752f96ba7c 100644 --- a/packages/react-data-grid-addons/src/__tests__/Grid.spec.js +++ b/packages/react-data-grid-addons/src/__tests__/Grid.spec.js @@ -10,10 +10,10 @@ const { mount } = require('enzyme'); describe('Grid', function() { beforeEach(function() { this.columns = [ - { key: 'id', name: 'ID', width: 100, events: { onClick: () => {}} }, + { key: 'id', name: 'ID', width: 100, events: { onClick: () => {} } }, { key: 'title', name: 'Title', width: 100 }, { key: 'count', name: 'Count', width: 100 }, - { key: 'country', name: 'Country', width: 100, events: { onClick: () => {}, onDoubleClick: () => {}, onDragOver: () => {}}} + { key: 'country', name: 'Country', width: 100, events: { onClick: () => {}, onDoubleClick: () => {}, onDragOver: () => {} } } ]; this._rows = []; @@ -199,7 +199,7 @@ describe('Grid', function() { describe('When row selection enabled', function() { beforeEach(function() { - this.component = this.createComponent({ enableRowSelect: true}).instance(); + this.component = this.createComponent({ enableRowSelect: true }).instance(); this.baseGrid = this.getBaseGrid(); this.selectRowCol = this.baseGrid.props.columnMetrics.columns[0]; }); @@ -246,7 +246,7 @@ describe('Grid', function() { describe('when selected is false', function() { beforeEach(function() { - this.component.setState({selectedRows: [{id: 0, isSelected: false}, {id: 1, isSelected: false}, {id: 2, isSelected: false}, {id: 3, isSelected: false}]}); + this.component.setState({ selectedRows: [{ id: 0, isSelected: false }, { id: 1, isSelected: false }, { id: 2, isSelected: false }, { id: 3, isSelected: false }] }); const selectRowCol = this.baseGrid.props.columnMetrics.columns[0]; selectRowCol.onCellChange(3, 'select-row', this._rows[3], this.buildFakeEvent()); }); @@ -258,7 +258,7 @@ describe('Grid', function() { describe('when selected is null', function() { beforeEach(function() { - this.component.setState({selectedRows: [{id: 0, isSelected: null}, {id: 1, isSelected: null}, {id: 2, isSelected: null}, {id: 3, isSelected: null}]}); + this.component.setState({ selectedRows: [{ id: 0, isSelected: null }, { id: 1, isSelected: null }, { id: 2, isSelected: null }, { id: 3, isSelected: null }] }); const selectRowCol = this.baseGrid.props.columnMetrics.columns[0]; selectRowCol.onCellChange(2, 'select-row', this._rows[2], this.buildFakeEvent()); }); @@ -270,7 +270,7 @@ describe('Grid', function() { describe('when selected is true', function() { beforeEach(function() { - this.component.setState({selectedRows: [{id: 0, isSelected: null}, {id: 1, isSelected: true}, {id: 2, isSelected: true}, {id: 3, isSelected: true}]}); + this.component.setState({ selectedRows: [{ id: 0, isSelected: null }, { id: 1, isSelected: true }, { id: 2, isSelected: true }, { id: 3, isSelected: true }] }); const selectRowCol = this.baseGrid.props.columnMetrics.columns[0]; selectRowCol.onCellChange(3, 'select-row', this._rows[3], this.buildFakeEvent()); }); @@ -287,19 +287,19 @@ describe('Grid', function() { const self = this; this._selectedRows = []; this._deselectedRows = []; - this.rows = [{id: '1', isSelected: true}, {id: '2', isSelected: false}, {id: '3', isSelected: false}, {id: '4', isSelected: false}]; - const columns = [{name: 'Id', key: 'id'}]; + this.rows = [{ id: '1', isSelected: true }, { id: '2', isSelected: false }, { id: '3', isSelected: false }, { id: '4', isSelected: false }]; + const columns = [{ name: 'Id', key: 'id' }]; const rowGetter = function(i) { return self.rows[i]; }; - this.component = this.createComponent({ rowsCount: this.rows.length, rowGetter: rowGetter, columns: columns, rowSelection: {enableShiftSelect: true, selectBy: {isSelectedKey: 'isSelected'}, + this.component = this.createComponent({ rowsCount: this.rows.length, rowGetter: rowGetter, columns: columns, rowSelection: { enableShiftSelect: true, selectBy: { isSelectedKey: 'isSelected' }, onRowsSelected: function(selectedRows) { self._selectedRows = selectedRows; }, onRowsDeselected: function(deselectedRows) { self._deselectedRows = deselectedRows; } - }}).instance(); + } }).instance(); this.baseGrid = this.getBaseGrid(); this.selectRowCol = this.baseGrid.props.columnMetrics.columns[0]; }); @@ -348,19 +348,19 @@ describe('Grid', function() { const self = this; this._selectedRows = []; this._deselectedRows = []; - this.rows = [{id: '1'}, {id: '2'}]; - const columns = [{name: 'Id', key: 'id'}]; + this.rows = [{ id: '1' }, { id: '2' }]; + const columns = [{ name: 'Id', key: 'id' }]; const rowGetter = function(i) { return self.rows[i]; }; - this.component = this.createComponent({ enableRowSelect: true, rowsCount: this.rows.length, rowGetter: rowGetter, columns: columns, rowSelection: {selectBy: {indexes: []}, + this.component = this.createComponent({ enableRowSelect: true, rowsCount: this.rows.length, rowGetter: rowGetter, columns: columns, rowSelection: { selectBy: { indexes: [] }, onRowsSelected: function(selectedRows) { self._selectedRows = selectedRows; }, onRowsDeselected: function(deselectedRows) { self._deselectedRows = deselectedRows; } - }}).instance(); + } }).instance(); this.baseGrid = this.getBaseGrid(); this.selectRowCol = this.baseGrid.props.columnMetrics.columns[0]; @@ -385,19 +385,19 @@ describe('Grid', function() { const self = this; this._selectedRows = []; this._deselectedRows = []; - this.rows = [{id: '1'}, {id: '2'}]; - const columns = [{name: 'Id', key: 'id'}]; + this.rows = [{ id: '1' }, { id: '2' }]; + const columns = [{ name: 'Id', key: 'id' }]; const rowGetter = function(i) { return self.rows[i]; }; - this.component = this.createComponent({ enableRowSelect: true, rowsCount: this.rows.length, rowGetter: rowGetter, columns: columns, rowSelection: {selectBy: {indexes: [0, 1]}, + this.component = this.createComponent({ enableRowSelect: true, rowsCount: this.rows.length, rowGetter: rowGetter, columns: columns, rowSelection: { selectBy: { indexes: [0, 1] }, onRowsSelected: function(selectedRows) { self._selectedRows = selectedRows; }, onRowsDeselected: function(deselectedRows) { self._deselectedRows = deselectedRows; } - }}).instance(); + } }).instance(); this.baseGrid = this.getBaseGrid(); this.selectRowCol = this.baseGrid.props.columnMetrics.columns[0]; @@ -467,8 +467,8 @@ describe('Grid', function() { describe('onRowClick handler', function() { beforeEach(function() { const self = this; - this.rows = [{id: '1', isSelected: true}, {id: '2', isSelected: false}]; - const columns = [{name: 'Id', key: 'id'}, {name: 'Title', key: 'title', width: 100 }]; + this.rows = [{ id: '1', isSelected: true }, { id: '2', isSelected: false }]; + const columns = [{ name: 'Id', key: 'id' }, { name: 'Title', key: 'title', width: 100 }]; const rowGetter = function(i) { return self.rows[i]; }; @@ -476,14 +476,14 @@ describe('Grid', function() { this.rowClicked = {}; this.rowClicks = 0; - this.component = this.createComponent({rowsCount: this.rows.length, rowGetter: rowGetter, columns: columns, onRowClick: function(rowIdx, row, column) { - self.rowClicked = {row, column}; + this.component = this.createComponent({ rowsCount: this.rows.length, rowGetter: rowGetter, columns: columns, onRowClick: function(rowIdx, row, column) { + self.rowClicked = { row, column }; self.rowClicks++; - }}).instance(); + } }).instance(); }); it('calls handler when row (cell) clicked', function() { - this.getCellMetaData().onCellClick({ idx: 1, rowIdx: 1}); + this.getCellMetaData().onCellClick({ idx: 1, rowIdx: 1 }); expect(this.rowClicks).toBe(1); const { row, column } = this.rowClicked; expect(row).toEqual(jasmine.objectContaining(this.rows[1])); diff --git a/packages/react-data-grid-addons/src/cells/headerCells/filters/AutoCompleteFilter.js b/packages/react-data-grid-addons/src/cells/headerCells/filters/AutoCompleteFilter.js index c72f4478ca..6ac5db486e 100644 --- a/packages/react-data-grid-addons/src/cells/headerCells/filters/AutoCompleteFilter.js +++ b/packages/react-data-grid-addons/src/cells/headerCells/filters/AutoCompleteFilter.js @@ -2,7 +2,7 @@ import 'react-select/dist/react-select.css'; import React from 'react'; import PropTypes from 'prop-types'; import Select from 'react-select'; -import {isEmptyArray} from 'common/utils'; +import { isEmptyArray } from 'common/utils'; import Column from 'common/prop-shapes/Column'; class AutoCompleteFilter extends React.Component { @@ -11,11 +11,11 @@ class AutoCompleteFilter extends React.Component { this.getOptions = this.getOptions.bind(this); this.handleChange = this.handleChange.bind(this); this.filterValues = this.filterValues.bind(this); - this.state = {options: this.getOptions(), rawValue: '', placeholder: 'Search'}; + this.state = { options: this.getOptions(), rawValue: '', placeholder: 'Search' }; } componentWillReceiveProps(newProps) { - this.setState({options: this.getOptions(newProps)}); + this.setState({ options: this.getOptions(newProps) }); } getOptions(newProps) { @@ -58,8 +58,8 @@ class AutoCompleteFilter extends React.Component { handleChange(value) { const filters = value; - this.setState({filters}); - this.props.onChange({filterTerm: filters, column: this.props.column, rawValue: value, filterValues: this.filterValues }); + this.setState({ filters }); + this.props.onChange({ filterTerm: filters, column: this.props.column, rawValue: value, filterValues: this.filterValues }); } render() { diff --git a/packages/react-data-grid-addons/src/cells/headerCells/filters/NumericFilter.js b/packages/react-data-grid-addons/src/cells/headerCells/filters/NumericFilter.js index 6245234fd6..d00cb63f4c 100644 --- a/packages/react-data-grid-addons/src/cells/headerCells/filters/NumericFilter.js +++ b/packages/react-data-grid-addons/src/cells/headerCells/filters/NumericFilter.js @@ -105,7 +105,7 @@ class NumericFilter extends React.Component { handleChange(e) { const value = e.target.value; const filters = this.getRules(value); - this.props.onChange({filterTerm: (filters.length > 0 ? filters : null), column: this.props.column, rawValue: value, filterValues: this.filterValues }); + this.props.onChange({ filterTerm: (filters.length > 0 ? filters : null), column: this.props.column, rawValue: value, filterValues: this.filterValues }); } render() { diff --git a/packages/react-data-grid-addons/src/cells/headerCells/filters/__tests__/AutoCompleteFilter.spec.js b/packages/react-data-grid-addons/src/cells/headerCells/filters/__tests__/AutoCompleteFilter.spec.js index 802e2d5982..0cfb4c459d 100644 --- a/packages/react-data-grid-addons/src/cells/headerCells/filters/__tests__/AutoCompleteFilter.spec.js +++ b/packages/react-data-grid-addons/src/cells/headerCells/filters/__tests__/AutoCompleteFilter.spec.js @@ -74,77 +74,77 @@ describe('AutoCompleteFilter', () => { }); it('should filter valid values', () => { - const columnFilter = { filterTerm: [ {value: '1'} ] }; + const columnFilter = { filterTerm: [ { value: '1' } ] }; const request = filterValues(columnFilter); expect(request).toBeTruthy(); }); it('should handle invalid values', () => { - const columnFilter = { filterTerm: [ {value: '3'} ] }; + const columnFilter = { filterTerm: [ { value: '3' } ] }; const request = filterValues(columnFilter); expect(request).toBeFalsy(); }); it('should handle empty values', () => { - const columnFilter = { filterTerm: [ {value: ''} ] }; + const columnFilter = { filterTerm: [ { value: '' } ] }; const request = filterValues(columnFilter); expect(request).toBeFalsy(); }); it('should be a full match when filter match is the first word', () => { - const columnFilter = { filterTerm: [ {value: 'Title 1'} ] }; + const columnFilter = { filterTerm: [ { value: 'Title 1' } ] }; const request = filterValues(columnFilter); expect(request).toBeFalsy(); }); it('should transform Integers into string to compare', () => { - const columnFilter = { filterTerm: [ {value: 1} ] }; + const columnFilter = { filterTerm: [ { value: 1 } ] }; const request = filterValues(columnFilter); expect(request).toBeTruthy(); }); it('should transform Float into string to compare', () => { - const columnFilter = { filterTerm: [ {value: 1.1} ] }; + const columnFilter = { filterTerm: [ { value: 1.1 } ] }; const request = filterValues(columnFilter); expect(request).toBeFalsy(); }); it('should transform row values into string to compare data (returns true)', () => { rows = [{ id: 1, title: 0.15, count: 1 }]; - const columnFilter = { filterTerm: [ {value: '0.15'} ] }; + const columnFilter = { filterTerm: [ { value: '0.15' } ] }; const request = filterValues(columnFilter); expect(request).toBeTruthy(); }); it('should transform row values into string to compare data (returns false)', () => { rows = [{ id: 1, title: 0.15, count: 1 }]; - const columnFilter = { filterTerm: [ {value: '0.10'} ] }; + const columnFilter = { filterTerm: [ { value: '0.10' } ] }; const request = filterValues(columnFilter); expect(request).toBeFalsy(); }); it('should transform row and filter values into string to compare data', () => { rows = [{ id: 1, title: 0.15, count: 1 }]; - const columnFilter = { filterTerm: [ {value: 0.15} ] }; + const columnFilter = { filterTerm: [ { value: 0.15 } ] }; const request = filterValues(columnFilter); expect(request).toBeTruthy(); }); it('should trim spaces of the filterTerm values', () => { - const columnFilter = { filterTerm: [ {value: ' 1 '} ] }; + const columnFilter = { filterTerm: [ { value: ' 1 ' } ] }; const request = filterValues(columnFilter); expect(request).toBeTruthy(); }); it('should handle undefined row values', () => { rows = [{ id: 1, title: undefined, count: 1 }]; - const columnFilter = { filterTerm: [ {value: 1} ] }; + const columnFilter = { filterTerm: [ { value: 1 } ] }; const request = filterValues(columnFilter); expect(request).toBeFalsy(); }); it('should handle undefined filter values', () => { - const columnFilter = { filterTerm: [ {value: undefined} ] }; + const columnFilter = { filterTerm: [ { value: undefined } ] }; const request = filterValues(columnFilter); expect(request).toBeFalsy(); }); diff --git a/packages/react-data-grid-addons/src/data/RowFilterer.js b/packages/react-data-grid-addons/src/data/RowFilterer.js index e221b02664..cc9ed34343 100644 --- a/packages/react-data-grid-addons/src/data/RowFilterer.js +++ b/packages/react-data-grid-addons/src/data/RowFilterer.js @@ -1,4 +1,4 @@ -import {isImmutableCollection, getMixedTypeValueRetriever} from 'common/utils'; +import { isImmutableCollection, getMixedTypeValueRetriever } from 'common/utils'; const filterRows = (filters, rows = []) => { return rows.filter(r => { diff --git a/packages/react-data-grid-addons/src/data/RowGrouper.js b/packages/react-data-grid-addons/src/data/RowGrouper.js index efec9a2842..4f89bb8327 100644 --- a/packages/react-data-grid-addons/src/data/RowGrouper.js +++ b/packages/react-data-grid-addons/src/data/RowGrouper.js @@ -1,4 +1,4 @@ -import {isImmutableCollection} from 'common/utils'; +import { isImmutableCollection } from 'common/utils'; import Resolver from './RowGrouperResolver'; @@ -30,7 +30,7 @@ class RowGrouper { for (let i = 0; i < keys.length; i++) { const key = keys[i]; const isExpanded = this.isRowExpanded(columnName, key); - const rowGroupHeader = {name: key, __metaData: {isGroup: true, treeDepth: columnIndex, isExpanded: isExpanded, columnGroupName: columnName, columnGroupDisplayName}}; + const rowGroupHeader = { name: key, __metaData: { isGroup: true, treeDepth: columnIndex, isExpanded: isExpanded, columnGroupName: columnName, columnGroupDisplayName } }; dataviewRows = this.resolver.addHeaderRow(rowGroupHeader, dataviewRows); diff --git a/packages/react-data-grid-addons/src/data/RowGrouperResolver.js b/packages/react-data-grid-addons/src/data/RowGrouperResolver.js index ba6a606167..d49290be49 100644 --- a/packages/react-data-grid-addons/src/data/RowGrouperResolver.js +++ b/packages/react-data-grid-addons/src/data/RowGrouperResolver.js @@ -1,6 +1,6 @@ -import {List} from 'immutable'; +import { List } from 'immutable'; import groupBy from 'lodash/groupBy'; -import { isImmutableMap, getMixedTypeValueRetriever} from 'common/utils'; +import { isImmutableMap, getMixedTypeValueRetriever } from 'common/utils'; export default class RowGrouperResolver { diff --git a/packages/react-data-grid-addons/src/data/RowSorter.js b/packages/react-data-grid-addons/src/data/RowSorter.js index a9c9892419..67bf340e7f 100644 --- a/packages/react-data-grid-addons/src/data/RowSorter.js +++ b/packages/react-data-grid-addons/src/data/RowSorter.js @@ -1,4 +1,4 @@ -import {getMixedTypeValueRetriever, isImmutableCollection} from 'common/utils'; +import { getMixedTypeValueRetriever, isImmutableCollection } from 'common/utils'; export const comparer = (a, b) => { if (a > b) { diff --git a/packages/react-data-grid-addons/src/data/Selectors.js b/packages/react-data-grid-addons/src/data/Selectors.js index 1b4057e7dc..efce55e9b8 100644 --- a/packages/react-data-grid-addons/src/data/Selectors.js +++ b/packages/react-data-grid-addons/src/data/Selectors.js @@ -1,5 +1,5 @@ import { createSelector } from 'reselect'; -import {isEmptyObject, isEmptyArray} from 'common/utils'; +import { isEmptyObject, isEmptyArray } from 'common/utils'; import groupRows from './RowGrouper'; import filterRows from './RowFilterer'; import sortRows from './RowSorter'; diff --git a/packages/react-data-grid-addons/src/data/__tests__/RowFilterer.spec.js b/packages/react-data-grid-addons/src/data/__tests__/RowFilterer.spec.js index c62aaa9964..e84542623a 100644 --- a/packages/react-data-grid-addons/src/data/__tests__/RowFilterer.spec.js +++ b/packages/react-data-grid-addons/src/data/__tests__/RowFilterer.spec.js @@ -1,13 +1,13 @@ import React from 'react'; import filterRows from '../RowFilterer'; -import {fromJS} from 'immutable'; +import { fromJS } from 'immutable'; import AutoCompleteFilter from '../../cells/headerCells/filters/AutoCompleteFilter'; import TestUtils from 'react-dom/test-utils'; const rows = [{ colOne: 'v1', colTwo: 'b1' }, { colOne: 'v2', colTwo: 'b2' }, { colOne: 'v3', colTwo: 'b3' }]; -const filters = { colOne: { filterTerm: 'v1' }}; +const filters = { colOne: { filterTerm: 'v1' } }; const fakeColumn = { name: 'Col One', key: 'colOne', width: 100 }; @@ -16,9 +16,9 @@ const fakeGetValidFilterValues = () => { return []; }; const acFilter = TestUtils.renderIntoDocument(); -const acFilters = { colOne: { filterTerm: [{ value: 'v1' }, { value: 'v2' }], filterValues: acFilter.filterValues }}; +const acFilters = { colOne: { filterTerm: [{ value: 'v1' }, { value: 'v2' }], filterValues: acFilter.filterValues } }; -const acFilters2Column = { colOne: { filterTerm: [{ value: 'v1' }, { value: 'v2' }], filterValues: acFilter.filterValues }, colTwo: { filterTerm: [{ value: 'b2' }], filterValues: acFilter.filterValues }}; +const acFilters2Column = { colOne: { filterTerm: [{ value: 'v1' }, { value: 'v2' }], filterValues: acFilter.filterValues }, colTwo: { filterTerm: [{ value: 'b2' }], filterValues: acFilter.filterValues } }; describe('Row Filterer', () => { it('It can filter arrays of rows', () => { diff --git a/packages/react-data-grid-addons/src/data/__tests__/RowSorter.spec.js b/packages/react-data-grid-addons/src/data/__tests__/RowSorter.spec.js index e2a5be4a5d..618c693245 100644 --- a/packages/react-data-grid-addons/src/data/__tests__/RowSorter.spec.js +++ b/packages/react-data-grid-addons/src/data/__tests__/RowSorter.spec.js @@ -1,4 +1,4 @@ -import sortRows, {comparer} from '../RowSorter'; +import sortRows, { comparer } from '../RowSorter'; import Immutable from 'immutable'; describe('RowSorter', () => { diff --git a/packages/react-data-grid-addons/src/data/__tests__/Selectors.spec.js b/packages/react-data-grid-addons/src/data/__tests__/Selectors.spec.js index 73527bdd6d..623a452ea9 100644 --- a/packages/react-data-grid-addons/src/data/__tests__/Selectors.spec.js +++ b/packages/react-data-grid-addons/src/data/__tests__/Selectors.spec.js @@ -71,7 +71,7 @@ function executeSpyTests(fn) { }); describe('When groupBy is defined as an array of objects', () => { - const options = { groupBy: [{key: 'title', name: 'Title'}] }; + const options = { groupBy: [{ key: 'title', name: 'Title' }] }; it('should call groupBy only once', () => { const expectedComputations = fn(options); @@ -224,7 +224,7 @@ describe('Grid Selectors', () => { }); it('can group by a single column when groupBy is an object array', () => { - const groupBy = [{key: 'title', name: 'title'}]; + const groupBy = [{ key: 'title', name: 'title' }]; const computedRows = Selectors.getRows({ rows, groupBy }); expect(computedRows.length).toBe(6); expect(computedRows[0].__metaData).toEqual(jasmine.objectContaining({ columnGroupName: 'title', isExpanded: true, isGroup: true, treeDepth: 0 })); @@ -237,7 +237,7 @@ describe('Grid Selectors', () => { }); it('can group by multiple columns when groupBy is an object array', () => { - const groupBy = [{key: 'title', name: 'title'}, {key: 'count', name: 'count'}, {key: 'id', name: 'id'}]; + const groupBy = [{ key: 'title', name: 'title' }, { key: 'count', name: 'count' }, { key: 'id', name: 'id' }]; const computedRows = Selectors.getRows({ rows, groupBy }); expect(computedRows.length).toBe(12); expect(computedRows[0].__metaData).toEqual(jasmine.objectContaining({ columnGroupName: 'title', isExpanded: true, isGroup: true, treeDepth: 0 })); @@ -248,7 +248,7 @@ describe('Grid Selectors', () => { it('can filter and then group by column when groupBy is an object array', () => { const filters = { title: { filterTerm: '1' } }; - const groupBy = [{key: 'title', name: 'title'}]; + const groupBy = [{ key: 'title', name: 'title' }]; const computedRows = Selectors.getRows({ rows, filters, groupBy }); expect(computedRows.length).toBe(2); expect(computedRows[0].__metaData).toEqual(jasmine.objectContaining({ columnGroupName: 'title', isExpanded: true, isGroup: true, treeDepth: 0 })); diff --git a/packages/react-data-grid-addons/src/data/index.js b/packages/react-data-grid-addons/src/data/index.js index 13059af53d..5a96d03635 100644 --- a/packages/react-data-grid-addons/src/data/index.js +++ b/packages/react-data-grid-addons/src/data/index.js @@ -1,3 +1,3 @@ import Selectors from './Selectors'; -export {Selectors}; +export { Selectors }; diff --git a/packages/react-data-grid-addons/src/draggable/DropTargetRowContainer.js b/packages/react-data-grid-addons/src/draggable/DropTargetRowContainer.js index dd800769fc..3e0f9d4eec 100644 --- a/packages/react-data-grid-addons/src/draggable/DropTargetRowContainer.js +++ b/packages/react-data-grid-addons/src/draggable/DropTargetRowContainer.js @@ -15,7 +15,7 @@ const rowDropTarget = (Row) => class extends React.Component { } render() { - const { connectDropTarget, isOver, canDrop} = this.props; + const { connectDropTarget, isOver, canDrop } = this.props; const overlayTop = this.props.idx * this.props.height; return connectDropTarget(
this.row = node} {...this.props}/> @@ -46,4 +46,4 @@ function collect(connect, monitor) { }; } -export default (Row) => DropTarget('Row', target, collect, {arePropsEqual: (nextProps, currentProps) => !rowComparer(nextProps, currentProps)})(rowDropTarget(Row)); +export default (Row) => DropTarget('Row', target, collect, { arePropsEqual: (nextProps, currentProps) => !rowComparer(nextProps, currentProps) })(rowDropTarget(Row)); diff --git a/packages/react-data-grid-addons/src/draggable/RowActionsCell.js b/packages/react-data-grid-addons/src/draggable/RowActionsCell.js index eded01231d..78df66e296 100644 --- a/packages/react-data-grid-addons/src/draggable/RowActionsCell.js +++ b/packages/react-data-grid-addons/src/draggable/RowActionsCell.js @@ -13,8 +13,8 @@ class RowActionsCell extends React.Component { } render() { - const {connectDragSource, rowSelection} = this.props; - const rowHandleStyle = rowSelection != null ? {position: 'absolute', marginTop: '5px'} : {}; + const { connectDragSource, rowSelection } = this.props; + const rowHandleStyle = rowSelection != null ? { position: 'absolute', marginTop: '5px' } : {}; const isSelected = this.props.value; const editorClass = isSelected ? 'rdg-actions-checkbox selected' : 'rdg-actions-checkbox'; diff --git a/packages/react-data-grid-addons/src/draggable/RowDragLayer.js b/packages/react-data-grid-addons/src/draggable/RowDragLayer.js index 888f4d22c4..b950214cb5 100644 --- a/packages/react-data-grid-addons/src/draggable/RowDragLayer.js +++ b/packages/react-data-grid-addons/src/draggable/RowDragLayer.js @@ -1,4 +1,4 @@ -import React, { Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { DragLayer } from 'react-dnd'; import Selectors from '../data/Selectors'; @@ -35,7 +35,7 @@ function getItemStyles(props) { class CustomDragLayer extends Component { isDraggedRowSelected(selectedRows) { - const {item, rowSelection} = this.props; + const { item, rowSelection } = this.props; if (selectedRows && selectedRows.length > 0) { const key = rowSelection.selectBy.keys.rowKey; return selectedRows.filter(r => r[key] === item.data[key]).length > 0; @@ -45,11 +45,11 @@ class CustomDragLayer extends Component { getDraggedRows() { let draggedRows; - const {rowSelection} = this.props; + const { rowSelection } = this.props; if (rowSelection && rowSelection.selectBy.keys) { const rows = this.props.rows; - const {rowKey, values} = rowSelection.selectBy.keys; - const selectedRows = Selectors.getSelectedRowsByKey({rowKey: rowKey, selectedKeys: values, rows: rows}); + const { rowKey, values } = rowSelection.selectBy.keys; + const selectedRows = Selectors.getSelectedRowsByKey({ rowKey: rowKey, selectedKeys: values, rows: rows }); draggedRows = this.isDraggedRowSelected(selectedRows) ? selectedRows : [this.props.rows[this.props.item.idx]]; } else { draggedRows = [this.props.rows[this.props.item.idx]]; @@ -72,9 +72,9 @@ class CustomDragLayer extends Component { if (c.formatter) { const Formatter = c.formatter; const dependentValues = typeof c.getRowMetaData === 'function' ? c.getRowMetaData(item, c) : {}; - cells.push(); + cells.push(); } else { - cells.push({item[c.key]}); + cells.push({item[c.key]}); } } }); @@ -83,7 +83,7 @@ class CustomDragLayer extends Component { } render() { - const { isDragging} = this.props; + const { isDragging } = this.props; if (!isDragging) { return null; } diff --git a/packages/react-data-grid-addons/src/draggable/__tests__/DropTargetRowContainer.spec.js b/packages/react-data-grid-addons/src/draggable/__tests__/DropTargetRowContainer.spec.js index 149c221748..b6219f5a74 100644 --- a/packages/react-data-grid-addons/src/draggable/__tests__/DropTargetRowContainer.spec.js +++ b/packages/react-data-grid-addons/src/draggable/__tests__/DropTargetRowContainer.spec.js @@ -1,9 +1,9 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import { mount } from 'enzyme'; import TestBackend from 'react-dnd-test-backend'; -import {DragDropContext} from 'react-dnd'; +import { DragDropContext } from 'react-dnd'; import dropTargetRowContainer from '../DropTargetRowContainer'; -import {DragTestSource} from './TestDragSources'; +import { DragTestSource } from './TestDragSources'; import { _helpers } from 'react-data-grid'; const { test: { GridPropHelpers } } = _helpers; @@ -33,7 +33,7 @@ describe('', () => { const props = { onRowDrop: jasmine.createSpy(), idx: 1, - row: {id: 5, country: 'England'}, + row: { id: 5, country: 'England' }, columns: GridPropHelpers.columns, cellMetaData: GridPropHelpers.cellMetaData }; @@ -53,7 +53,7 @@ describe('', () => { it('should call onRowDrop with correct parameters when source is dropped', () => { const rowTargetKey = Object.keys(registry.handlers).filter(k => registry.handlers[k].monitor && registry.handlers[k].monitor.targetId)[0]; const rowTargetId = registry.handlers[rowTargetKey].monitor.targetId; - const draggedRowItem = { idx: 3, data: { id: 11, country: 'Ireland', county: 'Wicklow' }}; + const draggedRowItem = { idx: 3, data: { id: 11, country: 'Ireland', county: 'Wicklow' } }; const sourceId = registry.addSource('Row', new DragTestSource(draggedRowItem)); backend.simulateBeginDrag([sourceId]); backend.simulateHover([rowTargetId]); diff --git a/packages/react-data-grid-addons/src/editors/AutoCompleteEditor.js b/packages/react-data-grid-addons/src/editors/AutoCompleteEditor.js index fb6591bdca..5209b7b493 100644 --- a/packages/react-data-grid-addons/src/editors/AutoCompleteEditor.js +++ b/packages/react-data-grid-addons/src/editors/AutoCompleteEditor.js @@ -51,7 +51,7 @@ class AutoCompleteEditor extends React.Component { }; getEditorDisplayValue = () => { - const displayValue = {title: ''}; + const displayValue = { title: '' }; const { column, value, editorDisplayValue } = this.props; if (editorDisplayValue && typeof editorDisplayValue === 'function') { displayValue.title = editorDisplayValue(column, value); diff --git a/packages/react-data-grid-addons/src/editors/AutoCompleteTokensEditor.js b/packages/react-data-grid-addons/src/editors/AutoCompleteTokensEditor.js index 8d0e2b7320..26b6108550 100644 --- a/packages/react-data-grid-addons/src/editors/AutoCompleteTokensEditor.js +++ b/packages/react-data-grid-addons/src/editors/AutoCompleteTokensEditor.js @@ -1,4 +1,4 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Select from 'react-select'; import ReactDOM from 'react-dom'; @@ -38,16 +38,16 @@ class AutoCompleteTokensEditor extends Component { } handleSelectChange(value) { - this.setState({value}); + this.setState({ value }); } render() { const options = []; this.props.options.forEach(function(name) { if (typeof (name) === 'string') { - options.push({label: name, value: name}); + options.push({ label: name, value: name }); } else { - options.push({label: name.caption, value: name.id}); + options.push({ label: name.caption, value: name.id }); } }); return ( diff --git a/packages/react-data-grid-addons/src/editors/DateRangeEditor.js b/packages/react-data-grid-addons/src/editors/DateRangeEditor.js index 790868af53..d1cdedf13d 100644 --- a/packages/react-data-grid-addons/src/editors/DateRangeEditor.js +++ b/packages/react-data-grid-addons/src/editors/DateRangeEditor.js @@ -34,7 +34,7 @@ class DateRangeEditor extends React.Component { }; handleDateFilterApply = (startDate, endDate) => { - this.commit({value: {startDate: startDate, endDate: endDate}}); + this.commit({ value: { startDate: startDate, endDate: endDate } }); }; render() { diff --git a/packages/react-data-grid-addons/src/editors/__tests__/AutoCompleteEditor-integration.spec.js b/packages/react-data-grid-addons/src/editors/__tests__/AutoCompleteEditor-integration.spec.js index d68810b999..f443b6097c 100644 --- a/packages/react-data-grid-addons/src/editors/__tests__/AutoCompleteEditor-integration.spec.js +++ b/packages/react-data-grid-addons/src/editors/__tests__/AutoCompleteEditor-integration.spec.js @@ -6,7 +6,7 @@ const AutoCompleteEditor = require('../AutoCompleteEditor'); describe('AutoCompleteEditor integration', () => { let component; function fakeCb() { return true; } - const fakeOptions = [{id: 1, title: 'test-result1'}, {id: 2, title: 'test-result2'}]; + const fakeOptions = [{ id: 1, title: 'test-result1' }, { id: 2, title: 'test-result2' }]; const fakeParams = ['param1', 'param2', 'param3']; const fakeColumn = { key: 'autocomplete', name: 'name', width: 0 }; const commitSpy = jasmine.createSpy(); diff --git a/packages/react-data-grid-addons/src/editors/__tests__/AutoCompleteEditor.spec.js b/packages/react-data-grid-addons/src/editors/__tests__/AutoCompleteEditor.spec.js index 69ca66c3a6..9bfdb05e82 100644 --- a/packages/react-data-grid-addons/src/editors/__tests__/AutoCompleteEditor.spec.js +++ b/packages/react-data-grid-addons/src/editors/__tests__/AutoCompleteEditor.spec.js @@ -1,13 +1,13 @@ import React from 'react'; -import {shallow} from 'enzyme'; +import { shallow } from 'enzyme'; import AutoCompleteEditor from '../AutoCompleteEditor'; import ReactAutocomplete from 'ron-react-autocomplete'; describe('AutoCompleteEditor', () => { function fakeCb() { return true; } - const fakeOptions = [{id: 1, title: 'test-result1'}, {id: 2, title: 'test-result2'}]; + const fakeOptions = [{ id: 1, title: 'test-result1' }, { id: 2, title: 'test-result2' }]; const fakeParams = ['param1', 'param2', 'param3']; const fakeColumn = { key: 'autocomplete', name: 'name', width: 0 }; @@ -26,43 +26,43 @@ describe('AutoCompleteEditor', () => { height={30} onKeyDown={fakeCb}/>); const autocomplete = wrapper.find(ReactAutocomplete); - return {wrapper, autocomplete}; + return { wrapper, autocomplete }; } it('should pass the search text to ReactAutocomplete as a prop', () => { - const {autocomplete} = setup(); + const { autocomplete } = setup(); expect(autocomplete.props().search).toBe('test'); }); it('should pass the label to ReactAutocomplete as a prop', () => { - const {autocomplete} = setup(); + const { autocomplete } = setup(); expect(autocomplete.props().label).toBe('title'); }); it('should pass the resultIdentifier to ReactAutocomplete as a prop', () => { - const {autocomplete} = setup(); + const { autocomplete } = setup(); expect(autocomplete.props().resultIdentifier).toBe('id'); }); it('should pass the options to ReachAutocomplete as a prop', () => { - const {autocomplete} = setup(); + const { autocomplete } = setup(); expect(autocomplete.props().options).toBe(fakeOptions); }); it('should pass the value to ReachAutocomplete as a prop', () => { - const {autocomplete} = setup(); + const { autocomplete } = setup(); expect(autocomplete.props().value.title).toBe('value'); }); it('should construct values from the parameters', () => { - const {wrapper} = setup(); - const constructedValues = wrapper.instance().constuctValueFromParams({param1: 'value1', param2: 'value2'}, fakeParams); + const { wrapper } = setup(); + const constructedValues = wrapper.instance().constuctValueFromParams({ param1: 'value1', param2: 'value2' }, fakeParams); expect(constructedValues).toBe('value1|value2|'); }); it('should return the value for getLabel if item is a string', () => { - const {wrapper} = setup(); - const value = wrapper.instance().getLabel({title: 'autocomplete'}); + const { wrapper } = setup(); + const value = wrapper.instance().getLabel({ title: 'autocomplete' }); expect(value).toBe('autocomplete'); }); }); diff --git a/packages/react-data-grid-addons/src/editors/__tests__/ContainerEditorWrapper.spec.js b/packages/react-data-grid-addons/src/editors/__tests__/ContainerEditorWrapper.spec.js index 7637a7a2b6..04cd66fc42 100644 --- a/packages/react-data-grid-addons/src/editors/__tests__/ContainerEditorWrapper.spec.js +++ b/packages/react-data-grid-addons/src/editors/__tests__/ContainerEditorWrapper.spec.js @@ -1,4 +1,4 @@ -import { mount} from 'enzyme'; +import { mount } from 'enzyme'; import React from 'react'; import PropTypes from 'prop-types'; diff --git a/packages/react-data-grid-addons/src/editors/widgets/DateRangeFilter.js b/packages/react-data-grid-addons/src/editors/widgets/DateRangeFilter.js index e5c401e718..0b7aca904f 100644 --- a/packages/react-data-grid-addons/src/editors/widgets/DateRangeFilter.js +++ b/packages/react-data-grid-addons/src/editors/widgets/DateRangeFilter.js @@ -1149,12 +1149,12 @@ class DateRangeFilter extends React.Component { endDate: validateDate }; - state = {dateRange: ''}; + state = { dateRange: '' }; componentDidMount() { // initialise jQuery date range widget - const $calendarNode = $(ReactDOM.findDOMNode(this.refs.calendar)); - const $calendar = $calendarNode.daterangepicker({ranges: this.props.ranges, format: this.props.format, opens: 'left', locale: { cancelLabel: 'Clear' }, applyClass: 'btn-primary' }); + const $calendar = $calendarNode.daterangepicker({ ranges: this.props.ranges, format: this.props.format, opens: 'left', locale: { cancelLabel: 'Clear' }, applyClass: 'btn-primary' }); this.calendar = $calendar.data('daterangepicker'); if (this.props.startDate) { this.calendar.setStartDate(this.props.startDate); @@ -1177,11 +1177,11 @@ class DateRangeFilter extends React.Component { this.props.onApply(picker.startDate, picker.endDate); } - this.setState({dateRange: picker.startDate.format(picker.format) + ' - ' + picker.endDate.format(picker.format)}); + this.setState({ dateRange: picker.startDate.format(picker.format) + ' - ' + picker.endDate.format(picker.format) }); }; handleClear = () => { - this.setState({dateRange: ''}); + this.setState({ dateRange: '' }); if (this.props.onApply) { // return moment instances for start and end date ranges this.props.onApply(null, null); diff --git a/packages/react-data-grid-addons/src/formatters/DateRangeFormatter.js b/packages/react-data-grid-addons/src/formatters/DateRangeFormatter.js index 57d6bcc1cc..0659591f32 100644 --- a/packages/react-data-grid-addons/src/formatters/DateRangeFormatter.js +++ b/packages/react-data-grid-addons/src/formatters/DateRangeFormatter.js @@ -16,7 +16,7 @@ class DateRangeFormatter extends React.Component { static defaultProps = { inputFormat: 'YYYY-MM-DD', displayFormat: 'YYYY-MM-DD', - value: {startDate: null, endDate: null} + value: { startDate: null, endDate: null } }; formatDate = (date) => { diff --git a/packages/react-data-grid-addons/src/index.js b/packages/react-data-grid-addons/src/index.js index 6b2b0634d0..6af69f5a15 100644 --- a/packages/react-data-grid-addons/src/index.js +++ b/packages/react-data-grid-addons/src/index.js @@ -11,5 +11,5 @@ import rowComparer from 'common/utils/RowComparer'; const performance = require('./performance'); const Utils = { rowComparer, performance }; -window.ReactDataGridPlugins = {Editors, Formatters, Toolbar, Menu, Data, ToolsPanel, Draggable, DraggableHeader, Filters, Utils}; -module.exports = {Editors, Formatters, Toolbar, Menu, Data, ToolsPanel, Draggable, DraggableHeader, Filters, Utils}; +window.ReactDataGridPlugins = { Editors, Formatters, Toolbar, Menu, Data, ToolsPanel, Draggable, DraggableHeader, Filters, Utils }; +module.exports = { Editors, Formatters, Toolbar, Menu, Data, ToolsPanel, Draggable, DraggableHeader, Filters, Utils }; diff --git a/packages/react-data-grid-addons/src/menu/ContextMenu.js b/packages/react-data-grid-addons/src/menu/ContextMenu.js index 4fd478bceb..622520677c 100644 --- a/packages/react-data-grid-addons/src/menu/ContextMenu.js +++ b/packages/react-data-grid-addons/src/menu/ContextMenu.js @@ -1,20 +1,20 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import {ContextMenu} from 'react-contextmenu'; - -class ReactDataGridContextMenu extends React.Component { - render() { - return ( - - {this.props.children} - - ); - } -} - -ReactDataGridContextMenu.propTypes = { - children: PropTypes.node -}; - -export default ReactDataGridContextMenu; +import React from 'react'; +import PropTypes from 'prop-types'; + +import { ContextMenu } from 'react-contextmenu'; + +class ReactDataGridContextMenu extends React.Component { + render() { + return ( + + {this.props.children} + + ); + } +} + +ReactDataGridContextMenu.propTypes = { + children: PropTypes.node +}; + +export default ReactDataGridContextMenu; diff --git a/packages/react-data-grid-addons/src/menu/__tests__/ContextMenu.spec.js b/packages/react-data-grid-addons/src/menu/__tests__/ContextMenu.spec.js index c8a34cb8f4..3a3f962500 100644 --- a/packages/react-data-grid-addons/src/menu/__tests__/ContextMenu.spec.js +++ b/packages/react-data-grid-addons/src/menu/__tests__/ContextMenu.spec.js @@ -1,7 +1,7 @@ import React from 'react'; import TestUtils from 'react-dom/test-utils'; import ReactDataGridContextMenu from '../ContextMenu'; -import {ContextMenu} from 'react-contextmenu'; +import { ContextMenu } from 'react-contextmenu'; describe('Context Menu', () => { let component = {}; diff --git a/packages/react-data-grid-addons/src/menu/index.js b/packages/react-data-grid-addons/src/menu/index.js index e131c20bd3..97b8326122 100644 --- a/packages/react-data-grid-addons/src/menu/index.js +++ b/packages/react-data-grid-addons/src/menu/index.js @@ -1,4 +1,4 @@ -import {ContextMenu, MenuItem, monitor, SubMenu, connect, ContextMenuTrigger} from 'react-contextmenu'; +import { ContextMenu, MenuItem, monitor, SubMenu, connect, ContextMenuTrigger } from 'react-contextmenu'; import MenuHeader from './MenuHeader'; -export {ContextMenu, MenuHeader, MenuItem, monitor, SubMenu, connect, ContextMenuTrigger}; +export { ContextMenu, MenuHeader, MenuItem, monitor, SubMenu, connect, ContextMenuTrigger }; diff --git a/packages/react-data-grid-addons/src/toolbars/AdvancedToolbar.js b/packages/react-data-grid-addons/src/toolbars/AdvancedToolbar.js index 537e38f812..545acd419c 100644 --- a/packages/react-data-grid-addons/src/toolbars/AdvancedToolbar.js +++ b/packages/react-data-grid-addons/src/toolbars/AdvancedToolbar.js @@ -1,29 +1,29 @@ -import React, {Component} from 'react'; -import PropTypes from 'prop-types'; - -import '../../../../themes/react-data-grid-toolbar.css'; - -const propTypes = { - children: PropTypes.array -}; - -const defaultProps = { - enableAddRow: true -}; - -class AdvancedToolbar extends Component { - render() { - return ( -
- {this.props.children} -
- -
-
); - } -} - -AdvancedToolbar.defaultProps = defaultProps; -AdvancedToolbar.propTypes = propTypes; - -export default AdvancedToolbar; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; + +import '../../../../themes/react-data-grid-toolbar.css'; + +const propTypes = { + children: PropTypes.array +}; + +const defaultProps = { + enableAddRow: true +}; + +class AdvancedToolbar extends Component { + render() { + return ( +
+ {this.props.children} +
+ +
+
); + } +} + +AdvancedToolbar.defaultProps = defaultProps; +AdvancedToolbar.propTypes = propTypes; + +export default AdvancedToolbar; diff --git a/packages/react-data-grid-addons/src/toolbars/GroupedColumnButton.js b/packages/react-data-grid-addons/src/toolbars/GroupedColumnButton.js index 1d87a14d36..e186789728 100644 --- a/packages/react-data-grid-addons/src/toolbars/GroupedColumnButton.js +++ b/packages/react-data-grid-addons/src/toolbars/GroupedColumnButton.js @@ -1,4 +1,4 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; export default class GroupedColumnButton extends Component { diff --git a/packages/react-data-grid-addons/src/toolbars/GroupedColumnsPanel.js b/packages/react-data-grid-addons/src/toolbars/GroupedColumnsPanel.js index f40c432438..161b3851ed 100644 --- a/packages/react-data-grid-addons/src/toolbars/GroupedColumnsPanel.js +++ b/packages/react-data-grid-addons/src/toolbars/GroupedColumnsPanel.js @@ -1,4 +1,4 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { DropTarget } from 'react-dnd'; @@ -22,7 +22,7 @@ const defaultProps = { class GroupedColumnsPanel extends Component { getPanelInstructionMessage() { - const {groupBy} = this.props; + const { groupBy } = this.props; return groupBy && groupBy.length > 0 ? this.props.panelDescription : this.props.noColumnsSelectedMessage; } @@ -54,7 +54,7 @@ class GroupedColumnsPanel extends Component { } render() { - const { connectDropTarget, isOver, canDrop} = this.props; + const { connectDropTarget, isOver, canDrop } = this.props; return connectDropTarget(
{this.renderGroupedColumns()} {this.getPanelInstructionMessage()} diff --git a/packages/react-data-grid-addons/src/toolbars/Toolbar.js b/packages/react-data-grid-addons/src/toolbars/Toolbar.js index 41daf30659..9bfa5f2324 100644 --- a/packages/react-data-grid-addons/src/toolbars/Toolbar.js +++ b/packages/react-data-grid-addons/src/toolbars/Toolbar.js @@ -21,7 +21,7 @@ class Toolbar extends React.Component { onAddRow = () => { if (this.props.onAddRow !== null && this.props.onAddRow instanceof Function) { - this.props.onAddRow({newRowIndex: this.props.numberOfRows}); + this.props.onAddRow({ newRowIndex: this.props.numberOfRows }); } }; diff --git a/packages/react-data-grid-addons/src/toolbars/index.js b/packages/react-data-grid-addons/src/toolbars/index.js index 758fb05ead..64029bf79f 100644 --- a/packages/react-data-grid-addons/src/toolbars/index.js +++ b/packages/react-data-grid-addons/src/toolbars/index.js @@ -1,4 +1,4 @@ import AdvancedToolbar from './AdvancedToolbar'; import GroupedColumnsPanel from './GroupedColumnsPanel'; -module.exports = {AdvancedToolbar, GroupedColumnsPanel}; +module.exports = { AdvancedToolbar, GroupedColumnsPanel }; diff --git a/packages/react-data-grid/src/Cell.js b/packages/react-data-grid/src/Cell.js index a5c7df97b0..c2d23dbd3f 100644 --- a/packages/react-data-grid/src/Cell.js +++ b/packages/react-data-grid/src/Cell.js @@ -1,13 +1,13 @@ import React from 'react'; import PropTypes from 'prop-types'; import joinClasses from 'classnames'; -import {isFunction} from 'common/utils'; +import { isFunction } from 'common/utils'; import SimpleCellFormatter from './formatters/SimpleCellFormatter'; import createObjectWithProperties from './createObjectWithProperties'; import CellAction from './CellAction'; import CellExpand from './CellExpander'; import ChildRowDeleteButton from './ChildRowDeleteButton'; -import {isFrozen} from './ColumnUtils'; +import { isFrozen } from './ColumnUtils'; require('../../../themes/react-data-grid-cell.css'); // The list of the propTypes that we want to include in the Cell div @@ -161,7 +161,7 @@ class Cell extends React.PureComponent { }; getCellClass = () => { - const {idx, lastFrozenColumnIndex} = this.props; + const { idx, lastFrozenColumnIndex } = this.props; const className = joinClasses( this.props.column.cellClass, 'react-grid-Cell', @@ -190,7 +190,7 @@ class Cell extends React.PureComponent { }; checkScroll() { - const {scrollLeft, column} = this.props; + const { scrollLeft, column } = this.props; const node = this.node; if (isFrozen(column) && node && node.style.transform != null) { this.setScrollLeft(scrollLeft); @@ -276,7 +276,7 @@ class Cell extends React.PureComponent { }; getCellActions() { - const {cellMetaData, column, rowData} = this.props; + const { cellMetaData, column, rowData } = this.props; if (cellMetaData && cellMetaData.getCellActions) { const cellActionButtons = cellMetaData.getCellActions(column, rowData); if (cellActionButtons && cellActionButtons.length) { @@ -298,7 +298,7 @@ class Cell extends React.PureComponent { let CellContent; const Formatter = this.getFormatter(); if (React.isValidElement(Formatter)) { - CellContent = React.cloneElement(Formatter, {...props, dependentValues: this.getFormatterDependencies(), row: this.getRowData()}); + CellContent = React.cloneElement(Formatter, { ...props, dependentValues: this.getFormatterDependencies(), row: this.getRowData() }); } else if (isFunction(Formatter)) { CellContent = ; } else { @@ -336,7 +336,7 @@ class Cell extends React.PureComponent { const className = this.getCellClass(); const cellActionButtons = this.getCellActions(); - const {value, column, rowIdx, isExpanded, isScrolling} = this.props; + const { value, column, rowIdx, isExpanded, isScrolling } = this.props; const cellContent = this.props.children || this.renderCellContent({ value, column, diff --git a/packages/react-data-grid/src/CellAction.js b/packages/react-data-grid/src/CellAction.js index d05453227b..1f56b7c68c 100644 --- a/packages/react-data-grid/src/CellAction.js +++ b/packages/react-data-grid/src/CellAction.js @@ -18,7 +18,7 @@ class CellAction extends React.Component { } onHideMenu = () => { - this.setState({isMenuOpen: false}); + this.setState({ isMenuOpen: false }); } onGetMenuOptions = () => { diff --git a/packages/react-data-grid/src/CellExpander.js b/packages/react-data-grid/src/CellExpander.js index 7e9a7cded4..edf6a6de04 100644 --- a/packages/react-data-grid/src/CellExpander.js +++ b/packages/react-data-grid/src/CellExpander.js @@ -17,7 +17,7 @@ class CellExpander extends React.Component { componentWillReceiveProps(nextProps) { const expanded = nextProps.expandableOptions && nextProps.expandableOptions.expanded; if (this.state.expanded !== expanded) { - this.setState({expanded}); + this.setState({ expanded }); } } diff --git a/packages/react-data-grid/src/ChildRowDeleteButton.js b/packages/react-data-grid/src/ChildRowDeleteButton.js index 31a8b86152..17ac1ef84c 100644 --- a/packages/react-data-grid/src/ChildRowDeleteButton.js +++ b/packages/react-data-grid/src/ChildRowDeleteButton.js @@ -1,7 +1,7 @@ import React from 'react'; import classNames from 'classnames'; -const ChildRowDeleteButton = ({treeDepth, cellHeight, siblingIndex, numberSiblings, onDeleteSubRow, isDeleteSubRowEnabled, allowAddChildRow = true }) => { +const ChildRowDeleteButton = ({ treeDepth, cellHeight, siblingIndex, numberSiblings, onDeleteSubRow, isDeleteSubRowEnabled, allowAddChildRow = true }) => { const lastSibling = siblingIndex === numberSiblings - 1; const className = classNames( { 'rdg-child-row-action-cross': allowAddChildRow === true || !lastSibling }, diff --git a/packages/react-data-grid/src/ColumnMetrics.js b/packages/react-data-grid/src/ColumnMetrics.js index 94258f48f1..5db6ebbd01 100644 --- a/packages/react-data-grid/src/ColumnMetrics.js +++ b/packages/react-data-grid/src/ColumnMetrics.js @@ -1,8 +1,8 @@ import shallowCloneObject from './shallowCloneObject'; import sameColumn from './ColumnComparer'; -import {getSize, getColumn, isFrozen, spliceColumn} from './ColumnUtils'; +import { getSize, getColumn, isFrozen, spliceColumn } from './ColumnUtils'; import getScrollbarSize from './getScrollbarSize'; -import {isColumnsImmutable} from 'common/utils'; +import { isColumnsImmutable } from 'common/utils'; function setColumnWidths(columns, totalWidth) { return columns.map(column => { diff --git a/packages/react-data-grid/src/Draggable.js b/packages/react-data-grid/src/Draggable.js index dacf48a995..daf7d7e8f2 100644 --- a/packages/react-data-grid/src/Draggable.js +++ b/packages/react-data-grid/src/Draggable.js @@ -44,7 +44,7 @@ class Draggable extends React.Component { window.addEventListener('touchend', this.onMouseUp); window.addEventListener('touchmove', this.onMouseMove); - this.setState({drag}); + this.setState({ drag }); }; onMouseMove = (e) => { @@ -62,7 +62,7 @@ class Draggable extends React.Component { onMouseUp = (e) => { this.cleanUp(); this.props.onDragEnd(e, this.state.drag); - this.setState({drag: null}); + this.setState({ drag: null }); }; cleanUp = () => { diff --git a/packages/react-data-grid/src/Grid.js b/packages/react-data-grid/src/Grid.js index 5648eb4187..e6d8499e97 100644 --- a/packages/react-data-grid/src/Grid.js +++ b/packages/react-data-grid/src/Grid.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import Header from './Header'; import Viewport from './Viewport'; import cellMetaDataShape from 'common/prop-shapes/CellMetaDataShape'; -import {isFrozen} from './ColumnUtils'; +import { isFrozen } from './ColumnUtils'; require('../../../themes/react-data-grid-core.css'); class Grid extends React.Component { @@ -105,7 +105,7 @@ class Grid extends React.Component { onScroll = (scrollState) => { this.props.onScroll(scrollState); - const {scrollLeft} = scrollState; + const { scrollLeft } = scrollState; if (this._scrollLeft !== scrollLeft || this.areFrozenColumnsScrolledLeft(scrollLeft)) { this._scrollLeft = scrollLeft; this._onScroll(); diff --git a/packages/react-data-grid/src/Header.js b/packages/react-data-grid/src/Header.js index 09fe3f6dd6..584a1f72eb 100644 --- a/packages/react-data-grid/src/Header.js +++ b/packages/react-data-grid/src/Header.js @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'; import joinClasses from 'classnames'; import shallowCloneObject from './shallowCloneObject'; import ColumnMetrics from './ColumnMetrics'; -import {getColumn} from './ColumnUtils'; +import { getColumn } from './ColumnUtils'; import HeaderRow from './HeaderRow'; import getScrollbarSize from './getScrollbarSize'; import PropTypes from 'prop-types'; @@ -33,10 +33,10 @@ class Header extends React.Component { cellMetaData: PropTypes.shape(cellMetaDataShape) }; - state = {resizing: null}; + state = { resizing: null }; componentWillReceiveProps() { - this.setState({resizing: null}); + this.setState({ resizing: null }); } shouldComponentUpdate(nextProps, nextState) { @@ -67,7 +67,7 @@ class Header extends React.Component { } resizing.column = getColumn(resizing.columnMetrics.columns, pos); - this.setState({resizing}); + this.setState({ resizing }); } }; @@ -189,7 +189,7 @@ class Header extends React.Component { // Set the cell selection to -1 x -1 when clicking on the header onHeaderClick = () => { - this.props.cellMetaData.onCellClick({rowIdx: -1, idx: -1 }); + this.props.cellMetaData.onCellClick({ rowIdx: -1, idx: -1 }); }; render() { diff --git a/packages/react-data-grid/src/HeaderCell.js b/packages/react-data-grid/src/HeaderCell.js index 3e23deccfb..64f901be84 100644 --- a/packages/react-data-grid/src/HeaderCell.js +++ b/packages/react-data-grid/src/HeaderCell.js @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import Column from 'common/prop-shapes/Column'; -import {isFrozen} from './ColumnUtils'; +import { isFrozen } from './ColumnUtils'; import { HeaderRowType } from 'common/constants'; const ResizeHandle = require('./ResizeHandle'); @@ -31,10 +31,10 @@ class HeaderCell extends React.Component { renderer: SimpleCellRenderer }; - state = {resizing: false}; + state = { resizing: false }; onDragStart = (e) => { - this.setState({resizing: true}); + this.setState({ resizing: true }); // need to set dummy data for FF if (e && e.dataTransfer && e.dataTransfer.setData) e.dataTransfer.setData('text/plain', 'dummy'); }; @@ -52,7 +52,7 @@ class HeaderCell extends React.Component { onDragEnd = (e) => { const width = this.getWidthFromMouseEvent(e); this.props.onResizeEnd(this.props.column, width); - this.setState({resizing: false}); + this.setState({ resizing: false }); }; getWidthFromMouseEvent = (e) => { @@ -62,15 +62,15 @@ class HeaderCell extends React.Component { }; getCell = () => { - const {height, column, renderer} = this.props; + const { height, column, renderer } = this.props; if (React.isValidElement(renderer)) { // if it is a string, it's an HTML element, and column is not a valid property, so only pass height if (typeof this.props.renderer.type === 'string') { - return React.cloneElement(renderer, {height}); + return React.cloneElement(renderer, { height }); } - return React.cloneElement(renderer, {column, height}); + return React.cloneElement(renderer, { column, height }); } - return this.props.renderer({column}); + return this.props.renderer({ column }); }; getStyle = () => { diff --git a/packages/react-data-grid/src/HeaderRow.js b/packages/react-data-grid/src/HeaderRow.js index 796ebcba57..08aaa5505a 100644 --- a/packages/react-data-grid/src/HeaderRow.js +++ b/packages/react-data-grid/src/HeaderRow.js @@ -2,7 +2,7 @@ import React from 'react'; import shallowEqual from 'shallowequal'; import BaseHeaderCell from './HeaderCell'; import getScrollbarSize from './getScrollbarSize'; -import {getColumn, getSize, isFrozen} from './ColumnUtils'; +import { getColumn, getSize, isFrozen } from './ColumnUtils'; import SortableHeaderCell from 'common/cells/headerCells/SortableHeaderCell'; import FilterableHeaderCell from 'common/cells/headerCells/FilterableHeaderCell'; import HeaderCellType from './HeaderCellType'; diff --git a/packages/react-data-grid/src/ReactDataGrid.js b/packages/react-data-grid/src/ReactDataGrid.js index 42c66addb0..95e300edb5 100644 --- a/packages/react-data-grid/src/ReactDataGrid.js +++ b/packages/react-data-grid/src/ReactDataGrid.js @@ -1,12 +1,12 @@ import React from 'react'; import PropTypes from 'prop-types'; -import {deprecate} from 'react-is-deprecated'; +import { deprecate } from 'react-is-deprecated'; import BaseGrid from './Grid'; import CheckboxEditor from 'common/editors/CheckboxEditor'; import RowUtils from './RowUtils'; -import {getColumn, getSize} from './ColumnUtils'; +import { getColumn, getSize } from './ColumnUtils'; import KeyCodes from './KeyCodes'; -import {isFunction} from 'common/utils'; +import { isFunction } from 'common/utils'; import SelectAll from './formatters/SelectAll'; import { DEFINE_SORT } from 'common/cells/headerCells/SortableHeaderCell'; const ColumnMetrics = require('./ColumnMetrics'); @@ -244,7 +244,7 @@ class ReactDataGrid extends React.Component { constructor(props, context) { super(props, context); const columnMetrics = this.createColumnMetrics(); - const initialState = {columnMetrics, selectedRows: [], expandedRows: [], canFilter: false, columnFilters: {}, sortDirection: null, sortColumn: null, scrollOffset: 0, lastRowIdxUiSelected: -1}; + const initialState = { columnMetrics, selectedRows: [], expandedRows: [], canFilter: false, columnFilters: {}, sortDirection: null, sortColumn: null, scrollOffset: 0, lastRowIdxUiSelected: -1 }; if (this.props.sortColumn && this.props.sortDirection) { initialState.sortColumn = this.props.sortColumn; initialState.sortDirection = this.props.sortDirection; @@ -274,7 +274,7 @@ class ReactDataGrid extends React.Component { if (!ColumnMetrics.sameColumns(this.props.columns, nextProps.columns, this.props.columnEquality) || nextProps.minWidth !== this.props.minWidth) { const columnMetrics = this.createColumnMetrics(nextProps); - this.setState({columnMetrics: columnMetrics}); + this.setState({ columnMetrics: columnMetrics }); } } } @@ -452,7 +452,7 @@ class ReactDataGrid extends React.Component { if (this.props.onGridRowsUpdated) { const cellKey = this.getColumn(e.idx).key; - this.onGridRowsUpdated(cellKey, e.rowIdx, this.props.rowsCount - 1, {[cellKey]: e.rowData[cellKey]}, UpdateActions.COLUMN_FILL); + this.onGridRowsUpdated(cellKey, e.rowIdx, this.props.rowsCount - 1, { [cellKey]: e.rowData[cellKey] }, UpdateActions.COLUMN_FILL); } }; @@ -489,7 +489,7 @@ class ReactDataGrid extends React.Component { // Deprecated prop // to be removed in next major release if (isFunction(this.props.onRowUpdated)) { - this.props.onRowUpdated({updated, rowIdx: fromRow, cellKey, value: updated[cellKey]}); + this.props.onRowUpdated({ updated, rowIdx: fromRow, cellKey, value: updated[cellKey] }); } if (!isFunction(onGridRowsUpdated)) { return; @@ -518,7 +518,7 @@ class ReactDataGrid extends React.Component { } handleSort = (columnKey, direction) => { - this.setState({sortDirection: direction, sortColumn: columnKey}, () => { + this.setState({ sortDirection: direction, sortColumn: columnKey }, () => { this.props.onGridSort(columnKey, direction); }); }; @@ -542,7 +542,7 @@ class ReactDataGrid extends React.Component { // return false if not a shift select so can be handled as normal row selection handleShiftSelect = (rowIdx) => { if (this.state.lastRowIdxUiSelected > -1 && this.isSingleKeyDown(KeyCodes.Shift)) { - const {keys, indexes, isSelectedKey} = this.props.rowSelection.selectBy; + const { keys, indexes, isSelectedKey } = this.props.rowSelection.selectBy; const isPreviouslySelected = RowUtils.isRowSelected(keys, indexes, isSelectedKey, this.props.rowGetter(rowIdx), rowIdx); if (isPreviouslySelected) return false; @@ -553,7 +553,7 @@ class ReactDataGrid extends React.Component { const rowsSelected = []; for (let i = this.state.lastRowIdxUiSelected + 1; i <= rowIdx; i++) { - rowsSelected.push({rowIdx: i, row: this.props.rowGetter(i)}); + rowsSelected.push({ rowIdx: i, row: this.props.rowGetter(i) }); } if (typeof this.props.rowSelection.onRowsSelected === 'function') { @@ -565,7 +565,7 @@ class ReactDataGrid extends React.Component { const rowsSelected = []; for (let i = rowIdx; i <= this.state.lastRowIdxUiSelected - 1; i++) { - rowsSelected.push({rowIdx: i, row: this.props.rowGetter(i)}); + rowsSelected.push({ rowIdx: i, row: this.props.rowGetter(i) }); } if (typeof this.props.rowSelection.onRowsSelected === 'function') { @@ -576,7 +576,7 @@ class ReactDataGrid extends React.Component { } if (handled) { - this.setState({lastRowIdxUiSelected: rowIdx}); + this.setState({ lastRowIdxUiSelected: rowIdx }); } return handled; @@ -590,15 +590,15 @@ class ReactDataGrid extends React.Component { this.selectAllCheckbox.checked = false; } - const {keys, indexes, isSelectedKey} = this.props.rowSelection.selectBy; + const { keys, indexes, isSelectedKey } = this.props.rowSelection.selectBy; const isPreviouslySelected = RowUtils.isRowSelected(keys, indexes, isSelectedKey, rowData, rowIdx); - this.setState({lastRowIdxUiSelected: isPreviouslySelected ? -1 : rowIdx, selected: {rowIdx: rowIdx, idx: 0}}); + this.setState({ lastRowIdxUiSelected: isPreviouslySelected ? -1 : rowIdx, selected: { rowIdx: rowIdx, idx: 0 } }); if (isPreviouslySelected && typeof this.props.rowSelection.onRowsDeselected === 'function') { - this.props.rowSelection.onRowsDeselected([{rowIdx, row: rowData}]); + this.props.rowSelection.onRowsDeselected([{ rowIdx, row: rowData }]); } else if (!isPreviouslySelected && typeof this.props.rowSelection.onRowsSelected === 'function') { - this.props.rowSelection.onRowsSelected([{rowIdx, row: rowData}]); + this.props.rowSelection.onRowsSelected([{ rowIdx, row: rowData }]); } }; @@ -624,7 +624,7 @@ class ReactDataGrid extends React.Component { rowData.isSelected = true; selectedRows.push(rowData); } - this.setState({selectedRows: selectedRows, selected: {rowIdx: rowIdx, idx: 0}}); + this.setState({ selectedRows: selectedRows, selected: { rowIdx: rowIdx, idx: 0 } }); if (this.props.onRowSelect) { this.props.onRowSelect(selectedRows.filter(r => r.isSelected === true)); } @@ -639,14 +639,14 @@ class ReactDataGrid extends React.Component { allRowsSelected = false; } if (this.useNewRowSelection()) { - const {keys, indexes, isSelectedKey} = this.props.rowSelection.selectBy; + const { keys, indexes, isSelectedKey } = this.props.rowSelection.selectBy; if (allRowsSelected && typeof this.props.rowSelection.onRowsSelected === 'function') { const selectedRows = []; for (let i = 0; i < this.props.rowsCount; i++) { const rowData = this.props.rowGetter(i); if (!RowUtils.isRowSelected(keys, indexes, isSelectedKey, rowData, i)) { - selectedRows.push({rowIdx: i, row: rowData}); + selectedRows.push({ rowIdx: i, row: rowData }); } } @@ -658,7 +658,7 @@ class ReactDataGrid extends React.Component { for (let i = 0; i < this.props.rowsCount; i++) { const rowData = this.props.rowGetter(i); if (RowUtils.isRowSelected(keys, indexes, isSelectedKey, rowData, i)) { - deselectedRows.push({rowIdx: i, row: rowData}); + deselectedRows.push({ rowIdx: i, row: rowData }); } } @@ -669,10 +669,10 @@ class ReactDataGrid extends React.Component { } else { const selectedRows = []; for (let i = 0; i < this.props.rowsCount; i++) { - const row = Object.assign({}, this.props.rowGetter(i), {isSelected: allRowsSelected}); + const row = Object.assign({}, this.props.rowGetter(i), { isSelected: allRowsSelected }); selectedRows.push(row); } - this.setState({selectedRows: selectedRows}); + this.setState({ selectedRows: selectedRows }); if (typeof this.props.onRowSelect === 'function') { this.props.onRowSelect(selectedRows.filter(r => r.isSelected === true)); } @@ -779,7 +779,7 @@ class ReactDataGrid extends React.Component { renderToolbar = () => { const Toolbar = this.props.toolbar; - const toolBarProps = {columns: this.props.columns, onToggleFilter: this.onToggleFilter, numberOfRows: this.props.rowsCount}; + const toolBarProps = { columns: this.props.columns, onToggleFilter: this.onToggleFilter, numberOfRows: this.props.rowsCount }; if (React.isValidElement(Toolbar)) { return ( React.cloneElement(Toolbar, toolBarProps)); } else if (isFunction(Toolbar)) { @@ -820,7 +820,7 @@ class ReactDataGrid extends React.Component { gridWidth = '100%'; } return ( -
{toolbar}
diff --git a/packages/react-data-grid/src/Row.js b/packages/react-data-grid/src/Row.js index 73fa8e8625..9b88299bdc 100644 --- a/packages/react-data-grid/src/Row.js +++ b/packages/react-data-grid/src/Row.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import joinClasses from 'classnames'; import Cell from './Cell'; import createObjectWithProperties from './createObjectWithProperties'; -import {isFrozen} from './ColumnUtils'; +import { isFrozen } from './ColumnUtils'; require('../../../themes/react-data-grid-row.css'); // The list of the propTypes that we want to include in the Row div diff --git a/packages/react-data-grid/src/Viewport.js b/packages/react-data-grid/src/Viewport.js index 8fd4bae158..67a45ba49b 100644 --- a/packages/react-data-grid/src/Viewport.js +++ b/packages/react-data-grid/src/Viewport.js @@ -2,7 +2,7 @@ import React from 'react'; import Canvas from './Canvas'; import cellMetaDataShape from 'common/prop-shapes/CellMetaDataShape'; import PropTypes from 'prop-types'; -import {getSize} from './ColumnUtils'; +import { getSize } from './ColumnUtils'; import { getGridState, getColOverscanEndIdx, @@ -109,7 +109,7 @@ class Viewport extends React.Component { } }; - getNextScrollState({ scrollTop, scrollLeft, height, rowHeight, rowsCount}) { + getNextScrollState({ scrollTop, scrollLeft, height, rowHeight, rowsCount }) { const isScrolling = true; const { columns } = this.props.columnMetrics; const scrollDirection = getScrollDirection(this.state, scrollTop, scrollLeft); diff --git a/packages/react-data-grid/src/__tests__/Canvas.spec.js b/packages/react-data-grid/src/__tests__/Canvas.spec.js index 2835fdb5c0..27224343ac 100644 --- a/packages/react-data-grid/src/__tests__/Canvas.spec.js +++ b/packages/react-data-grid/src/__tests__/Canvas.spec.js @@ -85,11 +85,11 @@ describe('Canvas Tests', () => { }); describe('Row Selection', () => { - const COLUMNS = [{key: 'id', name: 'ID'}]; + const COLUMNS = [{ key: 'id', name: 'ID' }]; describe('selectBy index', () => { it('renders row selected', () => { - const rowGetter = () => { return { id: 1}; }; + const rowGetter = () => { return { id: 1 }; }; const props = { rowOverscanStartIdx: 0, rowOverscanEndIdx: 1, COLUMNS, rowGetter, rowsCount: 1, rowSelection: { indexes: [0] } }; wrapper = renderComponent(props); @@ -101,7 +101,7 @@ describe('Canvas Tests', () => { describe('selectBy keys', () => { it('renders row selected', () => { - const rowGetter = () => { return {id: 1}; }; + const rowGetter = () => { return { id: 1 }; }; const props = { rowOverscanStartIdx: 0, rowOverscanEndIdx: 1, COLUMNS, rowGetter, rowsCount: 1, rowSelection: { keys: { rowKey: 'id', values: [1] } } }; wrapper = renderComponent(props); @@ -114,9 +114,9 @@ describe('Canvas Tests', () => { describe('selectBy `isSelectedKey`', () => { it('renders row selected', () => { - const rowGetter = (i) => { return i === 0 ? {id: 1, isSelected: true} : null; }; + const rowGetter = (i) => { return i === 0 ? { id: 1, isSelected: true } : null; }; - const props = { rowOverscanStartIdx: 0, rowOverscanEndIdx: 1, COLUMNS, rowGetter, rowsCount: 1, rowSelection: { isSelectedKey: 'isSelected'} }; + const props = { rowOverscanStartIdx: 0, rowOverscanEndIdx: 1, COLUMNS, rowGetter, rowsCount: 1, rowSelection: { isSelectedKey: 'isSelected' } }; wrapper = renderComponent(props); const rows = getRows(wrapper); @@ -130,8 +130,8 @@ describe('Canvas Tests', () => { return function() { return { children: [ - {id: 'row1-0'}, - {id: 'row1-1'} + { id: 'row1-0' }, + { id: 'row1-1' } ], treeDepth: 1, siblingIndex: index, @@ -140,14 +140,14 @@ describe('Canvas Tests', () => { }; } - const COLUMNS = [{key: 'id', name: 'ID', left: 100}]; + const COLUMNS = [{ key: 'id', name: 'ID', left: 100 }]; it('can render a custom renderer if __metadata property exists', () => { const EmptyChildRow = () => { return (
); }; - const rowGetter = () => { return {id: 0, __metaData: {getRowRenderer: EmptyChildRow}}; }; - const props = { rowOverscanStartIdx: 0, rowOverscanEndIdx: 1, columns: COLUMNS, rowGetter, rowsCount: 1, getSubRowDetails: getFakeSubRowDetails(1)}; + const rowGetter = () => { return { id: 0, __metaData: { getRowRenderer: EmptyChildRow } }; }; + const props = { rowOverscanStartIdx: 0, rowOverscanEndIdx: 1, columns: COLUMNS, rowGetter, rowsCount: 1, getSubRowDetails: getFakeSubRowDetails(1) }; wrapper = renderComponent(props); const rows = getRows(wrapper); expect(rows[0].props.className).toBe('test-row-renderer'); diff --git a/packages/react-data-grid/src/__tests__/Cell.spec.js b/packages/react-data-grid/src/__tests__/Cell.spec.js index 0779b638c6..0833dd19aa 100644 --- a/packages/react-data-grid/src/__tests__/Cell.spec.js +++ b/packages/react-data-grid/src/__tests__/Cell.spec.js @@ -7,7 +7,7 @@ import CellAction from '../CellAction'; import SimpleCellFormatter from '../formatters/SimpleCellFormatter'; const testCellMetaData = { - selected: {idx: 2, rowIdx: 3}, + selected: { idx: 2, rowIdx: 3 }, dragged: null, onCellClick: function() {}, onCellFocus: function() {}, @@ -24,13 +24,13 @@ const testCellMetaData = { const testProps = { rowIdx: 0, idx: 1, - column: {name: 'col1'}, + column: { name: 'col1' }, value: 'Wicklow', isExpanded: false, expandableOption: {}, cellMetaData: testCellMetaData, handleDragStart: () => {}, - rowData: {name: 'Johnny Test', location: 'Wicklow', likesTesting: 'Absolutely'}, + rowData: { name: 'Johnny Test', location: 'Wicklow', likesTesting: 'Absolutely' }, height: 40, name: 'JT' }; @@ -59,7 +59,7 @@ describe('Cell Tests', () => { }); it('should render children when those are passed', () => { - const wrapper = renderComponent({ children: (
Child
)}); + const wrapper = renderComponent({ children: (
Child
) }); expect(wrapper.children().text()).toBe('Child'); }); @@ -73,10 +73,10 @@ describe('Cell Tests', () => { rowIdx: 18, idx: 19, column: helpers.columns[0], - row: {key: 'value'}, + row: { key: 'value' }, value: 'requiredValue', cellMetaData: { - selected: {idx: 2, rowIdx: 3}, + selected: { idx: 2, rowIdx: 3 }, dragged: null, onCellClick: jasmine.createSpy(), onCellFocus: jasmine.createSpy(), @@ -90,14 +90,14 @@ describe('Cell Tests', () => { onColumnEvent: jasmine.createSpy() }, rowData: helpers.rowGetter(11), - expandableOptions: {key: 'reqValue'}, + expandableOptions: { key: 'reqValue' }, isScrolling: false }; const allProperties = { rowIdx: 20, idx: 21, - selected: {idx: 18}, + selected: { idx: 18 }, height: 35, ref: () => {}, column: helpers.columns[1], @@ -105,7 +105,7 @@ describe('Cell Tests', () => { isExpanded: true, isRowSelected: false, cellMetaData: { - selected: {idx: 2, rowIdx: 3}, + selected: { idx: 2, rowIdx: 3 }, dragged: null, onCellClick: jasmine.createSpy(), onCellFocus: jasmine.createSpy(), @@ -124,7 +124,7 @@ describe('Cell Tests', () => { rowData: helpers.rowGetter(10), extraClasses: 'extra-classes', forceUpdate: false, - expandableOptions: {key: 'value'}, + expandableOptions: { key: 'value' }, isScrolling: true }; @@ -181,10 +181,10 @@ describe('Cell Tests', () => { rowIdx: 18, idx: 19, column: helpers.columns[0], - row: {key: 'value'}, + row: { key: 'value' }, value: 'requiredValue', cellMetaData: { - selected: {idx: 2, rowIdx: 3}, + selected: { idx: 2, rowIdx: 3 }, dragged: null, onCellClick: jasmine.createSpy(), onCellFocus: jasmine.createSpy(), @@ -198,7 +198,7 @@ describe('Cell Tests', () => { onColumnEvent: jasmine.createSpy() }, rowData: helpers.rowGetter(11), - expandableOptions: {key: 'reqValue'}, + expandableOptions: { key: 'reqValue' }, isScrolling: false }, propsOverride); @@ -211,10 +211,10 @@ describe('Cell Tests', () => { describe('when getCellActions is in cellMetadata', () => { it('should render some CellActions', () => { - const action = {icon: 'glpyhicon glyphicon-link', callback: sinon.spy()}; - const {wrapper} = setup({ + const action = { icon: 'glpyhicon glyphicon-link', callback: sinon.spy() }; + const { wrapper } = setup({ cellMetaData: { - selected: {idx: 2, rowIdx: 3}, + selected: { idx: 2, rowIdx: 3 }, dragged: null, onCellClick: jasmine.createSpy(), onCellFocus: jasmine.createSpy(), @@ -242,7 +242,7 @@ describe('Cell Tests', () => { describe('when getCellActions is not in cellMetadata', () => { it('should not render any CellActions', () => { - const {wrapper} = setup(); + const { wrapper } = setup(); const renderedCellActions = wrapper.find(CellAction); diff --git a/packages/react-data-grid/src/__tests__/CellAction.spec.js b/packages/react-data-grid/src/__tests__/CellAction.spec.js index 35bc33495e..1e0f0ca03b 100644 --- a/packages/react-data-grid/src/__tests__/CellAction.spec.js +++ b/packages/react-data-grid/src/__tests__/CellAction.spec.js @@ -1,104 +1,104 @@ -import React from 'react'; -import sinon from 'sinon'; -import {shallow} from 'enzyme'; -import CellAction from '../CellAction'; - -const setup = (overriderProps = {}) => { - const props = Object.assign({ - action: { - icon: 'glyphicon glyphicon-link', - callback: sinon.spy() - }, - isFirst: true - }, overriderProps); - const wrapper = shallow(); - return { - props, - wrapper - }; -}; - -describe('Cell Action Tests', () => { - describe('when a button action is passed', () => { - it('will render a button action and hook up the callback function', () => { - const {wrapper, props} = setup(); - const renderedActionButton = wrapper.find('.rdg-cell-action-button'); - const renderedActionButtonProps = renderedActionButton.props(); - const renderedActionMenu = wrapper.find('.rdg-cell-action-menu'); - - expect(renderedActionButton.length).toBe(1); - expect(renderedActionButtonProps.onClick).toEqual(jasmine.any(Function)); - - renderedActionButton.simulate('click'); - - expect(props.action.callback.called).toBeTruthy(); - - expect(renderedActionMenu.length).toBe(0); - }); - }); - - describe('when a menu action is passed', () => { - it('will render a toggle button which will hide/show the menu of actions', () => { - const {wrapper, props} = setup({ - action: { - icon: 'glyphicon glyphicon-link', - actions: [ - { - text: 'Test Action 1', - callback: sinon.spy() - }, - { - text: 'Test Action 1', - callback: sinon.spy() - } - ] - } - }); - let wrapperState = wrapper.state(); - const renderedActionButton = wrapper.find('.rdg-cell-action-button'); - const renderedActionButtonProps = renderedActionButton.props(); - let renderedActionMenu = wrapper.find('.rdg-cell-action-menu'); - - expect(renderedActionButton.length).toBe(1); - expect(renderedActionButtonProps.onClick).toEqual(jasmine.any(Function)); - expect(wrapperState.isMenuOpen).toBeFalsy(); - expect(renderedActionMenu.length).toBe(0); - - renderedActionButton.simulate('click'); - - wrapperState = wrapper.state(); - renderedActionMenu = wrapper.find('.rdg-cell-action-menu'); - const renderedActionMenuProps = renderedActionMenu.props(); - - expect(wrapperState.isMenuOpen).toBeTruthy(); - expect(renderedActionMenu.length).toBe(1); - expect(renderedActionMenuProps.children.length).toBe(props.action.actions.length); - - expect(props.action.actions[0].callback.called).toBeFalsy(); - renderedActionMenu.childAt(0).simulate('click'); - expect(props.action.actions[0].callback.called).toBeTruthy(); - }); - }); - - describe('when isFirst is passed', () => { - describe('when isFirst is true', () => { - it('will render a button action with cell-action-last class on it', () => { - const {wrapper} = setup({isFirst: true}); - const wrapperProps = wrapper.props(); - - expect(wrapper.length).toBe(1); - expect(wrapperProps.className).toBe('rdg-cell-action rdg-cell-action-last'); - }); - }); - - describe('when isFirst is false', () => { - it('will render a button action without cell-action-last class on it', () => { - const {wrapper} = setup({isFirst: false}); - const wrapperProps = wrapper.props(); - - expect(wrapper.length).toBe(1); - expect(wrapperProps.className).toBe('rdg-cell-action'); - }); - }); - }); -}); +import React from 'react'; +import sinon from 'sinon'; +import { shallow } from 'enzyme'; +import CellAction from '../CellAction'; + +const setup = (overriderProps = {}) => { + const props = Object.assign({ + action: { + icon: 'glyphicon glyphicon-link', + callback: sinon.spy() + }, + isFirst: true + }, overriderProps); + const wrapper = shallow(); + return { + props, + wrapper + }; +}; + +describe('Cell Action Tests', () => { + describe('when a button action is passed', () => { + it('will render a button action and hook up the callback function', () => { + const { wrapper, props } = setup(); + const renderedActionButton = wrapper.find('.rdg-cell-action-button'); + const renderedActionButtonProps = renderedActionButton.props(); + const renderedActionMenu = wrapper.find('.rdg-cell-action-menu'); + + expect(renderedActionButton.length).toBe(1); + expect(renderedActionButtonProps.onClick).toEqual(jasmine.any(Function)); + + renderedActionButton.simulate('click'); + + expect(props.action.callback.called).toBeTruthy(); + + expect(renderedActionMenu.length).toBe(0); + }); + }); + + describe('when a menu action is passed', () => { + it('will render a toggle button which will hide/show the menu of actions', () => { + const { wrapper, props } = setup({ + action: { + icon: 'glyphicon glyphicon-link', + actions: [ + { + text: 'Test Action 1', + callback: sinon.spy() + }, + { + text: 'Test Action 1', + callback: sinon.spy() + } + ] + } + }); + let wrapperState = wrapper.state(); + const renderedActionButton = wrapper.find('.rdg-cell-action-button'); + const renderedActionButtonProps = renderedActionButton.props(); + let renderedActionMenu = wrapper.find('.rdg-cell-action-menu'); + + expect(renderedActionButton.length).toBe(1); + expect(renderedActionButtonProps.onClick).toEqual(jasmine.any(Function)); + expect(wrapperState.isMenuOpen).toBeFalsy(); + expect(renderedActionMenu.length).toBe(0); + + renderedActionButton.simulate('click'); + + wrapperState = wrapper.state(); + renderedActionMenu = wrapper.find('.rdg-cell-action-menu'); + const renderedActionMenuProps = renderedActionMenu.props(); + + expect(wrapperState.isMenuOpen).toBeTruthy(); + expect(renderedActionMenu.length).toBe(1); + expect(renderedActionMenuProps.children.length).toBe(props.action.actions.length); + + expect(props.action.actions[0].callback.called).toBeFalsy(); + renderedActionMenu.childAt(0).simulate('click'); + expect(props.action.actions[0].callback.called).toBeTruthy(); + }); + }); + + describe('when isFirst is passed', () => { + describe('when isFirst is true', () => { + it('will render a button action with cell-action-last class on it', () => { + const { wrapper } = setup({ isFirst: true }); + const wrapperProps = wrapper.props(); + + expect(wrapper.length).toBe(1); + expect(wrapperProps.className).toBe('rdg-cell-action rdg-cell-action-last'); + }); + }); + + describe('when isFirst is false', () => { + it('will render a button action without cell-action-last class on it', () => { + const { wrapper } = setup({ isFirst: false }); + const wrapperProps = wrapper.props(); + + expect(wrapper.length).toBe(1); + expect(wrapperProps.className).toBe('rdg-cell-action'); + }); + }); + }); +}); diff --git a/packages/react-data-grid/src/__tests__/ColumnMetrics.spec.js b/packages/react-data-grid/src/__tests__/ColumnMetrics.spec.js index 45c866682f..3517fa2c60 100644 --- a/packages/react-data-grid/src/__tests__/ColumnMetrics.spec.js +++ b/packages/react-data-grid/src/__tests__/ColumnMetrics.spec.js @@ -46,9 +46,9 @@ describe('Column Metrics Tests', () => { }); it('should shift all frozen columns to the start of column metrics array', () => { - const firstFrozenColumn = {key: 'frozenColumn1', name: 'frozenColumn1', frozen: true}; - const secondFrozenColumn = {key: 'frozenColumn2', name: 'frozenColumn2', frozen: true}; - const thirdFrozenColumn = {key: 'frozenColumn3', name: 'frozenColumn3', frozen: true}; + const firstFrozenColumn = { key: 'frozenColumn1', name: 'frozenColumn1', frozen: true }; + const secondFrozenColumn = { key: 'frozenColumn2', name: 'frozenColumn2', frozen: true }; + const thirdFrozenColumn = { key: 'frozenColumn3', name: 'frozenColumn3', frozen: true }; const columns = [...getInitialColumns(), secondFrozenColumn, thirdFrozenColumn]; columns.splice(2, 0, firstFrozenColumn); const metrics = ColumnMetrics.recalculate({ columns, totalWidth, minColumnWidth: 50 }); diff --git a/packages/react-data-grid/src/__tests__/ColumnUtils.spec.js b/packages/react-data-grid/src/__tests__/ColumnUtils.spec.js index a704895779..c86238e71d 100644 --- a/packages/react-data-grid/src/__tests__/ColumnUtils.spec.js +++ b/packages/react-data-grid/src/__tests__/ColumnUtils.spec.js @@ -1,5 +1,5 @@ import React from 'react'; -import {canEdit} from '../ColumnUtils'; +import { canEdit } from '../ColumnUtils'; import ReactDOM from 'react-dom'; const cloneElement = React.cloneElement; diff --git a/packages/react-data-grid/src/__tests__/FocusableComponentTestRunner.js b/packages/react-data-grid/src/__tests__/FocusableComponentTestRunner.js index f4eafce572..f32752f3eb 100644 --- a/packages/react-data-grid/src/__tests__/FocusableComponentTestRunner.js +++ b/packages/react-data-grid/src/__tests__/FocusableComponentTestRunner.js @@ -46,7 +46,7 @@ class FocusableComponentTestRunner { const { componentDidUpdate } = this.componentPrototype; const selected = this._getNewSelection(this._props); - this._componentWrapper.setProps({ cellMetaData: { selected }}); + this._componentWrapper.setProps({ cellMetaData: { selected } }); expect(componentDidUpdate.calls.count()).toBe(1); }); @@ -72,7 +72,7 @@ class FocusableComponentTestRunner { // Act. this._componentWrapper = mount(); - this._componentWrapper.setProps({ cellMetaData: { selected: this._getNewSelection(selection) }}); + this._componentWrapper.setProps({ cellMetaData: { selected: this._getNewSelection(selection) } }); // Assert. expect(this.componentPrototype.componentDidUpdate).not.toHaveBeenCalled(); diff --git a/packages/react-data-grid/src/__tests__/Grid.spec.js b/packages/react-data-grid/src/__tests__/Grid.spec.js index 9c621f4e25..ab1472c8c6 100644 --- a/packages/react-data-grid/src/__tests__/Grid.spec.js +++ b/packages/react-data-grid/src/__tests__/Grid.spec.js @@ -1,6 +1,6 @@ import React from 'react'; import Grid from '../Grid'; -import helpers, {fakeCellMetaData} from '../helpers/test/GridPropHelpers'; +import helpers, { fakeCellMetaData } from '../helpers/test/GridPropHelpers'; import { shallow } from 'enzyme'; import { ContextMenu } from 'react-contextmenu'; @@ -66,7 +66,7 @@ describe('Rendering Grid component', () => { emptyRowsView: jasmine.createSpy(), expandedRows: jasmine.createSpy(), selectedRows: jasmine.createSpy(), - rowSelection: {isSelectedKey: 'selectedKey'}, + rowSelection: { isSelectedKey: 'selectedKey' }, rowsCount: 14, onRows: jasmine.createSpy(), sortColumn: 'sortColumn', @@ -81,7 +81,7 @@ describe('Rendering Grid component', () => { onColumnResize: jasmine.createSpy(), onSort: jasmine.createSpy(), cellMetaData: { - selected: {idx: 2, rowIdx: 3}, + selected: { idx: 2, rowIdx: 3 }, dragged: null, onCellClick: jasmine.createSpy(), onCellContextMenu: jasmine.createSpy(), @@ -100,7 +100,7 @@ describe('Rendering Grid component', () => { draggableHeaderCell: jasmine.createSpy(), getValidFilterValues: jasmine.createSpy(), rowGroupRenderer: jasmine.createSpy(), - overScan: {key: 'value'} + overScan: { key: 'value' } }; }; it('passes classname property', () => { diff --git a/packages/react-data-grid/src/__tests__/Header.spec.js b/packages/react-data-grid/src/__tests__/Header.spec.js index d2902483ea..d9c70a737b 100644 --- a/packages/react-data-grid/src/__tests__/Header.spec.js +++ b/packages/react-data-grid/src/__tests__/Header.spec.js @@ -3,7 +3,7 @@ import Immutable from 'immutable'; import Header from '../Header'; import HeaderRow from '../HeaderRow'; -import helpers, {fakeCellMetaData} from '../helpers/test/GridPropHelpers'; +import helpers, { fakeCellMetaData } from '../helpers/test/GridPropHelpers'; import * as GetScrollbarSize from '../getScrollbarSize'; import { shallow } from 'enzyme'; const SCROLL_BAR_SIZE = 17; @@ -23,7 +23,7 @@ describe('Header Unit Tests', () => { cellMetaData: fakeCellMetaData, totalWidth: 1000, height: 50, - headerRows: [{height: 50, ref: 'row'}], + headerRows: [{ height: 50, ref: 'row' }], onColumnResize: jasmine.createSpy(), onSort: () => null }; @@ -106,7 +106,7 @@ describe('Header Unit Tests', () => { width: 2601 }, height: 51, - headerRows: [{height: 51, ref: 'row'}], + headerRows: [{ height: 51, ref: 'row' }], onSort: jasmine.createSpy() }; const testAllProps = { @@ -118,7 +118,7 @@ describe('Header Unit Tests', () => { }, totalWidth: 1000, height: 50, - headerRows: [{height: 50, ref: 'row'}], + headerRows: [{ height: 50, ref: 'row' }], sortColumn: 'sortColumnValue', sortDirection: 'DESC', onSort: jasmine.createSpy(), diff --git a/packages/react-data-grid/src/__tests__/HeaderCell.spec.js b/packages/react-data-grid/src/__tests__/HeaderCell.spec.js index 79a0e68f59..6573efa30c 100644 --- a/packages/react-data-grid/src/__tests__/HeaderCell.spec.js +++ b/packages/react-data-grid/src/__tests__/HeaderCell.spec.js @@ -21,28 +21,28 @@ describe('Header Cell Tests', () => { }; function setup(overrideProps = {}) { - const props = {...testProps, ...overrideProps}; + const props = { ...testProps, ...overrideProps }; const wrapper = shallow(); - return {wrapper, props}; + return { wrapper, props }; } it('should initialize the state correctly', () => { - const {wrapper} = setup(); + const { wrapper } = setup(); expect(wrapper.state()).toEqual( - {resizing: false} + { resizing: false } ); }); describe('When custom render is supplied', () => { it('will render', () => { const CustomRenderer = () =>
Custom
; - const {wrapper} = setup({renderer: }); + const { wrapper } = setup({ renderer: }); expect(wrapper.find(CustomRenderer).length).toBe(1); }); it('will have height passed in props', () => { const CustomRenderer = () =>
Custom
; - const {wrapper} = setup({renderer: }); + const { wrapper } = setup({ renderer: }); expect(wrapper.find(CustomRenderer).props().height).toBe(testProps.height); }); }); @@ -57,13 +57,13 @@ describe('Header Cell Tests', () => { }); it('should render a resize handle', () => { - const {wrapper} = setup(); + const { wrapper } = setup(); const resizeHandle = wrapper.find(ResizeHandle); expect(resizeHandle.length).toBe(1); }); it('start dragging handle should set resizing state to be true', () => { - const {wrapper} = setup(); + const { wrapper } = setup(); const resizeHandle = wrapper.find(ResizeHandle); resizeHandle.props().onDragStart(); expect(wrapper.state().resizing).toBe(true); @@ -73,7 +73,7 @@ describe('Header Cell Tests', () => { const dragLength = 200; const wrapper = mount(); const resizeHandle = wrapper.find(ResizeHandle); - const fakeEvent = {pageX: dragLength}; + const fakeEvent = { pageX: dragLength }; resizeHandle.props().onDrag(fakeEvent); expect(testProps.onResize).toHaveBeenCalled(); expect(testProps.onResize.calls.mostRecent().args[0]).toEqual(testProps.column); @@ -82,8 +82,8 @@ describe('Header Cell Tests', () => { it('finish dragging should reset resizing state', () => { const wrapper = mount(); - wrapper.setState({resizing: true}); - const fakeEvent = {pageX: 250}; + wrapper.setState({ resizing: true }); + const fakeEvent = { pageX: 250 }; const resizeHandle = wrapper.find(ResizeHandle); resizeHandle.props().onDragEnd(fakeEvent); expect(wrapper.state().resizing).toBe(false); @@ -92,7 +92,7 @@ describe('Header Cell Tests', () => { it('finish dragging should call onResizeEnd with correct params', () => { const wrapper = mount(); const resizeHandle = wrapper.find(ResizeHandle); - const fakeEvent = {pageX: 250}; + const fakeEvent = { pageX: 250 }; resizeHandle.props().onDrag(fakeEvent); expect(testProps.onResizeEnd).toHaveBeenCalled(); expect(testProps.onResizeEnd.calls.mostRecent().args[0]).toEqual(testProps.column); @@ -103,18 +103,18 @@ describe('Header Cell Tests', () => { describe('getCell method', () => { it('pass the column as property to cell renderer if it is a function', () => { const rendererFunction = jasmine.createSpy(); - const {props} = setup({renderer: rendererFunction}); - expect(rendererFunction.calls.argsFor(0)[0]).toEqual({column: props.column}); + const { props } = setup({ renderer: rendererFunction }); + expect(rendererFunction.calls.argsFor(0)[0]).toEqual({ column: props.column }); }); it('should not pass the column as property to cell renderer if it is an HTML element', () => { const renderer =
Value
; - const {wrapper} = setup({renderer}); + const { wrapper } = setup({ renderer }); const cell = wrapper.instance().getCell(); expect(cell.props.column).toBeUndefined(); }); it('should pass the column as property to cell renderer if it is a React class', () => { const renderer = ; - const {wrapper, props} = setup({renderer}); + const { wrapper, props } = setup({ renderer }); const cell = wrapper.instance().getCell(); expect(cell.props.column).toBe(props.column); }); diff --git a/packages/react-data-grid/src/__tests__/HeaderRow.spec.js b/packages/react-data-grid/src/__tests__/HeaderRow.spec.js index e4af1b83d7..8ec09f5247 100644 --- a/packages/react-data-grid/src/__tests__/HeaderRow.spec.js +++ b/packages/react-data-grid/src/__tests__/HeaderRow.spec.js @@ -4,7 +4,7 @@ import HeaderRow from '../HeaderRow'; import HeaderCell from '../HeaderCell'; import SortableHeaderCell from 'common/cells/headerCells/SortableHeaderCell'; import FilterableHeaderCell from 'common/cells/headerCells/FilterableHeaderCell'; -import { shallow} from 'enzyme'; +import { shallow } from 'enzyme'; describe('Header Row Unit Tests', () => { const defaultProps = { @@ -20,10 +20,10 @@ describe('Header Row Unit Tests', () => { }; const setup = (testProps) => { - const props = {...defaultProps, ...testProps}; + const props = { ...defaultProps, ...testProps }; const wrapper = shallow(); const headerCells = wrapper.find(HeaderCell); - return {wrapper, headerCells, props}; + return { wrapper, headerCells, props }; }; describe('When column is sortable and headerCellRenderer not provided', () => { @@ -38,19 +38,19 @@ describe('Header Row Unit Tests', () => { }); it('should provide column with a sortableHeaderRenderer', () => { - const {headerCells} = setup({sortColumn: defaultProps.columns[sortableColIdx].key}); + const { headerCells } = setup({ sortColumn: defaultProps.columns[sortableColIdx].key }); const renderer = headerCells.at(sortableColIdx).props().renderer; expect(renderer.type).toBe((SortableHeaderCell)); }); it('should pass sort direction as props to headerRenderer when column is sortColumn', () => { - const {headerCells} = setup({sortColumn: defaultProps.columns[sortableColIdx].key, sortDirection: 'ASC'}); + const { headerCells } = setup({ sortColumn: defaultProps.columns[sortableColIdx].key, sortDirection: 'ASC' }); const renderer = headerCells.at(sortableColIdx).props().renderer; expect(renderer.props.sortDirection).toEqual('ASC'); }); it('should call onSort when headerRender triggers sort', () => { - const {headerCells, props} = setup({sortColumn: defaultProps.columns[sortableColIdx].key, sortDirection: 'ASC'}); + const { headerCells, props } = setup({ sortColumn: defaultProps.columns[sortableColIdx].key, sortDirection: 'ASC' }); const renderer = headerCells.at(sortableColIdx).props().renderer; renderer.props.onSort('title', 'DESC'); expect(props.onSort).toHaveBeenCalled(); @@ -69,7 +69,7 @@ describe('Header Row Unit Tests', () => { }); it('should provide column with a filterableHeaderRenderer', () => { - const {headerCells} = setup({sortColumn: defaultProps.columns[sortableAndFilterableColIdx].key, filterable: true}); + const { headerCells } = setup({ sortColumn: defaultProps.columns[sortableAndFilterableColIdx].key, filterable: true }); const renderer = headerCells.at(sortableAndFilterableColIdx).props().renderer; expect(renderer.type).toBe(FilterableHeaderCell); }); @@ -82,7 +82,7 @@ describe('Header Row Unit Tests', () => { }); it('should provide column with a sortableHeaderRenderer', () => { - const {headerCells} = setup({sortColumn: defaultProps.columns[sortableAndFilterableColIdx].key}); + const { headerCells } = setup({ sortColumn: defaultProps.columns[sortableAndFilterableColIdx].key }); const renderer = headerCells.at(sortableAndFilterableColIdx).props().renderer; expect(renderer.type).toBe(SortableHeaderCell); }); @@ -102,14 +102,14 @@ describe('Header Row Unit Tests', () => { }); it('should render custom column header', () => { - const {headerCells} = setup(); + const { headerCells } = setup(); const renderer = headerCells.at(customColumnIdx).props().renderer; expect(renderer.type).toBe(CustomHeader); }); it('should render filter if header row if row and column is filterable', () => { defaultProps.columns[customColumnIdx].filterable = true; - const {headerCells} = setup({filterable: true}); + const { headerCells } = setup({ filterable: true }); const renderer = headerCells.at(customColumnIdx).props().renderer; expect(renderer.type).toBe(FilterableHeaderCell); }); @@ -144,7 +144,7 @@ describe('Header Row Unit Tests', () => { onColumnResize: jasmine.createSpy(), onColumnResizeEnd: jasmine.createSpy(), width: 200, - style: {overflow: 'scroll', + style: { overflow: 'scroll', width: 201, height: 36, position: 'relative' @@ -155,7 +155,7 @@ describe('Header Row Unit Tests', () => { headerCellRenderer: jasmine.createSpy(), filterable: true, onFilterChange: jasmine.createSpy(), - resizing: {key: 'value'}, + resizing: { key: 'value' }, onScroll, draggableHeaderCell: () =>
}; diff --git a/packages/react-data-grid/src/__tests__/Row.spec.js b/packages/react-data-grid/src/__tests__/Row.spec.js index dc960e837f..ddca341dfc 100644 --- a/packages/react-data-grid/src/__tests__/Row.spec.js +++ b/packages/react-data-grid/src/__tests__/Row.spec.js @@ -3,7 +3,7 @@ import TestUtils from 'react-dom/test-utils'; import Row from '../Row'; import Cell from '../Cell'; import { shallow } from 'enzyme'; -import {createColumns} from '../__tests__/utils/createColumns'; +import { createColumns } from '../__tests__/utils/createColumns'; describe('Row', () => { const fakeProps = { @@ -22,7 +22,7 @@ describe('Row', () => { const fakeExtraClasses = ['row-extra-class', 'row-extra-extra-class']; it('should have extra classes', () => { - const newProps = Object.assign({}, fakeProps, {extraClasses: fakeExtraClasses.join(' ')}); + const newProps = Object.assign({}, fakeProps, { extraClasses: fakeExtraClasses.join(' ') }); const component = TestUtils.renderIntoDocument(); const row = TestUtils.findRenderedDOMComponentWithClass(component, 'react-grid-Row'); @@ -39,13 +39,13 @@ describe('Row', () => { const setup = (props) => { const wrapper = shallow(); const cells = wrapper.find(Cell); - return {wrapper, cells}; + return { wrapper, cells }; }; const requiredProperties = { height: 30, columns: createColumns(COLUMN_COUNT), - row: {key: 'value'}, + row: { key: 'value' }, idx: 17, colVisibleStartIdx: 2, colVisibleEndIdx: 20, @@ -57,10 +57,10 @@ describe('Row', () => { const allProperties = { height: 35, columns: createColumns(COLUMN_COUNT), - row: {key: 'value', name: 'name'}, + row: { key: 'value', name: 'name' }, cellRenderer: jasmine.createSpy(), cellMetaData: { - selected: {idx: 2, rowIdx: 3}, + selected: { idx: 2, rowIdx: 3 }, dragged: null, onCellClick: jasmine.createSpy(), onCellContextMenu: jasmine.createSpy(), @@ -74,10 +74,10 @@ describe('Row', () => { }, isSelected: false, idx: 18, - expandedRows: [{key: 'one'}, {key: 'two'}], + expandedRows: [{ key: 'one' }, { key: 'two' }], extraClasses: 'extra-classes', forceUpdate: false, - subRowDetails: {name: 'subrowname'}, + subRowDetails: { name: 'subrowname' }, isRowHovered: false, colVisibleStartIdx: 0, colVisibleEndIdx: 1, @@ -87,22 +87,22 @@ describe('Row', () => { }; it('passes classname property', () => { - const {wrapper} = setup(requiredProperties); + const { wrapper } = setup(requiredProperties); const draggableDiv = wrapper.find('div').at(0); expect(draggableDiv.hasClass('react-grid-Row')); }); it('passes style property', () => { - const {wrapper} = setup(requiredProperties); + const { wrapper } = setup(requiredProperties); const draggableDiv = wrapper.find('div').at(0); expect(draggableDiv.props().style).toBeDefined(); }); it('passes height property', () => { - const {wrapper} = setup(requiredProperties); + const { wrapper } = setup(requiredProperties); const draggableDiv = wrapper.find('div').at(0); expect(draggableDiv.props().height).toBe(30); }); it('does not pass unknown properties to the div', () => { - const {wrapper} = setup(allProperties); + const { wrapper } = setup(allProperties); const draggableDiv = wrapper.find('div').at(0); expect(draggableDiv.props().columns).toBeUndefined(); expect(draggableDiv.props().row).toBeUndefined(); @@ -127,20 +127,20 @@ describe('Row', () => { const LAST_LOCKED_CELL_IDX = 5; const lockColumns = () => createColumns(COLUMN_COUNT).map((c, idx) => { - return idx <= LAST_LOCKED_CELL_IDX ? {...c, frozen: true} : c; + return idx <= LAST_LOCKED_CELL_IDX ? { ...c, frozen: true } : c; }); it('should render all frozen and visible and overscan cells', () => { const columns = lockColumns(LAST_LOCKED_CELL_IDX); - const {cells} = setup({...requiredProperties, columns}); - const {colOverscanStartIdx, colOverscanEndIdx} = requiredProperties; + const { cells } = setup({ ...requiredProperties, columns }); + const { colOverscanStartIdx, colOverscanEndIdx } = requiredProperties; const renderedRange = colOverscanEndIdx - colOverscanStartIdx + 1; expect(cells.length).toBe(renderedRange); }); it('first frozen cell should be rendered after the unfrozen cells', () => { const columns = lockColumns(LAST_LOCKED_CELL_IDX); - const {cells} = setup({...requiredProperties, columns}); + const { cells } = setup({ ...requiredProperties, columns }); const firstFrozenColumn = columns.filter(c => c.frozen === true)[0]; expect(cells.at(cells.length - LAST_LOCKED_CELL_IDX - 1).props().column).toBe(firstFrozenColumn); }); @@ -148,22 +148,22 @@ describe('Row', () => { describe('When not using frozen columns', () => { it('should render all visible and overscan cells', () => { - const {cells} = setup(requiredProperties); - const {colOverscanStartIdx, colOverscanEndIdx} = requiredProperties; + const { cells } = setup(requiredProperties); + const { colOverscanStartIdx, colOverscanEndIdx } = requiredProperties; const renderedRange = colOverscanEndIdx - colOverscanStartIdx + 1; expect(cells.length).toBe(renderedRange); }); it('first rendered cell index should be colOverscanStartIdx', () => { - const {cells} = setup(requiredProperties); - const {columns, colOverscanStartIdx} = requiredProperties; + const { cells } = setup(requiredProperties); + const { columns, colOverscanStartIdx } = requiredProperties; const expectedFirstColumn = columns[colOverscanStartIdx]; expect(cells.first().props().column).toBe(expectedFirstColumn); }); it('last rendered cell index should be colOverscanEndIdx', () => { - const {cells} = setup(requiredProperties); - const {columns, colOverscanEndIdx} = requiredProperties; + const { cells } = setup(requiredProperties); + const { columns, colOverscanEndIdx } = requiredProperties; const expectedLastColumn = columns[colOverscanEndIdx]; expect(cells.last().props().column).toBe(expectedLastColumn); }); diff --git a/packages/react-data-grid/src/__tests__/RowComparer.spec.js b/packages/react-data-grid/src/__tests__/RowComparer.spec.js index 5fe12dd81b..eca7a11aaa 100644 --- a/packages/react-data-grid/src/__tests__/RowComparer.spec.js +++ b/packages/react-data-grid/src/__tests__/RowComparer.spec.js @@ -6,7 +6,7 @@ const cellMetaData = { dragged: null, copied: null }; -const expandedRows = [{key: 'col1'}, {key: 'col2'}]; +const expandedRows = [{ key: 'col1' }, { key: 'col2' }]; describe('RowComparer shouldRowUpdate', () => { it('same props should not cause an update', () => { diff --git a/packages/react-data-grid/src/__tests__/RowUtils.spec.js b/packages/react-data-grid/src/__tests__/RowUtils.spec.js index 041aca0702..c0706a493d 100644 --- a/packages/react-data-grid/src/__tests__/RowUtils.spec.js +++ b/packages/react-data-grid/src/__tests__/RowUtils.spec.js @@ -16,15 +16,15 @@ describe('RowUtils Tests', () => { describe('using keys', () => { it('should return true', () => { - const keyProps = {rowKey: 'name', values: ['tim', 'willim', 'deigo']}; - const rowData = {id: 1, name: 'tim'}; + const keyProps = { rowKey: 'name', values: ['tim', 'willim', 'deigo'] }; + const rowData = { id: 1, name: 'tim' }; const result = RowUtils.isRowSelected(keyProps, null, null, rowData, 0); expect(result).toBe(true); }); it('should return false', () => { - const keyProps = {rowKey: 'name', values: ['tim', 'willim', 'deigo']}; - const rowData = {id: 1, name: 'john'}; + const keyProps = { rowKey: 'name', values: ['tim', 'willim', 'deigo'] }; + const rowData = { id: 1, name: 'john' }; const result = RowUtils.isRowSelected(keyProps, null, null, rowData, 0); expect(result).toBe(false); }); @@ -32,13 +32,13 @@ describe('RowUtils Tests', () => { describe('using `isSelectedKey`', () => { it('should return true', () => { - const rowData = {id: 1, name: 'tim', isSelected: true}; + const rowData = { id: 1, name: 'tim', isSelected: true }; const result = RowUtils.isRowSelected(null, null, 'isSelected', rowData, 0); expect(result).toBe(true); }); it('should return false', () => { - const rowData = {id: 1, name: 'tim', isSelected: false}; + const rowData = { id: 1, name: 'tim', isSelected: false }; const result = RowUtils.isRowSelected(null, null, 'isSelected', rowData, 0); expect(result).toBe(false); }); diff --git a/packages/react-data-grid/src/__tests__/Viewport.spec.js b/packages/react-data-grid/src/__tests__/Viewport.spec.js index b02b22433a..ff9929d353 100644 --- a/packages/react-data-grid/src/__tests__/Viewport.spec.js +++ b/packages/react-data-grid/src/__tests__/Viewport.spec.js @@ -1,9 +1,9 @@ import React from 'react'; import Viewport from '../Viewport'; import Canvas from '../Canvas'; -import { shallow} from 'enzyme'; +import { shallow } from 'enzyme'; import helpers from '../helpers/test/GridPropHelpers'; -import {SCROLL_DIRECTION} from '../utils/viewportUtils'; +import { SCROLL_DIRECTION } from '../utils/viewportUtils'; const viewportProps = { rowOffsetHeight: 0, @@ -86,7 +86,7 @@ describe('', () => { const scrollTop = 200; const wrapper = shallow(); const canvas = wrapper.find(Canvas); - canvas.props().onScroll({ scrollTop, scrollLeft}); + canvas.props().onScroll({ scrollTop, scrollLeft }); expect(wrapper.state()).toEqual({ colOverscanEndIdx: helpers.columns.length, colOverscanStartIdx: 0, @@ -118,7 +118,7 @@ describe('', () => { width: 100 }; const updatedColumns = helpers.columns.concat(extraColumn); - const newProps = Object.assign({}, viewportProps, {columnMetrics: Object.assign({}, viewportProps.columnMetrics, {columns: updatedColumns})}); + const newProps = Object.assign({}, viewportProps, { columnMetrics: Object.assign({}, viewportProps.columnMetrics, { columns: updatedColumns }) }); wrapper.setProps(newProps); expect(wrapper.state()).toEqual({ colOverscanEndIdx: updatedColumns.length, @@ -140,7 +140,7 @@ describe('', () => { it('should update when given height changed', () => { const wrapper = shallow(); const newHeight = 1000; - const newProps = Object.assign({}, viewportProps, {minHeight: newHeight}); + const newProps = Object.assign({}, viewportProps, { minHeight: newHeight }); wrapper.setProps(newProps); expect(wrapper.state()).toEqual({ colOverscanEndIdx: helpers.columns.length, diff --git a/packages/react-data-grid/src/focusableComponentWrapper.js b/packages/react-data-grid/src/focusableComponentWrapper.js index 301b04696d..aae2aa5069 100644 --- a/packages/react-data-grid/src/focusableComponentWrapper.js +++ b/packages/react-data-grid/src/focusableComponentWrapper.js @@ -18,7 +18,7 @@ const focusableComponentWrapper = WrappedComponent => { componentWillReceiveProps(nextProps) { const isScrolling = WrappedComponent.isScrolling(nextProps); if (isScrolling && !this.state.isScrolling) { - this.setState({isScrolling: isScrolling}); + this.setState({ isScrolling: isScrolling }); } } @@ -33,7 +33,7 @@ const focusableComponentWrapper = WrappedComponent => { checkFocus() { if (WrappedComponent.isSelected(this.props) && this.state.isScrolling) { this.focus(); - this.setState({isScrolling: false}); + this.setState({ isScrolling: false }); } } diff --git a/packages/react-data-grid/src/getWindowSize.js b/packages/react-data-grid/src/getWindowSize.js index ca1882af9e..30c96b8bd2 100644 --- a/packages/react-data-grid/src/getWindowSize.js +++ b/packages/react-data-grid/src/getWindowSize.js @@ -18,7 +18,7 @@ function getWindowSize() { height = document.body.clientHeight; } - return {width, height}; + return { width, height }; } module.exports = getWindowSize; diff --git a/packages/react-data-grid/src/masks/InteractionMasks.js b/packages/react-data-grid/src/masks/InteractionMasks.js index 86c056fbef..608f51ea47 100644 --- a/packages/react-data-grid/src/masks/InteractionMasks.js +++ b/packages/react-data-grid/src/masks/InteractionMasks.js @@ -20,7 +20,7 @@ import { selectedRangeIsSingleCell } from '../utils/SelectedCellUtils'; import { isFunction } from 'common/utils'; -import {getSize, getColumn, isFrozen} from '../ColumnUtils'; +import { getSize, getColumn, isFrozen } from '../ColumnUtils'; import * as keyCodes from '../KeyCodes'; import { CellNavigationMode, EventTypes } from 'common/constants'; diff --git a/packages/react-data-grid/src/masks/SelectionMask.js b/packages/react-data-grid/src/masks/SelectionMask.js index b6cf29edfe..d0c21c1d9b 100644 --- a/packages/react-data-grid/src/masks/SelectionMask.js +++ b/packages/react-data-grid/src/masks/SelectionMask.js @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import CellMask from './CellMask'; -import {isFrozen, getColumn} from '../ColumnUtils'; +import { isFrozen, getColumn } from '../ColumnUtils'; import zIndexes from 'common/constants/zIndexes'; function SelectionMask({ selectedPosition, innerRef, getSelectedDimensions, children }) { diff --git a/packages/react-data-grid/src/masks/SelectionRangeMask.js b/packages/react-data-grid/src/masks/SelectionRangeMask.js index e76eb279a0..d02449ec30 100644 --- a/packages/react-data-grid/src/masks/SelectionRangeMask.js +++ b/packages/react-data-grid/src/masks/SelectionRangeMask.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import { getSelectedRangeDimensions } from '../utils/SelectedCellUtils'; import CellMask from './CellMask'; -function SelectionRangeMask({ selectedRange, columns, rowHeight, children}) { +function SelectionRangeMask({ selectedRange, columns, rowHeight, children }) { const dimensions = getSelectedRangeDimensions({ selectedRange, columns, rowHeight }); return ( rowIdx * rowHeight; diff --git a/packages/react-data-grid/src/utils/viewportUtils.js b/packages/react-data-grid/src/utils/viewportUtils.js index 39c3f6e620..278fc0a776 100644 --- a/packages/react-data-grid/src/utils/viewportUtils.js +++ b/packages/react-data-grid/src/utils/viewportUtils.js @@ -1,4 +1,4 @@ -import {getSize, getColumn, isFrozen} from '../ColumnUtils'; +import { getSize, getColumn, isFrozen } from '../ColumnUtils'; export const OVERSCAN_ROWS = 2; @@ -57,11 +57,11 @@ const getTotalFrozenColumnWidth = (columns) => { }; const getColumnCountForWidth = (columns, initialWidth, colVisibleStartIdx) => { - const initialValue = {width: initialWidth, count: 0}; - return columns.slice(colVisibleStartIdx).reduce(({width, count}, column) => { + const initialValue = { width: initialWidth, count: 0 }; + return columns.slice(colVisibleStartIdx).reduce(({ width, count }, column) => { const remainingWidth = width - column.width; const columnCount = remainingWidth >= 0 ? count + 1 : count; - return {width: remainingWidth, count: columnCount}; + return { width: remainingWidth, count: columnCount }; }, initialValue); }; @@ -79,7 +79,7 @@ export const getNonFrozenVisibleColStartIdx = (columns, scrollLeft) => { }; export const getNonFrozenRenderedColumnCount = (columnMetrics, viewportDomWidth, scrollLeft) => { - const {columns} = columnMetrics; + const { columns } = columnMetrics; if (getSize(columns) === 0) { return 0; } @@ -91,7 +91,7 @@ export const getNonFrozenRenderedColumnCount = (columnMetrics, viewportDomWidth, const scrolledFrozenWidth = totalFrozenColumnWidth + scrollLeft; const firstColumnHiddenWidth = scrolledFrozenWidth > firstColumn.left ? scrolledFrozenWidth - firstColumn.left : 0; const initialWidth = viewportWidth - totalFrozenColumnWidth + firstColumnHiddenWidth; - const {count} = getColumnCountForWidth(columnMetrics.columns, initialWidth, colVisibleStartIdx); + const { count } = getColumnCountForWidth(columnMetrics.columns, initialWidth, colVisibleStartIdx); return count; };