Skip to content

Commit 2241918

Browse files
committed
fix the rest of the lint
1 parent 20b073e commit 2241918

File tree

7 files changed

+96
-77
lines changed

7 files changed

+96
-77
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules/
2+
/dist/

.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"react/jsx-uses-react": 2,
2424
"react/jsx-uses-vars": 2,
2525
"react/react-in-jsx-scope": 2,
26+
"react/jsx-no-bind": 0,
27+
"react/jsx-filename-extension": 0,
28+
"prefer-template": 0,
2629
"indent": [2, 2, {"SwitchCase": 1}],
2730
},
2831
"extends": "eslint-config-airbnb",

src/components/DataTable.js

+26-21
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export default class DataTable extends React.Component {
1111
this.resize = this.resize.bind(this);
1212
}
1313

14-
resize() {
15-
this.forceUpdate();
16-
}
17-
1814
componentDidMount() {
1915
window.addEventListener('resize', this.resize);
2016
}
@@ -23,36 +19,40 @@ export default class DataTable extends React.Component {
2319
window.removeEventListener('resize', this.resize);
2420
}
2521

22+
resize() {
23+
this.forceUpdate();
24+
}
25+
2626
prevPage() {
27-
let prev = this.state.page - 1;
27+
const prev = this.state.page - 1;
2828
this.setState({
2929
page: prev < 0 ? 0 : prev,
3030
});
3131
}
3232

3333
nextPage() {
34-
let props = this.props,
35-
limit = props.limit,
36-
length = props.values.length,
37-
page = this.state.page,
38-
next = page + 1;
34+
const props = this.props;
35+
const limit = props.limit;
36+
const length = props.values.length;
37+
const page = this.state.page;
38+
const next = page + 1;
3939

4040
this.setState({
4141
page: next >= Math.ceil(length / limit) ? page : next,
4242
});
4343
}
4444

4545
render() {
46-
let props = this.props,
47-
length = props.values.length,
48-
limit = props.limit,
49-
page = this.state.page,
50-
start = page * limit,
51-
end = start + limit,
52-
values = props.values.slice(start, end),
53-
columns = Object.keys(values[0] || {}),
54-
standardColumnWidth = 100,
55-
wide = (columns.length * standardColumnWidth < window.innerWidth);
46+
const props = this.props;
47+
const length = props.values.length;
48+
const limit = props.limit;
49+
const page = this.state.page;
50+
const start = page * limit;
51+
const end = start + limit;
52+
const values = props.values.slice(start, end);
53+
const columns = Object.keys(values[0] || {});
54+
const standardColumnWidth = 100;
55+
const wide = (columns.length * standardColumnWidth < window.innerWidth);
5656

5757
return (
5858
<div>
@@ -65,12 +65,17 @@ export default class DataTable extends React.Component {
6565
</tr>
6666
</thead>);
6767
}
68+
return undefined;
6869
})()}
6970

7071
<tbody>
7172
{values.map((val, i) => (
7273
<tr key={i}>
73-
{columns.map((col, j) => <td key={j}>{wide ? '' : <span>{col + ':'}</span>} {val[col]}</td>)}
74+
{columns.map((col, j) => (
75+
<td key={j}>
76+
{wide ? '' : <span>{col + ':'}</span>} {val[col]}
77+
</td>
78+
))}
7479
</tr>
7580
))}
7681
</tbody>

src/components/MainView.js

+42-34
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class MainView extends React.Component {
1414

1515
constructor(props) {
1616
super(props);
17-
let data = [];
17+
const data = [];
1818
this.state = {
1919
data,
2020
filteredData: data,
@@ -67,15 +67,14 @@ export default class MainView extends React.Component {
6767
download: true,
6868
header: true,
6969
dynamicTyping: true,
70-
complete: function (results) {
70+
complete: results => {
7171
this.parseCSV(results);
72-
}.bind(this),
73-
error: function (err, file, inputElem, reason)
74-
{
72+
},
73+
error: () => {
7574
this.setState({
7675
isError: true,
7776
});
78-
}.bind(this),
77+
},
7978
});
8079
}
8180

@@ -87,14 +86,18 @@ export default class MainView extends React.Component {
8786
}
8887

8988
export(json) {
90-
let filename = 'data.csv',
91-
csv = Papa.unparse(json),
92-
blob = new Blob([csv], { type: 'text/csv' });
89+
const filename = 'data.csv';
90+
const csv = Papa.unparse(json);
91+
const blob = new Blob([csv], { type: 'text/csv' });
92+
9393
if (window.navigator.msSaveOrOpenBlob) {
9494
window.navigator.msSaveBlob(blob, filename);
95-
} else {
96-
let a = window.document.createElement('a');
97-
a.href = window.URL.createObjectURL(blob, { type: 'text/plain' });
95+
}
96+
else {
97+
const a = window.document.createElement('a');
98+
a.href = window.URL.createObjectURL(blob, {
99+
type: 'text/plain',
100+
});
98101
a.download = filename;
99102
document.body.appendChild(a);
100103
a.click();
@@ -109,41 +112,46 @@ export default class MainView extends React.Component {
109112
}
110113

111114
render() {
112-
const data = this.state.data,
113-
filteredData = this.state.filteredData,
114-
dataSource = encodeURI(this.state.dataSource),
115-
isError = this.state.isError;
115+
const data = this.state.data;
116+
const filteredData = this.state.filteredData;
117+
const dataSource = encodeURI(this.state.dataSource);
118+
const isError = this.state.isError;
116119

117120
return (
118121
<div>
119122
<Navbar />
120-
<main className="container">
123+
<main className="container">
121124
<div className={'row ' + (isError ? '' : 'hidden')}>
122125
<div className="col-sm-12">
123126
<div className="alert alert-danger alert-dismissible" role="alert">
124-
<strong>Oh snap!</strong> We had some issues resolving the data source <a className="wrap" href={dataSource}>{dataSource}</a>.
127+
<strong>Oh snap!</strong>
128+
We had some issues resolving the data source
129+
<a className="wrap" href={dataSource}>{dataSource}</a>.
125130
</div>
126131
</div>
127132
</div>
128-
<div className="row">
129-
<div className="col-sm-12">
130-
<div className="row">
131-
<div className="col-xs-8 col-sm-4">
132-
<Search data={data} onFilteredData={this.filterData.bind(this)} />
133-
</div>
134-
<div className="col-xs-4 pull-right">
135-
<a className="btn btn-primary pull-right" onClick={this.export.bind(this, filteredData)}>Export to CSV</a>
133+
<div className="row">
134+
<div className="col-sm-12">
135+
<div className="row">
136+
<div className="col-xs-8 col-sm-4">
137+
<Search data={data} onFilteredData={this.filterData.bind(this)} />
138+
</div>
139+
<div className="col-xs-4 pull-right">
140+
<a
141+
className="btn btn-primary pull-right"
142+
onClick={this.export.bind(this, filteredData)}
143+
>Export to CSV</a>
144+
</div>
136145
</div>
137-
</div>
138-
<hr />
139-
<div className="row">
140-
<div className="col-xs-12">
141-
<DataTable limit={20} values={filteredData} />
146+
<hr />
147+
<div className="row">
148+
<div className="col-xs-12">
149+
<DataTable limit={20} values={filteredData} />
150+
</div>
142151
</div>
143152
</div>
144-
</div>
145-
</div>
146-
</main>
153+
</div>
154+
</main>
147155
</div>
148156
);
149157
}

src/components/Navbar.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ export default class Navbar extends React.Component {
1515
render() {
1616
return (
1717
<nav className="navbar navbar-fixed-top">
18-
<div className="container">
19-
<div className="navbar-header">
20-
<a className="navbar-brand" href="#">
21-
<img className="img-responsive" src={logoURL} alt="" />
22-
</a>
23-
</div>
24-
</div>
25-
</nav>
18+
<div className="container">
19+
<div className="navbar-header">
20+
<a className="navbar-brand">
21+
<img className="img-responsive" src={logoURL} alt="" />
22+
</a>
23+
</div>
24+
</div>
25+
</nav>
2626
);
2727
}
2828
}

src/components/Search.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ const propTypes = {
77
};
88

99
export default class Search extends React.Component {
10-
constructor(props) {
11-
super(props);
12-
}
13-
1410
onChange(e) {
15-
var value = e.target.value;
16-
this.props.onFilteredData(_.filter(this.props.data, function (row) {
17-
return _.find(_.values(row), function (val) {
18-
return (val.toString().toLowerCase()).indexOf(value.toLowerCase()) !== -1;
19-
});
20-
}));
11+
const value = e.target.value;
12+
this.props.onFilteredData(_.filter(this.props.data, (row) =>
13+
_.find(_.values(row), (val) =>
14+
(val.toString().toLowerCase()).indexOf(value.toLowerCase()) !== -1
15+
)
16+
));
2117
}
2218

2319
render() {
2420
return (<div>
25-
<input className="form-control" placeholder="Enter a Keyword, City, or State" onChange={this.onChange.bind(this)} />
21+
<input
22+
className="form-control"
23+
placeholder="Enter a Keyword, City, or State"
24+
onChange={this.onChange.bind(this)}
25+
/>
2626
</div>);
2727
}
2828
}

webpack.make.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ module.exports = function makeWebpackConfig(options) {
153153

154154
// JSX LOADER
155155
// Transpile .jsx files using babel-loader
156-
var jsxLoader = {
156+
const jsxLoader = {
157157
test: /\.(js|jsx)$/,
158158
loader: 'babel',
159159
exclude: [
@@ -179,7 +179,7 @@ module.exports = function makeWebpackConfig(options) {
179179
//
180180
// Reference: https://github.com/postcss/postcss-loader
181181
// Postprocess your css with PostCSS plugins
182-
var cssLoader = {
182+
const cssLoader = {
183183
test: /\.css$/,
184184
loader: 'style!css' + (BUILD ? '' : '') + '!autoprefixer?browsers=last 2 version',
185185
};
@@ -225,7 +225,8 @@ module.exports = function makeWebpackConfig(options) {
225225

226226
// Reference: https://www.npmjs.com/package/html-webpack-plugin
227227
// Uses index.html as template, appends scripts/css, and moves to templates/app
228-
// Note: npm dev script needs to run webpack regularly the first time to make sure this file actually gets emitted to the file system rather than kept in memory
228+
// Note: npm dev script needs to run webpack regularly the first time to make sure this file
229+
// actually gets emitted to the file system rather than kept in memory
229230
new HtmlWebpackPlugin({
230231
template: './src/index.html',
231232
inject: 'body',

0 commit comments

Comments
 (0)