Skip to content

Commit cf7195d

Browse files
committed
Update with eslint and better ES6 use lesson 3
1 parent 54c2765 commit cf7195d

File tree

9 files changed

+114
-24
lines changed

9 files changed

+114
-24
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["react", "es2015"]
3+
}
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/03-navigating-with-link/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Let's create some navigation in our `App` component.
88

99
```js
1010
// modules/App.js
11-
import React from 'react'
12-
import { Link } from 'react-router'
11+
import React from 'react';
12+
import { Link } from 'react-router';
1313

14-
export default React.createClass({
14+
export default class App extends React.Component {
1515
render() {
1616
return (
1717
<div>
@@ -21,9 +21,9 @@ export default React.createClass({
2121
<li><Link to="/repos">Repos</Link></li>
2222
</ul>
2323
</div>
24-
)
24+
);
2525
}
26-
})
26+
}
2727
```
2828

2929
Now visit [http://localhost:8080](http://localhost:8080) and click the links, click back, click
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import React from 'react'
2-
import { render } from 'react-dom'
3-
import { Router, Route, hashHistory } from 'react-router'
4-
import App from './modules/App'
5-
import About from './modules/About'
6-
import Repos from './modules/Repos'
1+
import React from 'react';
2+
import { render } from 'react-dom';
3+
import { Router, Route, hashHistory } from 'react-router';
4+
import App from './modules/App';
5+
import About from './modules/About';
6+
import Repos from './modules/Repos';
77

88
render((
99
<Router history={hashHistory}>
1010
<Route path="/" component={App}/>
1111
<Route path="/repos" component={Repos}/>
1212
<Route path="/about" component={About}/>
1313
</Router>
14-
), document.getElementById('app'))
14+
), 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 About extends React.Component {
44
render() {
5-
return <div>About</div>
5+
return <div>About</div>;
66
}
7-
})
7+
}
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+
}
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 Repos extends React.Component {
44
render() {
5-
return <div>Repos</div>
5+
return <div>Repos</div>;
66
}
7-
})
7+
}

lessons/03-navigating-with-link/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"

0 commit comments

Comments
 (0)