Skip to content

Commit c6fb215

Browse files
authored
Eslint (#14)
* `npm run lint` to check for lint * `npm run lint:fix` to fix lint * most lint removed from examples
1 parent 27dfafb commit c6fb215

File tree

39 files changed

+304
-290
lines changed

39 files changed

+304
-290
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ coverage
44
npm-debug.log
55
.DS_Store
66
**/.DS_Store
7+
**/build/**
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"parser" : "babel-eslint",
3+
"extends" : [
4+
"standard",
5+
"standard-react"
6+
],
7+
"plugins": [
8+
"babel"
9+
],
10+
"env" : {
11+
"browser" : true
12+
},
13+
"globals" : {
14+
"__DEV__" : false,
15+
"__PROD__" : false,
16+
"__DEBUG__" : false,
17+
"__COVERAGE__" : false,
18+
"__BASENAME__" : false
19+
},
20+
"rules": {
21+
"semi" : [2, "never"],
22+
"max-len": [2, 120, 2],
23+
"generator-star-spacing": 0,
24+
"babel/generator-star-spacing": 1,
25+
"jsx-quotes": ["error", "prefer-single"]
26+
}
27+
}

examples/react-firebase-redux/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ To deploy to [Heroku](http://heroku.com) through [Travis-CI](http://travis-ci.or
5858

5959
[npm-image]: https://img.shields.io/npm/v/react-firebase-redux.svg?style=flat-square
6060
[npm-url]: https://npmjs.org/package/react-firebase-redux
61-
[travis-image]: https://img.shields.io/travis/prescottprue/react-firebase-redux/master.svg?style=flat-square
62-
[travis-url]: https://travis-ci.org/prescottprue/react-firebase-redux
63-
[daviddm-image]: https://img.shields.io/david/prescottprue/react-firebase-redux.svg?style=flat-square
64-
[daviddm-url]: https://david-dm.org/prescottprue/react-firebase-redux
61+
[travis-image]: https://img.shields.io/travis/testuser/react-firebase-redux/master.svg?style=flat-square
62+
[travis-url]: https://travis-ci.org/testuser/react-firebase-redux
63+
[daviddm-image]: https://img.shields.io/david/testuser/react-firebase-redux.svg?style=flat-square
64+
[daviddm-url]: https://david-dm.org/testuser/react-firebase-redux
6565

6666
[license-image]: https://img.shields.io/npm/l/react-firebase-redux.svg?style=flat-square
67-
[license-url]: https://github.com/prescottprue/react-firebase-redux/blob/master/LICENSE
67+
[license-url]: https://github.com/testuser/react-firebase-redux/blob/master/LICENSE
6868
[code-style-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
6969
[code-style-url]: http://standardjs.com/

examples/react-firebase-redux/app/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const store = configureStore(initialState, createHistory)
1313
let rootElement = document.getElementById('root')
1414

1515
ReactDOM.render(
16-
<Provider store={ store }>
17-
{ createRoutes(browserHistory) }
16+
<Provider store={store}>
17+
{createRoutes(browserHistory)}
1818
</Provider>, rootElement
1919
)

examples/react-firebase-redux/app/components/AccountDropdown/AccountDropdown.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@ import { Link } from 'react-router'
33
import './AccountDropdown.scss'
44

55
export default class AccountDropdown extends Component {
6-
constructor () {
7-
super()
8-
}
9-
10-
state = { isOpen: false };
11-
126
static propTypes = {
137
account: PropTypes.shape({
148
username: PropTypes.string.isRequired
159
}).isRequired,
1610
onLogoutClick: PropTypes.func
17-
};
11+
}
12+
13+
state = { isOpen: false }
1814

1915
toggleDropdown = () => {
2016
this.setState({

examples/react-firebase-redux/app/components/AccountManager/AccountManager.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@ import AccountDropdown from '../AccountDropdown/AccountDropdown'
44
import './AccountManager.scss'
55

66
export default class AccountManager extends Component {
7-
constructor (props) {
8-
super(props)
9-
}
10-
117
static propTypes = {
128
account: PropTypes.object,
139
onLogoutClick: PropTypes.func
14-
};
10+
}
1511

1612
render () {
17-
if (this.props.account && this.props.account.username) {
13+
const { account, onLogoutClick } = this.props
14+
if (account && account.username) {
1815
return (
1916
<AccountDropdown
20-
account={this.props.account}
21-
onLogoutClick={this.props.onLogoutClick}
17+
account={account}
18+
onLogoutClick={onLogoutClick}
2219
/>
2320
)
2421
}

examples/react-firebase-redux/app/components/LoginForm/LoginForm.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,20 @@ import React, {Component, PropTypes} from 'react'
22
import { Link } from 'react-router'
33
import TextField from 'material-ui/lib/text-field'
44
import RaisedButton from 'material-ui/lib/raised-button'
5-
import CircularProgress from 'material-ui/lib/circular-progress'
65
import Checkbox from 'material-ui/lib/checkbox'
76
import './LoginForm.scss'
87

98
const fieldStyle = { width: '80%' }
109
const buttonStyle = { width: '100%' }
1110

1211
export default class LoginForm extends Component {
13-
constructor (props) {
14-
super(props)
15-
}
16-
17-
state = { errors: { username: null, password: null } }
18-
1912
static propTypes = {
13+
account: PropTypes.object,
2014
onLogin: PropTypes.func
2115
}
2216

17+
state = { errors: { username: null, password: null } }
18+
2319
/**
2420
* @function handleInputChange
2521
* @description Update the state with the values from the form inputs.
@@ -44,12 +40,12 @@ export default class LoginForm extends Component {
4440
handleLogin = e => {
4541
if (e && typeof e.preventDefault === 'function') e.preventDefault()
4642
const { username } = this.state
47-
if (!username || username == '') {
43+
if (!username || username === '') {
4844
return this.setState({
4945
errors: { username: 'Username required' }
5046
})
5147
}
52-
if (!this.password || this.password == '') {
48+
if (!this.password || this.password === '') {
5349
return this.setState({
5450
errors: { password: 'Password required' }
5551
})
@@ -68,15 +64,15 @@ export default class LoginForm extends Component {
6864
<TextField
6965
hintText='[email protected]'
7066
floatingLabelText='Username/Email'
71-
onChange={this.handleInputChange.bind(this, 'username')}
67+
onChange={() => { this.handleInputChange('username') }}
7268
errorText={this.state.errors.username}
7369
style={fieldStyle}
7470
/>
7571
<TextField
7672
hintText='password'
7773
floatingLabelText='Password'
7874
type='password'
79-
onChange={this.handlePrivateChange.bind(this, 'password')}
75+
onChange={() => { this.handlePrivateChange('password') }}
8076
errorText={this.state.errors.password}
8177
style={fieldStyle}
8278
/>

examples/react-firebase-redux/app/components/Navbar/Navbar.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ import React, { Component, PropTypes } from 'react'
22
import './Navbar.scss'
33
import { Link } from 'react-router'
44

5-
//Components
65
import AppBar from 'material-ui/lib/app-bar'
7-
import IconButton from 'material-ui/lib/icon-button'
8-
import NavigationClose from 'material-ui/lib/svg-icons/navigation/close'
96
import IconMenu from 'material-ui/lib/menus/icon-menu'
10-
import MoreVertIcon from 'material-ui/lib/svg-icons/navigation/more-vert'
117
import MenuItem from 'material-ui/lib/menus/menu-item'
128
import FlatButton from 'material-ui/lib/flat-button'
139
import Avatar from 'material-ui/lib/avatar'
@@ -18,17 +14,13 @@ const avatarSize = 50
1814
const buttonStyle = { color: 'white' }
1915

2016
export default class Navbar extends Component {
21-
constructor(props) {
22-
super(props)
23-
}
24-
2517
static propTypes = {
2618
account: PropTypes.object,
2719
onMenuClick: PropTypes.func,
2820
onLogoutClick: PropTypes.func
2921
}
3022

31-
selectItem = (e, item) => {
23+
selectItem = (item) => {
3224
if (item === 'logout' && this.props.onLogoutClick) {
3325
return this.props.onLogoutClick()
3426
}
@@ -39,18 +31,18 @@ export default class Navbar extends Component {
3931

4032
render() {
4133
const { username, avatar_url } = this.props.account ? this.props.account : {}
42-
const brandLinkLoc = username ? `/${username}` : '/'
34+
const brandLinkLoc = `/${username || ''}`
4335
const iconButton = (
4436
<Avatar
45-
className="Navbar-Avatar"
46-
src={ avatar_url ? avatar_url : stockPhotoUrl }
37+
className='Navbar-Avatar'
38+
src={ avatar_url || stockPhotoUrl }
4739
size={ avatarSize }
4840
/>
4941
)
5042
const mainMenu = (
51-
<div className="Navbar-Main-Menu">
52-
<FlatButton label="Sign Up" style={ buttonStyle } onClick={ this.selectItem.bind(this, null, 'signup') } />
53-
<FlatButton label="Login" style={ buttonStyle } onClick={ this.selectItem.bind(this, null, 'login') } />
43+
<div className='Navbar-Main-Menu'>
44+
<FlatButton label='Sign Up' style={ buttonStyle } onClick={ () => this.selectItem('signup') } />
45+
<FlatButton label='Login' style={ buttonStyle } onClick={ () => this.selectItem('login') } />
5446
</div>
5547
)
5648
const rightMenu = username ? (
@@ -60,15 +52,19 @@ export default class Navbar extends Component {
6052
anchorOrigin={ originSettings }
6153
onChange={ this.selectItem }
6254
>
63-
<MenuItem primaryText="Account" value="account" />
64-
<MenuItem primaryText="About" value="about"/>
65-
<MenuItem primaryText="Sign out" value="logout"/>
55+
<MenuItem primaryText='Account' value='account' />
56+
<MenuItem primaryText='About' value='about'/>
57+
<MenuItem primaryText='Sign out' value='logout'/>
6658
</IconMenu>
6759
) : mainMenu
6860
return (
6961
<AppBar
70-
title={<Link className="Navbar-Brand" to={ brandLinkLoc }>react-firebase-redux</Link>}
71-
className="Navbar"
62+
title={
63+
<Link className='Navbar-Brand' to={ brandLinkLoc }>
64+
react-firebase-redux
65+
</Link>
66+
}
67+
className='Navbar'
7268
showMenuIconButton={ false }
7369
iconElementRight={ rightMenu }
7470
/>

examples/react-firebase-redux/app/components/SignupForm/SignupForm.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import React, {Component, PropTypes} from 'react'
22
import TextField from 'material-ui/lib/text-field'
33
import RaisedButton from 'material-ui/lib/raised-button'
4-
import CircularProgress from 'material-ui/lib/circular-progress'
5-
import Paper from 'material-ui/lib/paper'
64
import './SignupForm.scss'
5+
import { capitalize } from 'lodash'
6+
77
const fieldStyle = { width: '80%' }
88
const buttonStyle = { width: '96%', marginBottom: '.5rem' }
99

1010
export default class SignupForm extends Component {
11-
constructor (props) {
12-
super(props)
11+
static propTypes = {
12+
account: PropTypes.object,
13+
signup: PropTypes.func,
14+
onSignup: PropTypes.func
1315
}
1416

1517
state = { errors: {} }
@@ -35,11 +37,7 @@ export default class SignupForm extends Component {
3537
this.props.onSignup(newAccountData)
3638
}
3739
}
38-
/**
39-
* @function requireInputs
40-
* @description Confirm that all required inputs have values
41-
* @return {Boolean}
42-
*/
40+
4341
requireInputs = () => {
4442
const requiredInputs = [
4543
{name: 'username', val: this.state.username},

examples/react-firebase-redux/app/containers/Account/Account.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,44 @@
11
import React, { Component, PropTypes } from 'react'
2-
import { Link } from 'react-router'
32

43
// styles
54
import './Account.scss'
65

7-
// firebase
8-
import firebaseUtil from '../../utils/firebase'
9-
106
import { bindActionCreators } from 'redux'
117
import { connect } from 'react-redux'
128
import * as Actions from '../../actions'
139

1410
class Acccount extends Component {
15-
constructor (props) {
16-
super(props)
17-
}
18-
1911
static propTypes = {
2012
account: PropTypes.object,
21-
};
13+
logout: PropTypes.func
14+
}
2215

2316
render () {
2417
const emailTo = `mailto:${this.props.account.email || ''}`
18+
const { account, logout } = this.props
2519
return (
2620
<div className='Acccount'>
2721
<div className='Acccount-Data'>
2822
<span className='Acccount-Datapoint Acccount-Username'>
29-
{ this.props.account.username }
23+
{ account.username }
3024
</span>
3125
<span className='Acccount-Datapoint Acccount-Name'>
32-
{ this.props.account.name || 'No Name' }
26+
{ account.name || 'No Name' }
3327
</span>
3428
<span className='Acccount-Datapoint Acccount-Role'>
35-
{ this.props.account.role }
29+
{ account.role }
3630
</span>
3731
<a className='Acccount-Datapoint Acccount-Email' href={ emailTo }>
38-
{ this.props.account.email }
32+
{ account.email }
3933
</a>
40-
<button className='Button' onClick={ this.props.logout }>
34+
<button className='Button' onClick={ logout }>
4135
Logout
4236
</button>
4337
</div>
4438
</div>
4539
)
4640
}
4741
}
48-
4942
// Place state of redux store into props of component
5043
const mapStateToProps = (state) => {
5144
return {

0 commit comments

Comments
 (0)