Skip to content

Commit 9180a1b

Browse files
committed
npm updates: eslint-config-airbnb
1 parent ad7027c commit 9180a1b

File tree

6 files changed

+93
-44
lines changed

6 files changed

+93
-44
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
es
2+
lib
3+
umd
4+
demo/dist

demo/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const rows = [
1414
{
1515
name: 'Marlon Brando',
1616
role: <a href="https://en.wikipedia.org/wiki/Vito_Corleone">Vito Corleone</a>,
17-
image: <img src="https://upload.wikimedia.org/wikipedia/en/2/21/Godfather15_flip.jpg" alt="Vito Corleone" />
17+
image: <img src="https://upload.wikimedia.org/wikipedia/en/2/21/Godfather15_flip.jpg" alt="Vito Corleone" />,
1818
},
1919
{
2020
image: <img src="https://upload.wikimedia.org/wikipedia/en/d/df/Michaelcoreleone.jpg" alt="Al Pacino" />,
@@ -44,8 +44,8 @@ const rows = [
4444
];
4545
const keyGetter = row => row.name;
4646

47-
const Demo = () =>
48-
(<div>
47+
const Demo = () => (
48+
<div>
4949
<h1>react-hyper-responsive-table demo</h1>
5050
<p>The breakpoint of this demo is set to 578 pixels.</p>
5151
<ReactHyperResponsiveTable

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"devDependencies": {
1111
"babel-eslint": "^8.0.1",
1212
"eslint": "^4.8.0",
13-
"eslint-config-airbnb": "^15.1.0",
13+
"eslint-config-airbnb": "^16.0.0",
1414
"eslint-plugin-import": "^2.7.0",
15-
"eslint-plugin-jsx-a11y": "^5.1.1",
15+
"eslint-plugin-jsx-a11y": "^6.0.2",
1616
"eslint-plugin-react": "^7.4.0",
1717
"gh-pages": "^1.0.0",
1818
"match-media-mock": "^0.1.0",
@@ -48,7 +48,7 @@
4848
"build": "nwb build-react-component",
4949
"clean": "nwb clean-module && nwb clean-demo",
5050
"gh-pages": "gh-pages -d demo/dist",
51-
"lint": "eslint src tests",
51+
"lint": "eslint .",
5252
"start": "nwb serve-react-demo",
5353
"test": "nwb test-react",
5454
"test:coverage": "nwb test-react --coverage",

src/index.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,34 +108,41 @@ class HyperResponsiveTable extends Component {
108108
};
109109

110110
render() {
111-
const { tableStyling, headers, rows, keyGetter } = this.props;
111+
const {
112+
tableStyling,
113+
headers,
114+
rows,
115+
keyGetter,
116+
} = this.props;
112117
const { narrow } = this.state;
113118

114119
const dataKeys = Object.keys(headers);
115120

116121
if (narrow) {
117-
return (<table {...getClassNameOrStyleProps(tableStyling, this.state)}>
118-
{rows.map(row =>
119-
(<tbody key={keyGetter(row)}>
120-
{dataKeys.map(key => <tr key={key}><th scope="row">{headers[key]}</th><td>{row[key]}</td></tr>)}
121-
</tbody>))
122-
}
123-
</table>);
122+
return (
123+
<table {...getClassNameOrStyleProps(tableStyling, this.state)}>
124+
{rows.map(row => (
125+
<tbody key={keyGetter(row)}>
126+
{dataKeys.map(key => <tr key={key}><th scope="row">{headers[key]}</th><td>{row[key]}</td></tr>)}
127+
</tbody>))
128+
}
129+
</table>);
124130
}
125131

126-
return (<table {...getClassNameOrStyleProps(tableStyling, this.state)}>
127-
<thead>
128-
<tr>
129-
{ dataKeys.map(key => <th key={key} scope="col">{headers[key]}</th>) }
130-
</tr>
131-
</thead>
132-
<tbody>
133-
{rows.map(row =>
134-
(<tr key={keyGetter(row)}>
135-
{dataKeys.map(key => <td key={key}>{row[key]}</td>)}
136-
</tr>))}
137-
</tbody>
138-
</table>);
132+
return (
133+
<table {...getClassNameOrStyleProps(tableStyling, this.state)}>
134+
<thead>
135+
<tr>
136+
{ dataKeys.map(key => <th key={key} scope="col">{headers[key]}</th>) }
137+
</tr>
138+
</thead>
139+
<tbody>
140+
{rows.map(row => (
141+
<tr key={keyGetter(row)}>
142+
{dataKeys.map(key => <td key={key}>{row[key]}</td>)}
143+
</tr>))}
144+
</tbody>
145+
</table>);
139146
}
140147
}
141148

tests/index-test.js

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ describe('Component', () => {
3838

3939
it('low integer breakpoint should give wide styled table', () => {
4040
const breakpoint = 300;
41-
const props = { headers, rows, keyGetter, breakpoint };
41+
const props = {
42+
headers,
43+
rows,
44+
keyGetter,
45+
breakpoint,
46+
};
4247

4348
render(<Component {...props} />, node, () => {
4449
expect(node.querySelectorAll('table').length).toEqual(1);
@@ -50,7 +55,12 @@ describe('Component', () => {
5055

5156
it('high integer breakpoint should give narrow styled table', () => {
5257
const breakpoint = 3000;
53-
const props = { headers, rows, keyGetter, breakpoint };
58+
const props = {
59+
headers,
60+
rows,
61+
keyGetter,
62+
breakpoint,
63+
};
5464

5565
render(<Component {...props} />, node, () => {
5666
expect(node.querySelectorAll('table').length).toEqual(1);
@@ -62,7 +72,12 @@ describe('Component', () => {
6272

6373
it('low media query breakpoint should give wide styled table', () => {
6474
const breakpoint = 'screen and (min-width: 1000px)';
65-
const props = { headers, rows, keyGetter, breakpoint };
75+
const props = {
76+
headers,
77+
rows,
78+
keyGetter,
79+
breakpoint,
80+
};
6681

6782
render(<Component {...props} />, node, () => {
6883
expect(node.querySelectorAll('table').length).toEqual(1);
@@ -74,7 +89,12 @@ describe('Component', () => {
7489

7590
it('tableStyling function value should give dynamic class when string is returned', () => {
7691
const tableStyling = opts => (opts.narrow ? 'narrow' : 'wide');
77-
const props = { headers, rows, keyGetter, tableStyling };
92+
const props = {
93+
headers,
94+
rows,
95+
keyGetter,
96+
tableStyling,
97+
};
7898

7999
render(<Component {...props} breakpoint={3000} />, node, () => {
80100
expect(node.querySelectorAll('table.narrow').length).toEqual(1);
@@ -92,7 +112,13 @@ describe('Component', () => {
92112
it('tableStyling object value should give style attribute', () => {
93113
const breakpoint = 3000;
94114
const tableStyling = { color: 'red' };
95-
const props = { headers, rows, keyGetter, breakpoint, tableStyling };
115+
const props = {
116+
headers,
117+
rows,
118+
keyGetter,
119+
breakpoint,
120+
tableStyling,
121+
};
96122

97123
render(<Component {...props} />, node, () => {
98124
const table = node.querySelector('table');
@@ -104,7 +130,13 @@ describe('Component', () => {
104130
it('wide to narrow change should trigger tableStyling function call', (done) => {
105131
const breakpoint = 1000;
106132
const tableStyling = opts => (opts.narrow ? 'narrow' : 'wide');
107-
const props = { headers, rows, keyGetter, breakpoint, tableStyling };
133+
const props = {
134+
headers,
135+
rows,
136+
keyGetter,
137+
breakpoint,
138+
tableStyling,
139+
};
108140

109141
render(<Component {...props} />, node, () => {
110142
const table = node.querySelector('table');
@@ -123,7 +155,13 @@ describe('Component', () => {
123155
it('invalid tableStyling should give no class or style attribute', () => {
124156
const breakpoint = 1000;
125157
const tableStyling = 1234;
126-
const props = { headers, rows, keyGetter, breakpoint, tableStyling };
158+
const props = {
159+
headers,
160+
rows,
161+
keyGetter,
162+
breakpoint,
163+
tableStyling,
164+
};
127165

128166
render(<Component {...props} />, node, () => {
129167
const table = node.querySelector('table');

0 commit comments

Comments
 (0)