From 8eba1f58b1471c9381a125276e354741889c5daa Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Mon, 19 Mar 2018 10:47:23 +0800 Subject: [PATCH] lint jsx --- .vscode/settings.json | 15 +- components/_util/ContainerRender.jsx | 1 - components/affix/index.jsx | 1 - components/alert/index.jsx | 1 - components/align/Align.jsx | 1 - components/auto-complete/InputElement.jsx | 1 - components/auto-complete/index.jsx | 1 - components/back-top/index.jsx | 1 - components/badge/Badge.jsx | 1 - components/badge/ScrollNumber.jsx | 1 - components/breadcrumb/Breadcrumb.jsx | 1 - components/breadcrumb/BreadcrumbItem.jsx | 60 ++-- components/card/Card.jsx | 294 +++++++++--------- components/cascader/index.jsx | 1 - components/dropdown/dropdown-button.jsx | 1 - components/dropdown/dropdown.jsx | 1 - components/dropdown/src/Dropdown.jsx | 1 - components/grid/Col.jsx | 2 - components/grid/Row.jsx | 1 - components/input/Group.jsx | 1 - components/locale-provider/LocaleReceiver.jsx | 1 - components/locale-provider/index.jsx | 1 - components/menu/MenuItem.jsx | 1 - components/menu/index.jsx | 1 - components/modal/ActionButton.jsx | 1 - components/modal/ConfirmDialog.jsx | 1 - components/modal/Modal.jsx | 1 - components/popconfirm/index.jsx | 1 - components/popover/index.jsx | 1 - components/select/index.jsx | 1 - components/tabs/src/ScrollableInkTabBar.jsx | 1 - components/tabs/src/ScrollableTabBar.jsx | 1 - components/tag/CheckableTag.jsx | 1 - components/trigger/LazyRenderBox.jsx | 1 - components/trigger/Popup.jsx | 2 - components/trigger/PopupInner.jsx | 1 - components/trigger/Trigger.jsx | 1 - components/vc-cascader/Cascader.jsx | 1 - components/vc-dialog/Dialog.jsx | 1 - components/vc-dialog/DialogWrap.jsx | 1 - components/vc-dialog/LazyRenderBox.jsx | 2 - components/vc-menu/DOMWrap.jsx | 1 - components/vc-notification/Notice.jsx | 1 - components/vc-notification/Notification.jsx | 1 - components/vc-select/DropdownMenu.jsx | 1 - components/vc-select/Select.jsx | 1 - components/vc-select/SelectTrigger.jsx | 1 - components/vc-steps/Steps.jsx | 1 - components/vc-time-picker/Combobox.jsx | 1 - components/vc-tooltip/Tooltip.jsx | 1 - package.json | 5 +- 51 files changed, 192 insertions(+), 232 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a72c3381d..8090fa64a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,16 +4,27 @@ "eslint.options": { "extensions": [ ".js", + ".jsx", ".vue" ], "configFile": ".eslintrc" }, "eslint.validate": [ - "javascript", - "javascriptreact", + { + "language": "html", + "autoFix": true + }, { "language": "vue", "autoFix": true + }, + { + "language": "javascript", + "autoFix": true + }, + { + "language": "javascriptreact", + "autoFix": true } ], "emmet.syntaxProfiles": { diff --git a/components/_util/ContainerRender.jsx b/components/_util/ContainerRender.jsx index d668f4cc3..9540e6db4 100644 --- a/components/_util/ContainerRender.jsx +++ b/components/_util/ContainerRender.jsx @@ -85,4 +85,3 @@ export default { }, } - diff --git a/components/affix/index.jsx b/components/affix/index.jsx index 65b11d6d2..4b1beb6f1 100644 --- a/components/affix/index.jsx +++ b/components/affix/index.jsx @@ -242,4 +242,3 @@ export default { }, } - diff --git a/components/alert/index.jsx b/components/alert/index.jsx index 089e6576b..289d328cd 100644 --- a/components/alert/index.jsx +++ b/components/alert/index.jsx @@ -130,4 +130,3 @@ export default { }, } - diff --git a/components/align/Align.jsx b/components/align/Align.jsx index af19e5377..d8ae29801 100644 --- a/components/align/Align.jsx +++ b/components/align/Align.jsx @@ -125,4 +125,3 @@ export default { }, } - diff --git a/components/auto-complete/InputElement.jsx b/components/auto-complete/InputElement.jsx index f7592eb2f..0e7d23bbd 100644 --- a/components/auto-complete/InputElement.jsx +++ b/components/auto-complete/InputElement.jsx @@ -52,4 +52,3 @@ export default { }, } - diff --git a/components/auto-complete/index.jsx b/components/auto-complete/index.jsx index 16e116671..0a371c29a 100644 --- a/components/auto-complete/index.jsx +++ b/components/auto-complete/index.jsx @@ -134,4 +134,3 @@ export default { }, } - diff --git a/components/back-top/index.jsx b/components/back-top/index.jsx index 90373b81b..895dbc387 100644 --- a/components/back-top/index.jsx +++ b/components/back-top/index.jsx @@ -131,4 +131,3 @@ export default { }, } - diff --git a/components/badge/Badge.jsx b/components/badge/Badge.jsx index 187214e5b..ab7a6deec 100644 --- a/components/badge/Badge.jsx +++ b/components/badge/Badge.jsx @@ -111,4 +111,3 @@ export default { }, } - diff --git a/components/badge/ScrollNumber.jsx b/components/badge/ScrollNumber.jsx index 66a8d8cc9..779a1392e 100644 --- a/components/badge/ScrollNumber.jsx +++ b/components/badge/ScrollNumber.jsx @@ -135,4 +135,3 @@ export default { }, } - diff --git a/components/breadcrumb/Breadcrumb.jsx b/components/breadcrumb/Breadcrumb.jsx index e82c5cb74..463e033a8 100644 --- a/components/breadcrumb/Breadcrumb.jsx +++ b/components/breadcrumb/Breadcrumb.jsx @@ -87,4 +87,3 @@ export default { }, } - diff --git a/components/breadcrumb/BreadcrumbItem.jsx b/components/breadcrumb/BreadcrumbItem.jsx index e273e9e94..c6a0a5627 100644 --- a/components/breadcrumb/BreadcrumbItem.jsx +++ b/components/breadcrumb/BreadcrumbItem.jsx @@ -1,33 +1,33 @@ - import PropTypes from '../_util/vue-types' - import { hasProp, getComponentFromProp } from '../_util/props-util' +import PropTypes from '../_util/vue-types' +import { hasProp, getComponentFromProp } from '../_util/props-util' - export default { - name: 'BreadcrumbItem', - __ANT_BREADCRUMB_ITEM: true, - props: { - prefixCls: PropTypes.string.def('ant-breadcrumb'), - href: PropTypes.string, - separator: PropTypes.any, - }, - render () { - const { prefixCls, $slots } = this - const children = $slots.default - let link - if (hasProp(this, 'href')) { - link = {children} - } else { - link = {children} - } - if (children) { - return ( - - {link} - {getComponentFromProp(this, 'separator') || '/'} - - ) - } - return null - }, - } +export default { + name: 'BreadcrumbItem', + __ANT_BREADCRUMB_ITEM: true, + props: { + prefixCls: PropTypes.string.def('ant-breadcrumb'), + href: PropTypes.string, + separator: PropTypes.any, + }, + render () { + const { prefixCls, $slots } = this + const children = $slots.default + let link + if (hasProp(this, 'href')) { + link = {children} + } else { + link = {children} + } + if (children) { + return ( + + {link} + {getComponentFromProp(this, 'separator') || '/'} + + ) + } + return null + }, +} diff --git a/components/card/Card.jsx b/components/card/Card.jsx index b05d9762d..12d64e521 100644 --- a/components/card/Card.jsx +++ b/components/card/Card.jsx @@ -1,164 +1,164 @@ - import Tabs from '../tabs' - import PropTypes from '../_util/vue-types' - import addEventListener from '../_util/Dom/addEventListener' - import { getComponentFromProp, getComponentName } from '../_util/props-util' - import throttleByAnimationFrame from '../_util/throttleByAnimationFrame' - import BaseMixin from '../_util/BaseMixin' +import Tabs from '../tabs' +import PropTypes from '../_util/vue-types' +import addEventListener from '../_util/Dom/addEventListener' +import { getComponentFromProp, getComponentName } from '../_util/props-util' +import throttleByAnimationFrame from '../_util/throttleByAnimationFrame' +import BaseMixin from '../_util/BaseMixin' - const { TabPane } = Tabs - export default { - name: 'Card', - mixins: [BaseMixin], - props: { - prefixCls: PropTypes.string.def('ant-card'), - title: PropTypes.string, - extra: PropTypes.any, - bordered: PropTypes.bool.def(true), - bodyStyle: PropTypes.object, - loading: PropTypes.bool.def(false), - hoverable: PropTypes.bool.def(false), - type: PropTypes.string, - actions: PropTypes.any, - tabList: PropTypes.array, - }, - data () { - this.updateWiderPaddingCalled = false - return { - widerPadding: false, +const { TabPane } = Tabs +export default { + name: 'Card', + mixins: [BaseMixin], + props: { + prefixCls: PropTypes.string.def('ant-card'), + title: PropTypes.string, + extra: PropTypes.any, + bordered: PropTypes.bool.def(true), + bodyStyle: PropTypes.object, + loading: PropTypes.bool.def(false), + hoverable: PropTypes.bool.def(false), + type: PropTypes.string, + actions: PropTypes.any, + tabList: PropTypes.array, + }, + data () { + this.updateWiderPaddingCalled = false + return { + widerPadding: false, + } + }, + beforeMount () { + this.updateWiderPadding = throttleByAnimationFrame(this.updateWiderPadding) + }, + mounted () { + this.updateWiderPadding() + this.resizeEvent = addEventListener(window, 'resize', this.updateWiderPadding) + }, + beforeDestroy () { + if (this.resizeEvent) { + this.resizeEvent.remove() + } + this.updateWiderPadding.cancel && this.updateWiderPadding.cancel() + }, + methods: { + updateWiderPadding () { + const cardContainerRef = this.$refs.cardContainerRef + if (!cardContainerRef) { + return + } + // 936 is a magic card width pixer number indicated by designer + const WIDTH_BOUDARY_PX = 936 + if (cardContainerRef.offsetWidth >= WIDTH_BOUDARY_PX && !this.widerPadding) { + this.setState({ widerPadding: true }, () => { + this.updateWiderPaddingCalled = true // first render without css transition + }) + } + if (cardContainerRef.offsetWidth < WIDTH_BOUDARY_PX && this.widerPadding) { + this.setState({ widerPadding: false }, () => { + this.updateWiderPaddingCalled = true // first render without css transition + }) } }, - beforeMount () { - this.updateWiderPadding = throttleByAnimationFrame(this.updateWiderPadding) + onHandleTabChange (key) { + this.$emit('tabChange', key) }, - mounted () { - this.updateWiderPadding() - this.resizeEvent = addEventListener(window, 'resize', this.updateWiderPadding) - }, - beforeDestroy () { - if (this.resizeEvent) { - this.resizeEvent.remove() - } - this.updateWiderPadding.cancel && this.updateWiderPadding.cancel() - }, - methods: { - updateWiderPadding () { - const cardContainerRef = this.$refs.cardContainerRef - if (!cardContainerRef) { - return - } - // 936 is a magic card width pixer number indicated by designer - const WIDTH_BOUDARY_PX = 936 - if (cardContainerRef.offsetWidth >= WIDTH_BOUDARY_PX && !this.widerPadding) { - this.setState({ widerPadding: true }, () => { - this.updateWiderPaddingCalled = true // first render without css transition - }) - } - if (cardContainerRef.offsetWidth < WIDTH_BOUDARY_PX && this.widerPadding) { - this.setState({ widerPadding: false }, () => { - this.updateWiderPaddingCalled = true // first render without css transition - }) - } - }, - onHandleTabChange (key) { - this.$emit('tabChange', key) - }, - isContainGrid (obj = []) { - let containGrid - obj.forEach((element) => { - if ( - element && + isContainGrid (obj = []) { + let containGrid + obj.forEach((element) => { + if ( + element && element.componentOptions && getComponentName(element.componentOptions) === 'Grid' - ) { - containGrid = true - } - }) - return containGrid - }, + ) { + containGrid = true + } + }) + return containGrid }, - render () { - const { - prefixCls = 'ant-card', extra, bodyStyle, title, loading, - bordered = true, type, tabList, hoverable, - } = this.$props + }, + render () { + const { + prefixCls = 'ant-card', extra, bodyStyle, title, loading, + bordered = true, type, tabList, hoverable, + } = this.$props - const { $slots } = this + const { $slots } = this - const classString = { - [`${prefixCls}`]: true, - [`${prefixCls}-loading`]: loading, - [`${prefixCls}-bordered`]: bordered, - [`${prefixCls}-hoverable`]: !!hoverable, - [`${prefixCls}-wider-padding`]: this.widerPadding, - [`${prefixCls}-padding-transition`]: this.updateWiderPaddingCalled, - [`${prefixCls}-contain-grid`]: this.isContainGrid($slots.default), - [`${prefixCls}-contain-tabs`]: tabList && tabList.length, - [`${prefixCls}-type-${type}`]: !!type, - } + const classString = { + [`${prefixCls}`]: true, + [`${prefixCls}-loading`]: loading, + [`${prefixCls}-bordered`]: bordered, + [`${prefixCls}-hoverable`]: !!hoverable, + [`${prefixCls}-wider-padding`]: this.widerPadding, + [`${prefixCls}-padding-transition`]: this.updateWiderPaddingCalled, + [`${prefixCls}-contain-grid`]: this.isContainGrid($slots.default), + [`${prefixCls}-contain-tabs`]: tabList && tabList.length, + [`${prefixCls}-type-${type}`]: !!type, + } - const loadingBlock = ( -
- - -
-- - -
-- - -
-- - - -
-+ + +
++ + +
++ + +
++ + + +
+