Skip to content

Commit b20d226

Browse files
committed
eslint implementation
1 parent b8ff122 commit b20d226

File tree

11 files changed

+44
-39
lines changed

11 files changed

+44
-39
lines changed

.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"semi": [
1313
2,
1414
"always"
15-
]
15+
],
16+
"react/prop-types": 1,
17+
"react/no-multi-comp": 1
1618
},
1719
"env": {
1820
"es6": true,

client/js/components/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var App = React.createClass({
1717
<Location path="/item/:item" handler={CatalogDetail} />
1818
</Locations>
1919
</Template>
20-
)
20+
);
2121
}
2222
});
2323

client/js/components/cart/cart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var Cart = React.createClass({
2929
</td>
3030
<td>${subtotal}</td>
3131
</tr>
32-
)
32+
);
3333
});
3434

3535
return (
@@ -47,7 +47,7 @@ var Cart = React.createClass({
4747
</table>
4848
<Link href="/">Continue Shopping</Link>
4949
</div>
50-
)
50+
);
5151
}
5252
});
5353

client/js/components/cart/decreaseitem.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ var React = require('React'),
22
AppActions = require('../../actions/actions');
33

44
var DecreaseItem = React.createClass({
5+
propTypes: {
6+
index: React.PropTypes.number
7+
},
58
handler: function() {
69
AppActions.decreaseItem(this.props.index);
710
},
811
render: function() {
9-
return (
10-
<button onClick={ this.handler }>
11-
-
12-
</button>
13-
)
12+
return <button onClick={ this.handler }>-</button>;
1413
}
1514
});
1615

client/js/components/cart/increaseitem.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ var React = require('React'),
22
AppActions = require('../../actions/actions');
33

44
var IncreaseItem = React.createClass({
5+
propTypes: {
6+
index: React.PropTypes.number
7+
},
58
handler: function() {
69
AppActions.increaseItem(this.props.index);
710
},
811
render: function() {
9-
return (
10-
<button onClick={ this.handler }>
11-
+
12-
</button>
13-
)
12+
return <button onClick={ this.handler }>+</button>;
1413
}
1514
});
1615

client/js/components/cart/removefromcart.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ var React = require('React'),
22
AppActions = require('../../actions/actions');
33

44
var RemmoveFromCart = React.createClass({
5+
propTypes: {
6+
index: React.PropTypes.number
7+
},
58
handler: function() {
69
AppActions.removeItem(this.props.index);
710
},
811
render: function() {
9-
return (
10-
<button onClick={ this.handler }>
11-
x
12-
</button>
13-
)
12+
return <button onClick={ this.handler }>x</button>;
1413
}
1514
});
1615

client/js/components/catalog/addtocart.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ var React = require('React'),
22
AppActions = require('../../actions/actions');
33

44
var AddToCart = React.createClass({
5+
propTypes: {
6+
item: React.PropTypes.object
7+
},
58
handler: function() {
69
AppActions.addItem(this.props.item);
710
},
811
render: function() {
912
return (
10-
<button onClick={ this.handler }>
11-
Add To Cart
12-
</button>
13-
)
13+
<button onClick={ this.handler }>
14+
Add To Cart
15+
</button>
16+
);
1417
}
1518
});
1619

client/js/components/catalog/catalog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ var Catalog = React.createClass({
1919
<td>${item.cost}</td>
2020
<td><AddToCart item={item} /></td>
2121
</tr>
22-
)
22+
);
2323
});
2424
return (
2525
<table width="100%">
2626
{items}
2727
</table>
28-
)
28+
);
2929
}
3030
});
3131

client/js/components/layout/header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var Header = React.createClass({
1010
View Shopping Cart
1111
</Link>
1212
</div>
13-
)
13+
);
1414
}
1515
});
1616

client/js/components/layout/template.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ var React = require('react'),
22
Header = require('./header');
33

44
var Template = React.createClass({
5+
propTypes: {
6+
children: React.PropTypes.array
7+
},
58
render: function() {
69
return (
710
<div>
811
<Header />
912
{this.props.children}
1013
</div>
11-
)
14+
);
1215
}
1316
});
1417

client/js/stores/store.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ var AppStore = assign(EventEmitter.prototype, {
9191
var action = payload.action;
9292

9393
switch(action.actionType) {
94-
case AppConstants.ADD_ITEM:
95-
_addItem(action.item);
96-
break;
97-
case AppConstants.REMOVE_ITEM:
98-
_removeItem(action.index);
99-
break;
100-
case AppConstants.INCREASE_ITEM:
101-
_increaseItem(action.index);
102-
break;
103-
case AppConstants.DECREASE_ITEM:
104-
_decreaseItem(action.index);
105-
break;
94+
case AppConstants.ADD_ITEM:
95+
_addItem(action.item);
96+
break;
97+
case AppConstants.REMOVE_ITEM:
98+
_removeItem(action.index);
99+
break;
100+
case AppConstants.INCREASE_ITEM:
101+
_increaseItem(action.index);
102+
break;
103+
case AppConstants.DECREASE_ITEM:
104+
_decreaseItem(action.index);
105+
break;
106106
}
107107

108108
AppStore.emitChange();

0 commit comments

Comments
 (0)