-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eslint Refactor #46
Merged
Merged
Eslint Refactor #46
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ab2239c
add precommit package, fix npm run quickstart
jrwells 6d46eb7
refactor src, tests, and webpack to be eslint compliant with our esli…
jrwells ef0ff58
remove debugger statement :fire:
jrwells 2b6e09a
revert quickstart script
jrwells 6cf1852
remove commented out auth stuff
jrwells 0eeafcc
move comment outside of function block
jrwells 6a6233a
remove auth token name shadow
jrwells 7f64ef5
remove unused globals
jrwells d51322e
change declaration to expression
jrwells 782048a
disable id-length rule
jrwells 88b01b4
revert changes that affect higher order components
jrwells File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
import React, {Component} from 'react'; | ||
import React from 'react'; | ||
import {Router, browserHistory} from 'react-router'; | ||
import {Provider} from 'react-redux'; | ||
import routes from '../universal/routes/index'; | ||
import {syncHistoryWithStore} from 'react-router-redux'; | ||
import {ensureState} from 'redux-optimistic-ui'; | ||
|
||
export default class Root extends Component { | ||
static propTypes = { | ||
store: React.PropTypes.object.isRequired | ||
} | ||
|
||
render() { | ||
const {store} = this.props; | ||
const history = syncHistoryWithStore(browserHistory, store, {selectLocationState: state => ensureState(state).get('routing')}); | ||
return ( | ||
<Provider store={store}> | ||
<div> | ||
<Router history={history} routes={routes(store)}/> | ||
</div> | ||
</Provider> | ||
); | ||
} | ||
export default function Root({store}) { | ||
const history = syncHistoryWithStore(browserHistory, store, | ||
{selectLocationState: state => ensureState(state).get('routing')}); | ||
return ( | ||
<Provider store={store}> | ||
<div> | ||
<Router history={history} routes={routes(store)} /> | ||
</div> | ||
</Provider> | ||
); | ||
} | ||
|
||
Root.propTypes = { | ||
store: React.PropTypes.object.isRequired | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
/* eslint react/no-danger:0 */ | ||
import React, {Component, PropTypes} from 'react'; | ||
import React, {PropTypes} from 'react'; | ||
import {Provider} from 'react-redux'; | ||
import {RouterContext} from 'react-router'; | ||
import {renderToString} from 'react-dom-stream/server'; | ||
|
||
// Injects the server rendered state and app into a basic html template | ||
export default class Html extends Component { | ||
static propTypes = { | ||
store: PropTypes.object.isRequired, | ||
title: PropTypes.string.isRequired, | ||
assets: PropTypes.object, | ||
renderProps: PropTypes.object | ||
} | ||
|
||
render() { | ||
const PROD = process.env.NODE_ENV === 'production'; | ||
const {title, store, assets, renderProps} = this.props; | ||
const {manifest, app, vendor} = assets || {}; | ||
const initialState = `window.__INITIAL_STATE__ = ${JSON.stringify(store.getState())}`; | ||
const root = PROD && renderToString( | ||
<Provider store={store}> | ||
<RouterContext {...renderProps}/> | ||
</Provider>); | ||
return ( | ||
<html> | ||
<head> | ||
<meta charSet="utf-8"/> | ||
<meta property="description" content="Team transparency, made easy." /> | ||
{PROD && <link rel="stylesheet" href="/static/prerender.css" type="text/css"/>} | ||
<title>{title}</title> | ||
</head> | ||
<body> | ||
<script dangerouslySetInnerHTML={{__html: initialState}}/> | ||
{PROD ? <div id="root" dangerouslySetInnerHTML={{__html: root}}></div> : <div id="root"></div>} | ||
{PROD && <script dangerouslySetInnerHTML={{__html: manifest.text}}/>} | ||
{PROD && <script src={vendor.js}/>} | ||
<script src={PROD ? app.js : '/static/app.js'}/> | ||
</body> | ||
</html> | ||
); | ||
} | ||
export default function Html({title, store, assets, renderProps}) { | ||
const PROD = process.env.NODE_ENV === 'production'; | ||
const {manifest, app, vendor} = assets || {}; | ||
const initialState = `window.__INITIAL_STATE__ = ${JSON.stringify(store.getState())}`; | ||
const root = PROD && renderToString( | ||
<Provider store={store}> | ||
<RouterContext {...renderProps} /> | ||
</Provider>); | ||
return ( | ||
<html> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta property="description" content="Team transparency, made easy." /> | ||
{PROD && <link rel="stylesheet" href="/static/prerender.css" type="text/css" />} | ||
<title>{title}</title> | ||
</head> | ||
<body> | ||
<script dangerouslySetInnerHTML={{__html: initialState}} /> | ||
{PROD ? | ||
<div id="root" dangerouslySetInnerHTML={{__html: root}}></div> : | ||
<div id="root"></div> | ||
} | ||
{PROD && <script dangerouslySetInnerHTML={{__html: manifest.text}} />} | ||
{PROD && <script src={vendor.js} />} | ||
<script src={PROD ? app.js : '/static/app.js'} /> | ||
</body> | ||
</html> | ||
); | ||
} | ||
|
||
Html.propTypes = { | ||
store: PropTypes.object.isRequired, | ||
title: PropTypes.string.isRequired, | ||
assets: PropTypes.object, | ||
renderProps: PropTypes.object | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
module.exports.run = function () { | ||
module.exports.run = () => { | ||
console.log(' >> Broker PID:', process.pid); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import r from '../../../database/rethinkdriver'; | ||
import {GraphQLString} from 'graphql'; | ||
import {CachedUser} from './cachedUserSchema'; | ||
import {getUserByUserId} from './helpers'; | ||
import { AuthenticationClient } from 'auth0'; | ||
import {auth0} from '../../../../universal/utils/clientOptions'; | ||
|
||
//TODO this stuff is no good, we need the good server stuff so we don't 401 | ||
// TODO this stuff is no good, we need the good server stuff so we don't 401 | ||
const auth0Client = new AuthenticationClient({ | ||
domain: auth0.account, | ||
clientId: auth0.clientId | ||
|
@@ -22,15 +21,16 @@ export default { | |
}, | ||
async resolve(source, {idToken}) { | ||
const userInfo = await auth0Client.tokens.getInfo(idToken); | ||
//TODO add the userId to the JWT to eliminate call to DB? JWT.sub is the userId, not id, maybe it'll do | ||
//TODO loginsCount and blockedFor are not a part of this API response | ||
const user = await getUserByUserId(userInfo.user_id); //eslint-disable-line camelcase | ||
const id = user && user.id; | ||
// TODO add the userId to the JWT to eliminate call to DB? | ||
// JWT.sub is the userId, not id, maybe it'll do | ||
// TODO loginsCount and blockedFor are not a part of this API response | ||
// const user = await getUserByUserId(userInfo.user_id); // eslint-disable-line camelcase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...(cont'd) as in, none of these constants were populated on the below object? |
||
// const id = user && user.id; | ||
const newUserObj = { | ||
cachedAt: new Date(), | ||
//TODO set expiry here | ||
// TODO set expiry here | ||
cacheExpiresAt: new Date(), | ||
//from auth0 | ||
// from auth0 | ||
createdAt: userInfo.created_at, | ||
updatedAt: userInfo.updated_at, | ||
userId: userInfo.user_id, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import {GraphQLNonNull, GraphQLID} from 'graphql'; | ||
import {CachedUser} from './cachedUserSchema'; | ||
import {getUserByUserId} from './helpers'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting! Did you fix a bug by adding this line? |
||
import {errorObj} from '../utils'; | ||
|
||
export default { | ||
getUserByUserId: { | ||
type: CachedUser, | ||
args: { | ||
userId: {type: new GraphQLNonNull(GraphQLID), description: 'The user ID for the desired profile'} | ||
userId: { | ||
type: new GraphQLNonNull(GraphQLID), | ||
description: 'The user ID for the desired profile' | ||
} | ||
}, | ||
async resolve(source, {userId}) { | ||
const user = await getUserByUserId(userId); | ||
|
@@ -17,4 +21,3 @@ export default { | |
} | ||
} | ||
}; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how can you extend Component if you don't import it? Seriously, what is this magic? Do I not have to import Component to use it? Is that a thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's all functions now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhhh! didn't see the change to stateless functions. nice!
@jordanh per dan abramov's medium post, i think the winds are changing to using webpack's stock HMR solution instead of proxying all of the react component to achieve HMR. This will be especially true since detecting stateless components in babel is error prone. Just something to put on the radar when we start focusing on the front end build. see: mattkrick/meatier#114