Skip to content

Commit 54c2765

Browse files
committed
Update with eslint and better ES6 use lessons 1 and 2
1 parent 66d013c commit 54c2765

File tree

15 files changed

+213
-30
lines changed

15 files changed

+213
-30
lines changed

lessons/01-setting-up/.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["react", "es2015"]
3+
}

lessons/01-setting-up/.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

lessons/01-setting-up/.eslintrc

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"extends": [
3+
"eslint:recommended",
4+
"plugin:import/errors",
5+
"plugin:import/warnings"
6+
],
7+
"plugins": [
8+
"react"
9+
],
10+
"parserOptions": {
11+
"ecmaVersion": 6,
12+
"sourceType": "module",
13+
"ecmaFeatures": {
14+
"jsx": true
15+
}
16+
},
17+
"env": {
18+
"es6": true,
19+
"browser": true,
20+
"node": true,
21+
"jquery": true,
22+
"mocha": true
23+
},
24+
"rules": {
25+
"quotes": 0,
26+
"no-console": 1,
27+
"no-debugger": 1,
28+
"no-var": 1,
29+
"indent": ["error", 2],
30+
"semi": [1, "always"],
31+
"no-trailing-spaces": 0,
32+
"eol-last": 0,
33+
"no-unused-vars": 0,
34+
"no-underscore-dangle": 0,
35+
"no-alert": 0,
36+
"no-lone-blocks": 0,
37+
"jsx-quotes": 1,
38+
"react/display-name": [ 1, {"ignoreTranspilerName": false }],
39+
"react/forbid-prop-types": [1, {"forbid": ["any"]}],
40+
"react/jsx-boolean-value": 1,
41+
"react/jsx-closing-bracket-location": 0,
42+
"react/jsx-curly-spacing": 1,
43+
"react/jsx-indent-props": 0,
44+
"react/jsx-key": 1,
45+
"react/jsx-max-props-per-line": 0,
46+
"react/jsx-no-bind": 1,
47+
"react/jsx-no-duplicate-props": 1,
48+
"react/jsx-no-literals": 0,
49+
"react/jsx-no-undef": 1,
50+
"react/jsx-pascal-case": 1,
51+
"react/jsx-sort-prop-types": 0,
52+
"react/jsx-sort-props": 0,
53+
"react/jsx-uses-react": 1,
54+
"react/jsx-uses-vars": 1,
55+
"react/no-danger": 1,
56+
"react/no-did-mount-set-state": 1,
57+
"react/no-did-update-set-state": 1,
58+
"react/no-direct-mutation-state": 1,
59+
"react/no-multi-comp": 1,
60+
"react/no-set-state": 0,
61+
"react/no-unknown-property": 1,
62+
"react/prefer-es6-class": 1,
63+
"react/prop-types": 1,
64+
"react/react-in-jsx-scope": 1,
65+
"react/require-extension": 1,
66+
"react/self-closing-comp": 1,
67+
"react/sort-comp": 1,
68+
"react/wrap-multilines": 1
69+
}
70+
}

lessons/01-setting-up/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!doctype html public "storage">
22
<html>
33
<meta charset=utf-8/>
4+
<link rel="icon" href="data:;base64,=">
45
<title>My First React Router App</title>
56
<div id=app></div>
67
<script src="bundle.js"></script>

lessons/01-setting-up/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
2-
import { render } from 'react-dom'
3-
import App from './modules/App'
4-
render(<App/>, document.getElementById('app'))
1+
import React from 'react';
2+
import { render } from 'react-dom';
3+
import App from './modules/App';
4+
render(<App/>, document.getElementById('app'));

lessons/01-setting-up/modules/App.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react'
1+
import React from 'react';
22

3-
export default React.createClass({
3+
export default class App extends React.Component {
44
render() {
5-
return <div>Hello, React Router!</div>
5+
return <div>Hello!!, React Router!</div>;
66
}
7-
})
7+
}

lessons/01-setting-up/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"babel-loader": "^6.2.2",
1919
"babel-preset-es2015": "^6.5.0",
2020
"babel-preset-react": "^6.5.0",
21+
"babel-preset-react-hmre": "^1.1.1",
2122
"http-server": "^0.8.5",
2223
"webpack": "^1.12.13",
2324
"webpack-dev-server": "^1.14.1"

lessons/02-rendering-a-route/.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": ["react", "es2015"],
3+
"env": {
4+
"development": {
5+
}
6+
}
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"extends": [
3+
"eslint:recommended",
4+
"plugin:import/errors",
5+
"plugin:import/warnings"
6+
],
7+
"plugins": [
8+
"react"
9+
],
10+
"parserOptions": {
11+
"ecmaVersion": 6,
12+
"sourceType": "module",
13+
"ecmaFeatures": {
14+
"jsx": true
15+
}
16+
},
17+
"env": {
18+
"es6": true,
19+
"browser": true,
20+
"node": true,
21+
"jquery": true,
22+
"mocha": true
23+
},
24+
"rules": {
25+
"quotes": 0,
26+
"no-console": 1,
27+
"no-debugger": 1,
28+
"no-var": 1,
29+
"indent": ["error", 2],
30+
"semi": [1, "always"],
31+
"no-trailing-spaces": 0,
32+
"eol-last": 0,
33+
"no-unused-vars": 0,
34+
"no-underscore-dangle": 0,
35+
"no-alert": 0,
36+
"no-lone-blocks": 0,
37+
"jsx-quotes": 1,
38+
"react/display-name": [ 1, {"ignoreTranspilerName": false }],
39+
"react/forbid-prop-types": [1, {"forbid": ["any"]}],
40+
"react/jsx-boolean-value": 1,
41+
"react/jsx-closing-bracket-location": 0,
42+
"react/jsx-curly-spacing": 1,
43+
"react/jsx-indent-props": 0,
44+
"react/jsx-key": 1,
45+
"react/jsx-max-props-per-line": 0,
46+
"react/jsx-no-bind": 1,
47+
"react/jsx-no-duplicate-props": 1,
48+
"react/jsx-no-literals": 0,
49+
"react/jsx-no-undef": 1,
50+
"react/jsx-pascal-case": 1,
51+
"react/jsx-sort-prop-types": 0,
52+
"react/jsx-sort-props": 0,
53+
"react/jsx-uses-react": 1,
54+
"react/jsx-uses-vars": 1,
55+
"react/no-danger": 1,
56+
"react/no-did-mount-set-state": 1,
57+
"react/no-did-update-set-state": 1,
58+
"react/no-direct-mutation-state": 1,
59+
"react/no-multi-comp": 1,
60+
"react/no-set-state": 0,
61+
"react/no-unknown-property": 1,
62+
"react/prefer-es6-class": 1,
63+
"react/prop-types": 1,
64+
"react/react-in-jsx-scope": 1,
65+
"react/require-extension": 1,
66+
"react/self-closing-comp": 1,
67+
"react/sort-comp": 1,
68+
"react/wrap-multilines": 1
69+
}
70+
}

lessons/02-rendering-a-route/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Open up `index.js` and
1515

1616
```js
1717
// ...
18-
import { Router, Route, hashHistory } from 'react-router'
18+
import { Router, Route, hashHistory } from 'react-router';
1919

2020
render((
2121
<Router history={hashHistory}>
2222
<Route path="/" component={App}/>
2323
</Router>
24-
), document.getElementById('app'))
24+
), document.getElementById('app'));
2525
```
2626

2727
Make sure your server is running with `npm start` and then visit
@@ -43,32 +43,32 @@ Create two new components at:
4343

4444
```js
4545
// modules/About.js
46-
import React from 'react'
46+
import React from 'react';
4747

48-
export default React.createClass({
48+
export default class About extends React.Component {
4949
render() {
50-
return <div>About</div>
50+
return <div>About</div>;
5151
}
52-
})
52+
}
5353
```
5454

5555
```js
5656
// modules/Repos.js
57-
import React from 'react'
57+
import React from 'react';
5858

59-
export default React.createClass({
59+
export default class Repos extends React.Component {
6060
render() {
61-
return <div>Repos</div>
61+
return <div>Repos</div>;
6262
}
63-
})
63+
}
6464
```
6565

6666
Now we can couple them to the app at their respective paths.
6767

6868
```js
6969
// insert into index.js
70-
import About from './modules/About'
71-
import Repos from './modules/Repos'
70+
import About from './modules/About';
71+
import Repos from './modules/Repos';
7272

7373
render((
7474
<Router history={hashHistory}>

lessons/02-rendering-a-route/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React from 'react'
2-
import { render } from 'react-dom'
3-
import App from './modules/App'
4-
render(<App/>, document.getElementById('app'))
1+
import React from 'react';
2+
import { render } from 'react-dom';
3+
import App from './modules/App';
4+
5+
render(<App/>, document.getElementById('app'));
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react'
1+
import React from 'react';
22

3-
export default React.createClass({
3+
export default class App extends React.Component {
44
render() {
5-
return <div>Hello, React Router!</div>
5+
return <div>Hello, React Router!</div>;
66
}
7-
})
7+
}

lessons/02-rendering-a-route/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
"react-router": "^2.0.0"
1515
},
1616
"devDependencies": {
17+
"babel-cli": "^6.23.0",
1718
"babel-core": "^6.5.1",
1819
"babel-loader": "^6.2.2",
1920
"babel-preset-es2015": "^6.5.0",
2021
"babel-preset-react": "^6.5.0",
22+
"eslint": "^3.17.1",
23+
"eslint-plugin-import": "^2.2.0",
24+
"eslint-plugin-react": "^6.10.0",
2125
"http-server": "^0.8.5",
2226
"webpack": "^1.12.13",
2327
"webpack-dev-server": "^1.14.1"

lessons/02-rendering-a-route/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88

99
module: {
1010
loaders: [
11-
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
11+
{ test: /\.js$/, exclude: /node_modules/, loaders: ['babel-loader'] }
1212
]
1313
}
14-
}
14+
};

0 commit comments

Comments
 (0)