Skip to content

Commit 40eafc9

Browse files
author
Sven
committed
style: modify eslintrc
1 parent 0fe184f commit 40eafc9

File tree

16 files changed

+52
-36
lines changed

16 files changed

+52
-36
lines changed

.eslintrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@
2323
"comma-dangle": "off", // standard 默认禁止使用拖尾逗号,但是ES8新特性支持拖尾逗号,所以关闭
2424
"jsx-quotes": [2, "prefer-double"], // JSX中使用双引号
2525
"max-len": [2, 120, 2], // 一行最长长度
26+
"no-use-before-define": [2, { "functions": true, "classes": true }],
2627
"space-before-function-paren":[2,
2728
{"anonymous": "always", "named": "never", "asyncArrow": "always"}], // 函数圆括号之前有一个空格
2829
"object-curly-spacing": [2, "always"], // 对象花括号总是包裹空格
2930
"react/jsx-curly-spacing": [2, {"when": "never", "children": true}], // 不要在JSX {} 引用括号里两边加空格
3031
"react/jsx-closing-bracket-location": [2, "line-aligned"], // JSX对齐方式
31-
"react/jsx-wrap-multilines": [2] //JSX多行元素用()包裹
32+
"react/jsx-wrap-multilines": 2, //JSX多行元素用()包裹
33+
"react/prefer-stateless-function": 2,
34+
"react/jsx-boolean-value": 2,
35+
"react/no-string-refs": 2,
36+
"react/jsx-filename-extension": 2,
37+
"react/default-props-match-prop-types": 2
3238
}
3339
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"compile": "node build/scripts/compile",
99
"build": "npm run clean && cross-env NODE_ENV=production npm run compile",
1010
"start": "cross-env NODE_ENV=development node build/scripts/start",
11-
"lint": "eslint .",
11+
"lint": "eslint . --ext .js,.jsx",
1212
"lint:fix": "npm run lint -- --fix"
1313
},
1414
"repository": {
File renamed without changes.

src/components/Loading.js renamed to src/components/Loading.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@ import React from 'react'
22
import { bool } from 'prop-types'
33
import Spinner from 'react-spinkit'
44

5-
Loading.propTypes = {
6-
isLoading: bool,
7-
timedOut: bool,
8-
pastDelay: bool,
9-
error: bool
10-
}
11-
12-
export default function Loading(props) {
5+
function Loading(props) {
136
if (props.isLoading) {
147
// While our other component is loading...
158
if (props.timedOut) {
@@ -30,3 +23,12 @@ export default function Loading(props) {
3023
return null
3124
}
3225
}
26+
27+
Loading.propTypes = {
28+
isLoading: bool,
29+
timedOut: bool,
30+
pastDelay: bool,
31+
error: bool
32+
}
33+
34+
export default Loading

src/components/PrivateRoute.js renamed to src/components/PrivateRoute.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ import PropTypes from 'prop-types'
33
import { Route, Redirect } from 'react-router-dom'
44
import { connect } from 'react-redux'
55

6-
PrivateRoute.propTypes = {
7-
isAuthenticated: PropTypes.bool.isRequired,
8-
component: PropTypes.func.isRequired,
9-
location: PropTypes.object.isRequired,
10-
}
11-
126
function PrivateRoute({ component: Component, isAuthenticated, ...rest }) {
137
return (
148
<Route {...rest} render={props => (
@@ -27,6 +21,12 @@ function PrivateRoute({ component: Component, isAuthenticated, ...rest }) {
2721
)
2822
}
2923

24+
PrivateRoute.propTypes = {
25+
isAuthenticated: PropTypes.bool.isRequired,
26+
component: PropTypes.func.isRequired,
27+
location: PropTypes.object.isRequired,
28+
}
29+
3030
const mapStateToProps = (state) => ({
3131
isAuthenticated: state.isAuthenticated
3232
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/routes/Counter/components/Counter.js renamed to src/routes/Counter/components/Counter.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ import { Button } from 'reactstrap'
44

55
// Stateless Functional Component
66
// React style:https://github.com/airbnb/javascript/tree/master/react
7-
Counter.propTypes = {
8-
counter: number.isRequired,
9-
increment: func.isRequired,
10-
doubleAsync: func.isRequired
11-
}
12-
137
function Counter({ counter, increment, doubleAsync }) {
148
return (<div style={{ margin: '0 auto' }}>
159
<h3>Counter: {counter}</h3>
@@ -23,4 +17,10 @@ function Counter({ counter, increment, doubleAsync }) {
2317
</div>)
2418
}
2519

20+
Counter.propTypes = {
21+
counter: number.isRequired,
22+
increment: func.isRequired,
23+
doubleAsync: func.isRequired
24+
}
25+
2626
export default Counter

0 commit comments

Comments
 (0)