From 3690b2888dc83307828964da095c51f0adac0a0b Mon Sep 17 00:00:00 2001 From: yiminghe Date: Thu, 11 Jun 2015 16:35:36 +0800 Subject: [PATCH] pass lint --- components/confirm/index.jsx | 28 +++++++++++++++++++++------- components/modal/index.jsx | 15 ++++++++------- index.js | 2 +- package.json | 7 ++++++- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/components/confirm/index.jsx b/components/confirm/index.jsx index 7edcd6e390..e2ce6081ab 100644 --- a/components/confirm/index.jsx +++ b/components/confirm/index.jsx @@ -1,3 +1,5 @@ +'use strict'; + var React = require('react'); var Dialog = require('rc-dialog'); var div; @@ -17,26 +19,38 @@ module.exports = function (props) { } function onCancel() { - if (props.onCancel) { - props.onCancel(close); + var cancelFn = props.onCancel; + if (cancelFn) { + if(cancelFn.length){ + cancelFn(close); + }else { + cancelFn(); + close(); + } } else { close(); } } function onOk() { - if (props.onOk) { - props.onOk(close); + var okFn = props.onOk; + if (okFn) { + if(okFn.length){ + okFn(close); + }else { + okFn(); + close(); + } } else { close(); } } var body =
- + {props.title}
{props.content}
-
+ ; var footer =
@@ -48,7 +62,7 @@ module.exports = function (props) { } React.render( -
{body} {footer}
+
{body} {footer}
, div, function () { d = this; diff --git a/components/modal/index.jsx b/components/modal/index.jsx index dd03098e4b..c85856e1f9 100644 --- a/components/modal/index.jsx +++ b/components/modal/index.jsx @@ -2,18 +2,19 @@ var React = require('react'); var Dialog = require('rc-dialog'); -function noop(){} +function noop() { +} var Modal = React.createClass({ handleCancel() { this.refs.d.requestClose(); }, - getDefaultProps(){ + getDefaultProps() { return { - onOk:noop, - onCancel:noop, - onBeforeClose:noop + onOk: noop, + onCancel: noop, + onBeforeClose: noop }; }, @@ -27,8 +28,8 @@ var Modal = React.createClass({ , ]; - return + return ; } }); -module.exports = Modal; \ No newline at end of file +module.exports = Modal; diff --git a/index.js b/index.js index 35b9baf3fc..87155ecaad 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,7 @@ var antd = { Dropdown: require('./components/dropdown'), Progress: require('./components/progress'), Select: require('./components/select'), - confirm:require('./components/confirm') + confirm: require('./components/confirm') }; module.exports = window.antd = antd; diff --git a/package.json b/package.json index 7969d82405..24c5d94cb8 100644 --- a/package.json +++ b/package.json @@ -32,11 +32,13 @@ "eslint-plugin-react": "~2.5.0", "extract-text-webpack-plugin": "~0.8.1", "gh-pages-cli": "~0.2.0", + "jshint": "~2.8.0", "json-loader": "~0.5.1", "less": "~2.5.1", "less-loader": "~2.2.0", "lodash": "~3.8.0", "nico-jsx": "~0.5.8", + "precommit-hook": "~1.0.7", "style-loader": "~0.12.2", "webpack": "~1.9.7" }, @@ -47,5 +49,8 @@ "deploy": "npm run build && gh-pages -d _site -b gh-pages", "lint": "eslint components index.js --ext '.js,.jsx'", "test": "webpack && npm run lint" - } + }, + "precommit": [ + "lint" + ] }