Conversation
@@ -1,6 +1,7 @@ | |||
{ | |||
"presets": [ | |||
[ "es2015", { "modules": false } ], | |||
"stage-0", |
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.
stage-0
gives you stages 1-3, plus these:
- transform-do-expressions
- transform-function-bind
I'm willing to bet you don't actually need stage-0
... what syntax are you going for?
@@ -0,0 +1,3 @@ | |||
var AUTH0_CLIENT_ID='KvwsETaUxuXVjW2cmz2LbdqXQBdYs6wH'; |
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.
no more var
s in ES6. use const. also, this file doesn't seem to be used anywhere, and consts.js seems to have the same data.
looks like you don't need this file?
@@ -3,14 +3,19 @@ | |||
*/ | |||
|
|||
const APP_INDEX_HTML = 'index.html'; | |||
const APP_INDEX_JS = 'index.js'; | |||
const APP_INDEX_JS = 'app.js'; |
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.
since you're changing index.js
to app.js
, why not also change the constant name from APP_INDEX_JS
to just APP_JS
?
|
||
const MEDIA_FILE_REGEX = /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/; | ||
const MEDIA_URL_REGEX = /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/; | ||
|
||
const AUTH0_CLIENT_ID = 'KvwsETaUxuXVjW2cmz2LbdqXQBdYs6wH'; | ||
const AUTH0_DOMAIN = 'loom.auth0.com'; | ||
|
||
module.exports = { |
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.
module.exports
is a NodeJS thing. in ES6, we'll be using the export
keyword. look at this for reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
eslint/espree#43
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.
so this will translate to...
export default {
...
}
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.
export default { ... } seems to be breaking it: "SyntaxError: Unexpected token export". (also that part came from the lets-react project, I think)
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.
you're right. this has to stay module.exports
for now :/
|
||
const CONSTS = require('./consts'); | ||
const ENV = require('./env.js'); | ||
const PATHS = require('./paths.js'); | ||
const PACKAGE = require('../package.json'); | ||
const root = resolve(__dirname); |
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.
already exists... PATHS.ABS.ROOT
. you could do const ROOT = PATHS.ABS.ROOT
to make it easier to type
|
||
const CONSTS = require('./consts'); | ||
const ENV = require('./env.js'); | ||
const PATHS = require('./paths.js'); | ||
const PACKAGE = require('../package.json'); | ||
const root = resolve(__dirname); | ||
const src = join(root, '../src'); |
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.
already exists... PATHS.ABS.SOURCE
|
||
const CONSTS = require('./consts'); | ||
const ENV = require('./env.js'); | ||
const PATHS = require('./paths.js'); | ||
const PACKAGE = require('../package.json'); | ||
const root = resolve(__dirname); | ||
const src = join(root, '../src'); | ||
const dest = join(root, '../dist'); |
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.
we're not using dist
. we're using build
. available in PATHS.ABS.BUILD
|
||
const MEDIA_FILE_REGEX = /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/; | ||
const MEDIA_URL_REGEX = /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/; | ||
|
||
const AUTH0_CLIENT_ID = 'KvwsETaUxuXVjW2cmz2LbdqXQBdYs6wH'; |
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.
is this meant to be a secret token, or open to the public?
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 the public token!
const path = require('path'), | ||
join = path.join, | ||
resolve = path.resolve; | ||
const getConfig = require('hjs-webpack'); |
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.
why do you need hjs-webpack
? also, you're not using getConfig
anywhere.
@@ -40,12 +46,29 @@ | |||
"eslint-plugin-react": "^6.0.0", | |||
"file-loader": "^0.9.0", | |||
"flow-bin": "^0.32.0", | |||
"hjs-webpack": "^8.1.0", |
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.
you don't need to worry about webpack configuration and such. I'll take care of all of that. also, hjs-webpack
is basically what our lets-react
is meant to be. why are you including it?
"babel-preset-es2015": "^6.14.0", | ||
"babel-preset-react": "^6.11.1", | ||
"babel-preset-stage-0": "^6.5.0", | ||
"bootstrap": "^3.3.5", |
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.
looks like you're using react-bootstrap
everywhere, which is good. so you don't need this dependency.
@@ -0,0 +1,22 @@ | |||
@import url("styles/colors.css"); |
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.
please be consistent with your whitespace. I'll assign myself a task for linting CSS
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.
what did you want me to change about the whitespace here?
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.
you're using 4 space indentation and 2 space indentation. should be 2space across the board
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.
oh haha whoops
import Catalog from './Catalog/Catalog' | ||
import Login from './Login/Login' | ||
|
||
const CONSTS = require('../../../config/consts'); |
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.
don't use require
. use the import
syntax.
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.
refer to my above comments. ../../../config/consts
is the wrong location for these Auth0 constants. they should live under src
|
||
const MEDIA_FILE_REGEX = /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/; | ||
const MEDIA_URL_REGEX = /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/; | ||
|
||
const AUTH0_CLIENT_ID = 'KvwsETaUxuXVjW2cmz2LbdqXQBdYs6wH'; | ||
const AUTH0_DOMAIN = 'loom.auth0.com'; | ||
|
||
module.exports = { |
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.
the top level config
folder is meant to be for general project configuration, for tasks like building, linting, deploying, etc...
this is application specific, so it belongs under src
. you can either create a config
folder under src
, or something else entirely. up to you.
I'll standardize all of this in lets-react
at some point, and provide better documentation to provide more clarity.
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.
just a heads up... you'll have a lot of errors if you run ESLint on this code. linting is not fully set up for you yet, sorry, but it's not hard to run ESLint against this
return ( | ||
<Route path="/" component={Container} auth={auth}> | ||
<IndexRedirect to="/catalog" /> | ||
<Route path="catalog" component={Catalog} onEnter={requireAuth} /> |
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.
path="catalog"
probably works fine, but I think it's good to be consistent. so I'd change this to path={'catalog'}
.
import { shallow } from 'enzyme' | ||
|
||
import App from './App' | ||
import styles from './styles.module.css' |
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.
this is not used anywhere
@@ -20,20 +20,23 @@ | |||
"author": "Hristo Oskov", | |||
"license": "Apache-2.0", | |||
"dependencies": { | |||
"auth0-lock": "^10.3.0", |
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.
dependencies
are required for the app to run. devDependencies
are required only for development. anything related to unit tests should be under devDependencies
. I believe anything that's being bundled will be under dependencies
.
- react
- react-dom
- react-router (I think)
- react-bootstrap (I think)
- auth0-lock
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.
ok! I moved chai out, all the others are needed otherwise the linter gets sad
|
||
import 'bootstrap/dist/css/bootstrap.css' | ||
import './app.css' | ||
import 'react-bootstrap/dist/react-bootstrap.js'; |
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.
this looks like invalid syntax.
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.
you're not using bootstrap in this file, so you don't need the import.
import './app.css' | ||
import 'react-bootstrap/dist/react-bootstrap.js'; | ||
import { hashHistory } from 'react-router'; | ||
import './app.css'; |
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.
check syntax. also doesn't look like it's being used.
|
||
class App extends React.Component { | ||
static contextTypes = { | ||
router: PropTypes.object | ||
} | ||
|
||
static propTypes = { | ||
history: PropTypes.object.isRequired, | ||
routes: PropTypes.element.isRequired | ||
}; | ||
|
||
get content() { |
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.
these getters are usually used for binding a function to an object property. content
is more than just a property in this case, so I think it's better to make it a class method.
since you're returning JSX, how about renderContent
?
const AUTH0_CLIENT_ID = 'KvwsETaUxuXVjW2cmz2LbdqXQBdYs6wH'; | ||
const AUTH0_DOMAIN = 'loom.auth0.com'; | ||
|
||
module.exports = { |
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.
module.exports
is for NodeJS. you can use standard ES6 export syntax for any of the app source code.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
import styles from './styles.module.css' | ||
import React, { PropTypes as T } from 'react'; | ||
import { Button } from 'react-bootstrap'; | ||
import AuthService from '../../../utils/AuthService'; |
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.
I'll figure out a way to make this nicer :)
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.
cool yay thanks!
import {Button} from 'react-bootstrap' | ||
import AuthService from 'utils/AuthService' | ||
import styles from './styles.module.css' | ||
import React, { PropTypes as T } from 'react'; |
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.
what is this for { PropTypes as T }
? doesn't look like PropTypes
is being used, nor T
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 being used for auth things. I got rid of the alias though
import React, { PropTypes as T } from 'react' | ||
import { Jumbotron } from 'react-bootstrap' | ||
import styles from './styles.module.css' | ||
import React, { PropTypes as T } from 'react'; |
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.
I wouldn't alias PropTypes
as T
.
</Route> | ||
) | ||
} | ||
export const makeMainRoutes = () => ( |
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.
there's 2 files named routes.js
, and they both seem to do similar things. is this intentional?
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.
yeah, one is a wrapper around the other. this is the way it came in the default auth0 project, but I can rename one of them to make it less confusing, or see if I can combine them somehow, if you think that would help.
react framework set up with routing and login/logout