From 0970534f65be2734496313bb40b7129fa091b327 Mon Sep 17 00:00:00 2001 From: zwjamnsss Date: Mon, 10 Jul 2017 21:29:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20eslint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 36 ++++++++++++++++++++++ client/components/Header/Header.js | 4 +-- client/containers/Home/Home.js | 4 +-- client/containers/Login/Login.js | 13 +++++--- client/containers/Login/Login_container.js | 5 +-- client/reducer/Login/Login_redux.js | 2 -- package.json | 1 + ykit.js | 10 ++++-- 8 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..5a2e2404 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "env": { + "browser": true, + "commonjs": true + }, + "extends": [], + "globals": [ + "$", + "$$", + "jQuery", + "Promise" + ], + "rules": { + "no-with": "error", + "no-octal": "error", + "no-undef": "error", + "no-dupe-keys": "error", + "no-dupe-args": "error", + "no-delete-var": "error", + "no-unused-vars": "error", + "no-caller": "error", + "no-debugger": "error", + "no-unreachable": "error", + "no-inner-declarations": [ + "error", + "functions" + ] + }, + "ignorePattern": [ + "/fekit_modules/*", + "/node_modules/*", + "/bower_components/*", + "/dev/*", + "/prd/*" + ] +} diff --git a/client/components/Header/Header.js b/client/components/Header/Header.js index 57d2d89e..8ac0b39c 100644 --- a/client/components/Header/Header.js +++ b/client/components/Header/Header.js @@ -1,6 +1,6 @@ import './Header.scss' import React, { Component } from 'react' -import { BrowserRouter as Router, Route, Link } from 'react-router-dom' +import { Link } from 'react-router-dom' class Header extends Component { constructor(props) { @@ -29,4 +29,4 @@ class Header extends Component { } } -export default Header \ No newline at end of file +export default Header diff --git a/client/containers/Home/Home.js b/client/containers/Home/Home.js index 22dc8f65..3512c7a6 100644 --- a/client/containers/Home/Home.js +++ b/client/containers/Home/Home.js @@ -1,9 +1,7 @@ // import { React, Component } from '../../base.js' import './Home.scss' import React, { Component } from 'react' -import { Button, Input, Icon, Checkbox } from 'antd' import Header from '../../components/Header/Header.js' -import { BrowserRouter as Router, Route, Link } from 'react-router-dom' class Home extends Component { constructor(props) { @@ -19,4 +17,4 @@ class Home extends Component { } } -export default Home \ No newline at end of file +export default Home diff --git a/client/containers/Login/Login.js b/client/containers/Login/Login.js index 17306e55..0c0d8d73 100644 --- a/client/containers/Login/Login.js +++ b/client/containers/Login/Login.js @@ -1,16 +1,19 @@ -// import { React, Component } from '../../base.js' -import './Login.scss' import React, { Component } from 'react' +import PropTypes from 'prop-types' import { Button, Input, Icon, Checkbox } from 'antd' -import { BrowserRouter as Router, Route, Link } from 'react-router-dom' +import './Login.scss' class Login extends Component { constructor(props) { super(props) } + static propTypes = { + value: PropTypes.string, + per: PropTypes.string, + } + render () { - console.log(this.props) return ( {this.props.value}{this.props.per} @@ -29,7 +32,7 @@ class Login extends Component {
记住密码 - +
diff --git a/client/containers/Login/Login_container.js b/client/containers/Login/Login_container.js index 0a78386b..0b3782b8 100644 --- a/client/containers/Login/Login_container.js +++ b/client/containers/Login/Login_container.js @@ -1,12 +1,10 @@ -import React, { Component } from 'react' -import { createStore, combineReducers } from 'redux' import { connect } from 'react-redux' import Login from './Login.js' // Action const increaseAction = { type: 'increase' } -function mapStateToProps(state) { +function mapStateToProps() { return { per: '测试数据', } @@ -24,4 +22,3 @@ const App = connect( )(Login) export default App - diff --git a/client/reducer/Login/Login_redux.js b/client/reducer/Login/Login_redux.js index 227d0973..a2bd47e2 100644 --- a/client/reducer/Login/Login_redux.js +++ b/client/reducer/Login/Login_redux.js @@ -1,5 +1,3 @@ -import React, { Component } from 'react' - export default function (state = 3, action) { const count = state switch (action.type) { diff --git a/package.json b/package.json index ce9302d0..aee4afac 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "mongoose": "4.10.8", "mongoose-auto-increment": "^5.0.1", "node-sass-china": "^4.5.0", + "prop-types": "^15.5.10", "redux": "^3.7.1", "ykit-config-antd": "^0.1.3", "ykit-config-react": "^0.4.4" diff --git a/ykit.js b/ykit.js index 2d4204c8..8fea7f7e 100644 --- a/ykit.js +++ b/ykit.js @@ -2,7 +2,13 @@ var path = require('path'); var ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { - plugins: ['qunar', 'antd'], + plugins: [{ + name: 'qunar', + options: { + eslint: true, + configFile: path.resolve(__dirname, "./client/.eslintrc.js") + } + }, 'antd'], devtool: 'cheap-source-map', config: { exports: [ @@ -17,7 +23,7 @@ module.exports = { // true/false,默认 false,效果相当于 ykit server --hot hot: true, // true/false,默认 false,开启后可在当前打开的页面提示打包错误 - overlay: true + overlay: true }, hooks: {}, commands: []