Skip to content

Commit aa7e902

Browse files
committed
feat(linter): remove all warnings
1 parent 8a24558 commit aa7e902

File tree

8 files changed

+31
-24
lines changed

8 files changed

+31
-24
lines changed

.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"parser": "babel-eslint",
44
"extends": "fullstack",
55
"rules": {
6-
"semi": 0
6+
"semi": 0,
7+
"new-cap": [1, { "capIsNewExceptions": ["Router"] }]
78
}
89
}

client/components/auth-form.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ const AuthForm = (props) => {
1313
<div>
1414
<form onSubmit={handleSubmit} name={name}>
1515
<div>
16-
<label htmlFor='email'><small>Email</small></label>
17-
<input name='email' type='text' />
16+
<label htmlFor="email"><small>Email</small></label>
17+
<input name="email" type="text" />
1818
</div>
1919
<div>
20-
<label htmlFor='password'><small>Password</small></label>
21-
<input name='password' type='password' />
20+
<label htmlFor="password"><small>Password</small></label>
21+
<input name="password" type="password" />
2222
</div>
2323
<div>
24-
<button type='submit'>{displayName}</button>
24+
<button type="submit">{displayName}</button>
2525
</div>
2626
{error && error.response && <div> {error.response.data} </div>}
2727
</form>
28-
<a href='/auth/google'>{displayName} with Google</a>
28+
<a href="/auth/google">{displayName} with Google</a>
2929
</div>
3030
)
3131
}

client/components/main.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ const Main = (props) => {
2121
isLoggedIn
2222
? <div>
2323
{/* The navbar will show these links after you log in */}
24-
<Link to='/home'>Home</Link>
25-
<a href='#' onClick={handleClick}>Logout</a>
24+
<Link to="/home">Home</Link>
25+
<a href="#" onClick={handleClick}>Logout</a>
2626
</div>
2727
: <div>
2828
{/* The navbar will show these links before you log in */}
29-
<Link to='/login'>Login</Link>
30-
<Link to='/signup'>Sign Up</Link>
29+
<Link to="/login">Login</Link>
30+
<Link to="/signup">Sign Up</Link>
3131
</div>
3232
}
3333
</nav>

client/routes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class Routes extends Component {
2323
<Main>
2424
<Switch>
2525
{/* Routes placed here are available to all visitors */}
26-
<Route path='/login' component={Login} />
27-
<Route path='/signup' component={Signup} />
26+
<Route path="/login" component={Login} />
27+
<Route path="/signup" component={Signup} />
2828
{
2929
isLoggedIn &&
3030
<Switch>
3131
{/* Routes placed here are only available after logging in */}
32-
<Route path='/home' component={UserHome} />
32+
<Route path="/home" component={UserHome} />
3333
</Switch>
3434
}
3535
{/* Displays our Login component as a fallback */}

client/store/user.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const auth = (email, password, method) =>
4141
export const logout = () =>
4242
dispatch =>
4343
axios.post('/auth/logout')
44-
.then(res => {
44+
.then(_ => {
4545
dispatch(removeUser())
4646
history.push('/login')
4747
})

server/auth/google.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ const strategy = new GoogleStrategy(googleConfig, (token, refreshToken, profile,
3030
const email = profile.emails[0].value
3131

3232
User.find({where: {googleId}})
33-
.then(user => user
34-
? done(null, user)
33+
.then(foundUser => (foundUser
34+
? done(null, foundUser)
3535
: User.create({name, email, googleId})
36-
.then(user => done(null, user))
37-
)
36+
.then(createdUser => done(null, createdUser))
37+
))
3838
.catch(done)
3939
})
4040

server/auth/index.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ router.post('/login', (req, res, next) => {
1010
} else if (!user.correctPassword(req.body.password)) {
1111
res.status(401).send('Incorrect password')
1212
} else {
13-
req.login(user, err => err ? next(err) : res.json(user))
13+
req.login(user, err => (err ? next(err) : res.json(user)))
1414
}
1515
})
1616
.catch(next)
@@ -19,12 +19,14 @@ router.post('/login', (req, res, next) => {
1919
router.post('/signup', (req, res, next) => {
2020
User.create(req.body)
2121
.then(user => {
22-
req.login(user, err => err ? next(err) : res.json(user))
22+
req.login(user, err => (err ? next(err) : res.json(user)))
2323
})
2424
.catch(err => {
25-
if (err.name === 'SequelizeUniqueConstraintError')
25+
if (err.name === 'SequelizeUniqueConstraintError') {
2626
res.status(401).send('User already exists')
27-
else next(err)
27+
} else {
28+
next(err)
29+
}
2830
})
2931
})
3032

server/db/models/user.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ User.generateSalt = function () {
3636
}
3737

3838
User.encryptPassword = function (plainText, salt) {
39-
return crypto.createHash('RSA-SHA256').update(plainText).update(salt).digest('hex')
39+
return crypto
40+
.createHash('RSA-SHA256')
41+
.update(plainText)
42+
.update(salt)
43+
.digest('hex')
4044
}
4145

4246
/**

0 commit comments

Comments
 (0)