Skip to content

Commit 4399cbb

Browse files
committed
prettier code style
1 parent 1a62d2c commit 4399cbb

13 files changed

+137
-370
lines changed

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.doc
2+
.storybook
3+
es
4+
lib

HISTORY.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# History
2-
----
2+
3+
---
34

45
## 6.9.0 / 2019-10-18
56

@@ -104,7 +105,7 @@ Fix https://github.com/ant-design/ant-design/issues/2625
104105

105106
## 4.4.1 / 2016-07-24
106107

107-
- Fix row expand of key 0 record. (ant-design/ant-design#2471)
108+
- Fix row expand of key 0 record. (ant-design/ant-design#2471)
108109

109110
## 4.4.0 / 2016-07-19
110111

LICENSE.md

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,8 @@ MIT LICENSE
22

33
Copyright (c) 2015-present Alipay.com, https://www.alipay.com/
44

5-
Permission is hereby granted, free of charge, to any person obtaining
6-
a copy of this software and associated documentation files (the
7-
"Software"), to deal in the Software without restriction, including
8-
without limitation the rights to use, copy, modify, merge, publish,
9-
distribute, sublicense, and/or sell copies of the Software, and to
10-
permit persons to whom the Software is furnished to do so, subject to
11-
the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
126

13-
The above copyright notice and this permission notice shall be
14-
included in all copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
158

16-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22

33
React table component with useful functions.
44

5-
[![NPM version][npm-image]][npm-url]
6-
[![build status][travis-image]][travis-url]
7-
[![Test coverage][codecov-image]][codecov-url]
8-
[![Dependencies][david-image]][david-url]
9-
[![DevDependencies][david-dev-image]][david-dev-url]
10-
[![npm download][download-image]][download-url]
11-
[![bundle size][bundlephobia-image]][bundlephobia-url]
5+
[![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] [![Dependencies][david-image]][david-url] [![DevDependencies][david-dev-image]][david-dev-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url]
126

137
[npm-image]: http://img.shields.io/npm/v/rc-table.svg?style=flat-square
148
[npm-url]: http://npmjs.org/package/rc-table

examples/react-dnd.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ class Demo extends React.Component {
148148
this.setState(prevState =>
149149
update(prevState, {
150150
data: {
151-
$splice: [[dragIndex, 1], [hoverIndex, 0, dragRow]],
151+
$splice: [
152+
[dragIndex, 1],
153+
[hoverIndex, 0, dragRow],
154+
],
152155
},
153156
}),
154157
);

examples/title-and-footer.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,20 @@ const Demo = () => {
6363
title={currentData => <div>Title: {currentData.length} items</div>}
6464
footer={currentData => <div>Footer: {currentData.length} items</div>}
6565
summary={currentData => (
66-
<>
67-
<tr>
68-
<th colSpan={6}>Summary</th>
69-
</tr>
70-
<tr>
71-
<td>-</td>
72-
<td>-</td>
73-
<td>-</td>
74-
<td>{currentData.reduce((total, item) => total + item.value, 0)}</td>
75-
<td>{currentData.reduce((total, item) => total + item.value2, 0)}</td>
76-
<td>-</td>
77-
</tr>
78-
</>
79-
)}
66+
<>
67+
<tr>
68+
<th colSpan={6}>Summary</th>
69+
</tr>
70+
<tr>
71+
<td>-</td>
72+
<td>-</td>
73+
<td>-</td>
74+
<td>{currentData.reduce((total, item) => total + item.value, 0)}</td>
75+
<td>{currentData.reduce((total, item) => total + item.value2, 0)}</td>
76+
<td>-</td>
77+
</tr>
78+
</>
79+
)}
8080
/>
8181
</div>
8282
);

src/Header/HeaderRow.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ function HeaderRow<RecordType>({
3434

3535
let rowProps: React.HTMLAttributes<HTMLElement>;
3636
if (onHeaderRow) {
37-
rowProps = onHeaderRow(cells.map(cell => cell.column), index);
37+
rowProps = onHeaderRow(
38+
cells.map(cell => cell.column),
39+
index,
40+
);
3841
}
3942

4043
const columnsKey = getColumnsKey(cells.map(cell => cell.column));

src/interface.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ export interface ColumnType<RecordType> extends ColumnSharedType<RecordType> {
9191

9292
export type ColumnsType<RecordType = unknown> = (
9393
| ColumnGroupType<RecordType>
94-
| ColumnType<RecordType>)[];
94+
| ColumnType<RecordType>
95+
)[];
9596

9697
export type GetRowKey<RecordType> = (record: RecordType, index?: number) => Key;
9798

tests/ExpandRow.spec.js

Lines changed: 25 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ describe('Table.Expand', () => {
1313
{ title: 'Age', dataIndex: 'age', key: 'age' },
1414
];
1515

16-
const sampleData = [{ key: 0, name: 'Lucy', age: 27 }, { key: 1, name: 'Jack', age: 28 }];
16+
const sampleData = [
17+
{ key: 0, name: 'Lucy', age: 27 },
18+
{ key: 1, name: 'Jack', age: 28 },
19+
];
1720

1821
const createTable = props => <Table columns={sampleColumns} data={sampleData} {...props} />;
1922

@@ -130,11 +133,7 @@ describe('Table.Expand', () => {
130133
}),
131134
);
132135
act(() => {
133-
wrapper
134-
.find('ResizeObserver')
135-
.first()
136-
.props()
137-
.onResize({ width: 1128 });
136+
wrapper.find('ResizeObserver').first().props().onResize({ width: 1128 });
138137
});
139138
wrapper.update();
140139
expect(wrapper.render()).toMatchSnapshot();
@@ -151,10 +150,7 @@ describe('Table.Expand', () => {
151150
}),
152151
);
153152
expect(
154-
wrapper
155-
.find('tbody tr td')
156-
.at(1)
157-
.hasClass('rc-table-row-expand-icon-cell'),
153+
wrapper.find('tbody tr td').at(1).hasClass('rc-table-row-expand-icon-cell'),
158154
).toBeTruthy();
159155
});
160156

@@ -212,12 +208,7 @@ describe('Table.Expand', () => {
212208
}),
213209
);
214210
expect(wrapper.find('tbody tr')).toHaveLength(3);
215-
expect(
216-
wrapper
217-
.find('tbody tr')
218-
.at(2)
219-
.hasClass('rc-table-expanded-row'),
220-
).toBeTruthy();
211+
expect(wrapper.find('tbody tr').at(2).hasClass('rc-table-expanded-row')).toBeTruthy();
221212
});
222213

223214
it('controlled by expandedRowKeys', () => {
@@ -228,33 +219,13 @@ describe('Table.Expand', () => {
228219
}),
229220
);
230221
expect(wrapper.find('tbody tr')).toHaveLength(3);
231-
expect(
232-
wrapper
233-
.find('tbody tr')
234-
.at(1)
235-
.hasClass('rc-table-expanded-row'),
236-
).toBeTruthy();
222+
expect(wrapper.find('tbody tr').at(1).hasClass('rc-table-expanded-row')).toBeTruthy();
237223

238224
wrapper.setProps({ expandedRowKeys: [1] });
239225
expect(wrapper.find('tbody tr')).toHaveLength(4);
240-
expect(
241-
wrapper
242-
.find('tbody tr')
243-
.at(1)
244-
.hasClass('rc-table-expanded-row'),
245-
).toBeTruthy();
246-
expect(
247-
wrapper
248-
.find('tbody tr')
249-
.at(1)
250-
.props().style.display,
251-
).toEqual('none');
252-
expect(
253-
wrapper
254-
.find('tbody tr')
255-
.at(3)
256-
.hasClass('rc-table-expanded-row'),
257-
).toBeTruthy();
226+
expect(wrapper.find('tbody tr').at(1).hasClass('rc-table-expanded-row')).toBeTruthy();
227+
expect(wrapper.find('tbody tr').at(1).props().style.display).toEqual('none');
228+
expect(wrapper.find('tbody tr').at(3).hasClass('rc-table-expanded-row')).toBeTruthy();
258229
});
259230

260231
it('renders expend row class correctly', () => {
@@ -269,12 +240,7 @@ describe('Table.Expand', () => {
269240
}),
270241
);
271242

272-
expect(
273-
wrapper
274-
.find('tbody tr')
275-
.at(1)
276-
.hasClass('expand-row-test-class-name'),
277-
).toBeTruthy();
243+
expect(wrapper.find('tbody tr').at(1).hasClass('expand-row-test-class-name')).toBeTruthy();
278244
});
279245

280246
it('fires expand change event', () => {
@@ -287,16 +253,10 @@ describe('Table.Expand', () => {
287253
},
288254
}),
289255
);
290-
wrapper
291-
.find('.rc-table-row-expand-icon')
292-
.first()
293-
.simulate('click');
256+
wrapper.find('.rc-table-row-expand-icon').first().simulate('click');
294257
expect(onExpand).toHaveBeenCalledWith(true, sampleData[0]);
295258

296-
wrapper
297-
.find('.rc-table-row-expand-icon')
298-
.first()
299-
.simulate('click');
259+
wrapper.find('.rc-table-row-expand-icon').first().simulate('click');
300260
expect(onExpand).toHaveBeenCalledWith(false, sampleData[0]);
301261
});
302262

@@ -308,10 +268,7 @@ describe('Table.Expand', () => {
308268
onExpandedRowsChange,
309269
}),
310270
);
311-
wrapper
312-
.find('.rc-table-row-expand-icon')
313-
.first()
314-
.simulate('click');
271+
wrapper.find('.rc-table-row-expand-icon').first().simulate('click');
315272
expect(onExpandedRowsChange).toHaveBeenCalledWith([0]);
316273
});
317274

@@ -339,16 +296,10 @@ describe('Table.Expand', () => {
339296
},
340297
}),
341298
);
342-
wrapper
343-
.find('tbody tr')
344-
.first()
345-
.simulate('click');
299+
wrapper.find('tbody tr').first().simulate('click');
346300
expect(onExpand).toHaveBeenCalledWith(true, sampleData[0]);
347301

348-
wrapper
349-
.find('tbody tr')
350-
.first()
351-
.simulate('click');
302+
wrapper.find('tbody tr').first().simulate('click');
352303
expect(onExpand).toHaveBeenCalledWith(false, sampleData[0]);
353304
});
354305

@@ -410,30 +361,14 @@ describe('Table.Expand', () => {
410361
}),
411362
);
412363
expect(wrapper.find('.rc-table-expanded-row').length).toBe(0);
413-
wrapper
414-
.find('.custom-expand-icon')
415-
.first()
416-
.simulate('click');
364+
wrapper.find('.custom-expand-icon').first().simulate('click');
417365
expect(onExpand).toHaveBeenCalledWith(true, data[0]);
418366
expect(onExpand).toHaveBeenCalledTimes(1);
419-
expect(
420-
wrapper
421-
.find('.rc-table-expanded-row')
422-
.first()
423-
.getDOMNode().style.display,
424-
).toBe('');
425-
wrapper
426-
.find('.custom-expand-icon')
427-
.first()
428-
.simulate('click');
367+
expect(wrapper.find('.rc-table-expanded-row').first().getDOMNode().style.display).toBe('');
368+
wrapper.find('.custom-expand-icon').first().simulate('click');
429369
expect(onExpand).toHaveBeenCalledWith(false, data[0]);
430370
expect(onExpand).toHaveBeenCalledTimes(2);
431-
expect(
432-
wrapper
433-
.find('.rc-table-expanded-row')
434-
.first()
435-
.getDOMNode().style.display,
436-
).toBe('none');
371+
expect(wrapper.find('.rc-table-expanded-row').first().getDOMNode().style.display).toBe('none');
437372
});
438373

439374
// https://github.com/ant-design/ant-design/issues/23894
@@ -450,16 +385,10 @@ describe('Table.Expand', () => {
450385
data,
451386
}),
452387
);
453-
wrapper
454-
.find('.rc-table-row-expand-icon')
455-
.first()
456-
.simulate('click');
388+
wrapper.find('.rc-table-row-expand-icon').first().simulate('click');
457389
expect(onExpand).toHaveBeenCalledWith(true, data[0]);
458390
expect(onExpand).toHaveBeenCalledTimes(1);
459-
wrapper
460-
.find('.rc-table-row-expand-icon')
461-
.first()
462-
.simulate('click');
391+
wrapper.find('.rc-table-row-expand-icon').first().simulate('click');
463392
expect(onExpand).toHaveBeenCalledWith(false, data[0]);
464393
expect(onExpand).toHaveBeenCalledTimes(2);
465394
});
@@ -486,16 +415,10 @@ describe('Table.Expand', () => {
486415
data,
487416
}),
488417
);
489-
wrapper
490-
.find('.custom-expand-icon')
491-
.first()
492-
.simulate('click');
418+
wrapper.find('.custom-expand-icon').first().simulate('click');
493419
expect(onExpand).toHaveBeenCalledWith(true, data[0]);
494420
expect(onExpand).toHaveBeenCalledTimes(1);
495-
wrapper
496-
.find('.custom-expand-icon')
497-
.first()
498-
.simulate('click');
421+
wrapper.find('.custom-expand-icon').first().simulate('click');
499422
expect(onExpand).toHaveBeenCalledWith(false, data[0]);
500423
expect(onExpand).toHaveBeenCalledTimes(2);
501424
});

0 commit comments

Comments
 (0)