From 615b460ee47f82249beb33a36626ec685bdbfed5 Mon Sep 17 00:00:00 2001 From: Amour1688 <31695475+Amour1688@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:52:02 +0800 Subject: [PATCH] chore: enhance eslint (#1890) * perf: enhance eslint * perf: remove props in progress --- .eslintrc | 7 +++++ components/_util/ContainerRender.jsx | 2 +- components/_util/env.js | 1 + components/affix/__tests__/index.test.js | 3 +-- components/affix/index.jsx | 3 +-- components/breadcrumb/Breadcrumb.jsx | 2 +- components/button/button-group.jsx | 2 +- components/button/button.jsx | 1 - components/calendar/Header.jsx | 2 +- components/calendar/index.jsx | 10 +++---- components/card/__tests__/index.test.js | 2 -- components/cascader/index.jsx | 8 +++--- components/comment/index.jsx | 2 +- components/date-picker/RangePicker.jsx | 26 +++++++++---------- components/date-picker/WeekPicker.jsx | 2 -- components/date-picker/createPicker.js | 2 +- components/date-picker/interface.js | 2 +- components/form/Form.jsx | 4 +-- components/form/FormItem.jsx | 2 +- components/grid/Row.jsx | 9 ------- components/layout/__tests__/index.test.js | 2 -- components/list/Item.jsx | 1 - components/mentions/__test__/index.test.js | 1 - components/mentions/index.jsx | 2 +- components/menu/__tests__/index.test.js | 6 ++--- components/menu/index.jsx | 2 +- components/modal/Modal.jsx | 2 +- components/modal/__tests__/Modal.test.js | 1 - components/modal/confirm.js | 2 +- components/page-header/index.jsx | 1 + components/progress/progress.jsx | 26 +------------------ components/radio/Group.jsx | 2 +- components/radio/__tests__/group.test.js | 1 - components/result/index.jsx | 4 +-- components/skeleton/Paragraph.jsx | 1 - components/statistic/__tests__/index.test.js | 2 -- components/table/SelectionCheckboxAll.jsx | 2 +- components/table/Table.jsx | 3 --- .../table/__tests__/SelectionBox.test.js | 2 +- .../__tests__/Table.rowSelection.test.js | 4 +-- components/table/__tests__/Table.test.js | 2 +- components/tooltip/Tooltip.jsx | 2 +- components/tree/Tree.jsx | 1 - components/upload/Upload.jsx | 2 +- components/vc-calendar/src/RangeCalendar.jsx | 4 +-- .../src/calendar/CalendarFooter.jsx | 2 +- components/vc-cascader/Cascader.jsx | 6 ++--- components/vc-collapse/src/Panel.jsx | 1 - components/vc-dropdown/src/Dropdown.jsx | 2 +- components/vc-form/src/createBaseForm.jsx | 2 +- components/vc-input-number/src/index.js | 1 - components/vc-menu/Menu.jsx | 4 +-- components/vc-menu/SubMenu.jsx | 1 - components/vc-pagination/Options.jsx | 2 +- components/vc-select/Select.jsx | 8 +++--- components/vc-slick/src/arrows.js | 8 +++--- components/vc-slick/src/dots.js | 12 ++++----- components/vc-slick/src/inner-slider.js | 2 +- components/vc-slick/src/slider.js | 2 +- components/vc-slick/src/track.js | 2 +- components/vc-slider/src/Range.jsx | 2 +- components/vc-table/src/BaseTable.jsx | 2 +- components/vc-tabs/src/TabBarTabsNode.jsx | 2 +- components/vc-tabs/src/TabContent.jsx | 2 +- components/vc-time-picker/Header.jsx | 2 -- components/vc-time-picker/Panel.jsx | 3 +-- components/vc-time-picker/Select.jsx | 5 ---- components/vc-time-picker/TimePicker.jsx | 1 - components/vc-tooltip/Tooltip.jsx | 6 ++--- .../vc-tree-select/src/Base/BasePopup.jsx | 8 +++--- components/vc-tree-select/src/Select.jsx | 4 +-- components/vc-tree-select/src/util.js | 2 +- components/vc-tree/src/TreeNode.jsx | 1 - components/vc-trigger/Trigger.jsx | 2 +- 74 files changed, 104 insertions(+), 163 deletions(-) diff --git a/.eslintrc b/.eslintrc index ec87f0692..ebb56cb71 100644 --- a/.eslintrc +++ b/.eslintrc @@ -15,6 +15,10 @@ "rules": { "comma-dangle": [2, "always-multiline"], "no-var": "error", + "no-console": [2, { "allow": ["warn", "error"] }], + "object-shorthand": 2, + "no-unused-vars": [2, { "ignoreRestSiblings": true, "argsIgnorePattern": "^h$" }], + "no-undef": 2, "camelcase": "off", "no-extra-boolean-cast": "off", "semi": ["error", "always"], @@ -32,5 +36,8 @@ } } ] + }, + "globals": { + "h": true } } diff --git a/components/_util/ContainerRender.jsx b/components/_util/ContainerRender.jsx index 57746b25f..2b9e23d31 100644 --- a/components/_util/ContainerRender.jsx +++ b/components/_util/ContainerRender.jsx @@ -52,7 +52,7 @@ export default { } if (!this._component) { this._component = new this.$root.constructor({ - el: el, + el, parent: self, data: { comProps: props, diff --git a/components/_util/env.js b/components/_util/env.js index 96894fc58..5b500008a 100644 --- a/components/_util/env.js +++ b/components/_util/env.js @@ -1,3 +1,4 @@ +/* eslint-disable no-undef */ // Browser environment sniffing export const inBrowser = typeof window !== 'undefined'; export const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform; diff --git a/components/affix/__tests__/index.test.js b/components/affix/__tests__/index.test.js index 0c029a886..ab265ecb8 100644 --- a/components/affix/__tests__/index.test.js +++ b/components/affix/__tests__/index.test.js @@ -2,7 +2,6 @@ import Affix from '..'; import Button from '../../button'; import { mount } from '@vue/test-utils'; import { spyElementPrototype } from '../../__tests__/util/domHook'; -import { asyncExpect } from '@/tests/utils'; const events = {}; const AffixMounter = { @@ -62,7 +61,7 @@ describe('Affix Render', () => { }); const movePlaceholder = top => { classRect.fixed = { - top: top, + top, bottom: top, }; events.scroll({ diff --git a/components/affix/index.jsx b/components/affix/index.jsx index c0a2484b0..d82d00716 100644 --- a/components/affix/index.jsx +++ b/components/affix/index.jsx @@ -1,6 +1,5 @@ import PropTypes from '../_util/vue-types'; import classNames from 'classnames'; -import shallowequal from 'shallowequal'; import omit from 'omit.js'; import ResizeObserver from '../vc-resize-observer'; import BaseMixin from '../_util/BaseMixin'; @@ -231,7 +230,7 @@ const Affix = { }, render() { - const { prefixCls, affixStyle, placeholderStyle, status, $slots, $props } = this; + const { prefixCls, affixStyle, placeholderStyle, $slots, $props } = this; const getPrefixCls = this.configProvider.getPrefixCls; const className = classNames({ [getPrefixCls('affix', prefixCls)]: affixStyle, diff --git a/components/breadcrumb/Breadcrumb.jsx b/components/breadcrumb/Breadcrumb.jsx index 6b17d93f3..9cdd6dd46 100644 --- a/components/breadcrumb/Breadcrumb.jsx +++ b/components/breadcrumb/Breadcrumb.jsx @@ -61,7 +61,7 @@ export default { return originalPaths; }, - genForRoutes({ routes = [], params = {}, separator, itemRender = defaultItemRender }) { + genForRoutes({ routes = [], params = {}, separator, itemRender = this.defaultItemRender }) { const paths = []; return routes.map(route => { const path = this.getPath(route.path, params); diff --git a/components/button/button-group.jsx b/components/button/button-group.jsx index 41df76fb3..41f05fd6d 100644 --- a/components/button/button-group.jsx +++ b/components/button/button-group.jsx @@ -26,7 +26,7 @@ export default { }; }, render() { - const { prefixCls: customizePrefixCls, size, sizeMap, $slots } = this; + const { prefixCls: customizePrefixCls, size, $slots } = this; const getPrefixCls = this.configProvider.getPrefixCls; const prefixCls = getPrefixCls('btn-group', customizePrefixCls); diff --git a/components/button/button.jsx b/components/button/button.jsx index 06c79822c..e92b66cda 100644 --- a/components/button/button.jsx +++ b/components/button/button.jsx @@ -36,7 +36,6 @@ export default { sLoading, ghost, block, - sizeMap, icon, $slots, } = this; diff --git a/components/calendar/Header.jsx b/components/calendar/Header.jsx index c7828b484..e69643bdb 100644 --- a/components/calendar/Header.jsx +++ b/components/calendar/Header.jsx @@ -1,7 +1,7 @@ import Select from '../select'; import { Group, Button } from '../radio'; import PropTypes from '../_util/vue-types'; -import { initDefaultProps, getComponentFromProp } from '../_util/props-util'; +import { initDefaultProps } from '../_util/props-util'; import { ConfigConsumerProps } from '../config-provider'; const { Option } = Select; diff --git a/components/calendar/index.jsx b/components/calendar/index.jsx index f3e0b58a5..eabf79009 100644 --- a/components/calendar/index.jsx +++ b/components/calendar/index.jsx @@ -22,7 +22,7 @@ function zerofixed(v) { } export const MomentType = { type: Object, - validator: function(value) { + validator(value) { return moment.isMoment(value); }, }; @@ -207,11 +207,11 @@ const Calendar = { Select: {}, locale: locale.lang, type: mode === 'year' ? 'month' : 'date', - prefixCls: prefixCls, + prefixCls, showHeader: false, - value: value, - monthCellRender: monthCellRender, - dateCellRender: dateCellRender, + value, + monthCellRender, + dateCellRender, disabledDate, }, on: { diff --git a/components/card/__tests__/index.test.js b/components/card/__tests__/index.test.js index 0a6ebb871..cf2cead1b 100644 --- a/components/card/__tests__/index.test.js +++ b/components/card/__tests__/index.test.js @@ -3,8 +3,6 @@ import Card from '../index'; import Button from '../../button/index'; import mountTest from '../../../tests/shared/mountTest'; -const testMethod = typeof window !== 'undefined' ? it : xit; - describe('Card', () => { mountTest(Card); beforeAll(() => { diff --git a/components/cascader/index.jsx b/components/cascader/index.jsx index 66f269262..3957878e8 100644 --- a/components/cascader/index.jsx +++ b/components/cascader/index.jsx @@ -484,7 +484,7 @@ const Cascader = { prefixCls: inputPrefixCls, placeholder: value && value.length > 0 ? undefined : placeholder, value: inputValue, - disabled: disabled, + disabled, readOnly: !showSearch, autoComplete: 'off', }, @@ -535,11 +535,11 @@ const Cascader = { props: { ...props, getPopupContainer, - options: options, + options, prefixCls, - value: value, + value, popupVisible: sPopupVisible, - dropdownMenuColumnStyle: dropdownMenuColumnStyle, + dropdownMenuColumnStyle, expandIcon, loadingIcon, }, diff --git a/components/comment/index.jsx b/components/comment/index.jsx index b9857660c..588849141 100644 --- a/components/comment/index.jsx +++ b/components/comment/index.jsx @@ -1,5 +1,5 @@ import PropsTypes from '../_util/vue-types'; -import { initDefaultProps, getComponentFromProp, getListeners } from '../_util/props-util'; +import { getComponentFromProp, getListeners } from '../_util/props-util'; import { ConfigConsumerProps } from '../config-provider'; import Base from '../base'; export const CommentProps = { diff --git a/components/date-picker/RangePicker.jsx b/components/date-picker/RangePicker.jsx index 0801ea262..24c0f4b96 100644 --- a/components/date-picker/RangePicker.jsx +++ b/components/date-picker/RangePicker.jsx @@ -14,11 +14,9 @@ import { initDefaultProps, mergeProps, getComponentFromProp, - isValidElement, getListeners, } from '../_util/props-util'; import BaseMixin from '../_util/BaseMixin'; -import { cloneElement } from '../_util/vnode'; import { formatDate } from './utils'; import InputIcon from './InputIcon'; @@ -221,7 +219,7 @@ export default { this.$refs.picker.blur(); }, - renderFooter(...args) { + renderFooter() { const { ranges, $scopedSlots, $slots } = this; const { _prefixCls: prefixCls, _tagPrefixCls: tagPrefixCls } = this; const renderExtraFooter = @@ -341,22 +339,22 @@ export default { const rangeCalendarProps = mergeProps(calendarProps, { props: { separator, - format: format, - prefixCls: prefixCls, + format, + prefixCls, renderFooter: this.renderFooter, timePicker: props.timePicker, - disabledDate: disabledDate, - disabledTime: disabledTime, + disabledDate, + disabledTime, dateInputPlaceholder: [startPlaceholder, endPlaceholder], locale: locale.lang, - dateRender: dateRender, + dateRender, value: showDate, - hoverValue: hoverValue, - showToday: showToday, + hoverValue, + showToday, }, on: { change: calendarChange, - ok: ok, + ok, valueChange: this.handleShowDateChange, hoverChange: this.handleHoverChange, panelChange, @@ -419,9 +417,9 @@ export default { pickerChangeHandler, { props: { - calendar: calendar, - value: value, - open: open, + calendar, + value, + open, prefixCls: `${prefixCls}-picker-container`, }, on: { diff --git a/components/date-picker/WeekPicker.jsx b/components/date-picker/WeekPicker.jsx index afeb99726..e1f1e7d5d 100644 --- a/components/date-picker/WeekPicker.jsx +++ b/components/date-picker/WeekPicker.jsx @@ -8,13 +8,11 @@ import { getOptionProps, initDefaultProps, getComponentFromProp, - isValidElement, getListeners, } from '../_util/props-util'; import BaseMixin from '../_util/BaseMixin'; import { WeekPickerProps } from './interface'; import interopDefault from '../_util/interopDefault'; -import { cloneElement } from '../_util/vnode'; import InputIcon from './InputIcon'; function formatValue(value, format) { diff --git a/components/date-picker/createPicker.js b/components/date-picker/createPicker.js index 81ca00b43..40d9e37b0 100644 --- a/components/date-picker/createPicker.js +++ b/components/date-picker/createPicker.js @@ -191,7 +191,7 @@ export default function createPicker(TheCalendar, props) { value: showDate, }, on: { - ok: ok, + ok, panelChange, change: this.handleCalendarChange, }, diff --git a/components/date-picker/interface.js b/components/date-picker/interface.js index 277f00c5e..15ed8fc08 100644 --- a/components/date-picker/interface.js +++ b/components/date-picker/interface.js @@ -4,7 +4,7 @@ import PropTypes from '../_util/vue-types'; export const MomentType = { type: Object, - validator: function(value) { + validator(value) { return value === undefined || moment.isMoment(value); }, }; diff --git a/components/form/Form.jsx b/components/form/Form.jsx index d956d549d..17b03a7d3 100755 --- a/components/form/Form.jsx +++ b/components/form/Form.jsx @@ -133,7 +133,7 @@ const Form = { colon: true, }), Item: FormItem, - createFormField: createFormField, + createFormField, create: (options = {}) => { return createDOMForm({ fieldNameProp: 'id', @@ -246,7 +246,7 @@ const Form = { data() { return { children: $slots.default, - formClassName: formClassName, + formClassName, submit: onSubmit, }; }, diff --git a/components/form/FormItem.jsx b/components/form/FormItem.jsx index 18e96ff48..3d445e4ac 100644 --- a/components/form/FormItem.jsx +++ b/components/form/FormItem.jsx @@ -238,7 +238,7 @@ export default { // Resolve duplicated ids bug between different forms // https://github.com/ant-design/ant-design/issues/7351 - onLabelClick(e) { + onLabelClick() { const id = this.id || this.getId(); if (!id) { return; diff --git a/components/grid/Row.jsx b/components/grid/Row.jsx index 2d48fc7b4..04757e8fe 100644 --- a/components/grid/Row.jsx +++ b/components/grid/Row.jsx @@ -3,15 +3,6 @@ import BaseMixin from '../_util/BaseMixin'; import { ConfigConsumerProps } from '../config-provider'; import ResponsiveObserve from '../_util/responsiveObserve'; -const BreakpointMap = PropTypes.shape({ - xs: PropTypes.number, - sm: PropTypes.number, - md: PropTypes.number, - lg: PropTypes.number, - xl: PropTypes.number, - xxl: PropTypes.number, -}).loose; - const RowProps = { gutter: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]), type: PropTypes.oneOf(['flex']), diff --git a/components/layout/__tests__/index.test.js b/components/layout/__tests__/index.test.js index 2022f4603..3fd46a234 100644 --- a/components/layout/__tests__/index.test.js +++ b/components/layout/__tests__/index.test.js @@ -1,8 +1,6 @@ import { mount } from '@vue/test-utils'; import Vue from 'vue'; import Layout from '..'; -import Icon from '../../icon'; -import Menu from '../../menu'; import mountTest from '../../../tests/shared/mountTest'; const { Sider, Content } = Layout; diff --git a/components/list/Item.jsx b/components/list/Item.jsx index c1f7090bf..20759106f 100644 --- a/components/list/Item.jsx +++ b/components/list/Item.jsx @@ -1,7 +1,6 @@ import PropTypes from '../_util/vue-types'; import classNames from 'classnames'; import { - getSlotOptions, getComponentFromProp, isStringElement, getListeners, diff --git a/components/mentions/__test__/index.test.js b/components/mentions/__test__/index.test.js index a9625d44d..e9f112f01 100644 --- a/components/mentions/__test__/index.test.js +++ b/components/mentions/__test__/index.test.js @@ -1,7 +1,6 @@ import { mount } from '@vue/test-utils'; import Vue from 'vue'; import Mentions from '..'; -import { asyncExpect } from '@/tests/utils'; import focusTest from '../../../tests/shared/focusTest'; const { getMentions } = Mentions; diff --git a/components/mentions/index.jsx b/components/mentions/index.jsx index 8f170d3b0..ada35d658 100644 --- a/components/mentions/index.jsx +++ b/components/mentions/index.jsx @@ -160,7 +160,7 @@ const Mentions = { ...otherProps, disabled, filterOption: this.getFilterOption(), - getPopupContainer: getPopupContainer, + getPopupContainer, children: this.getOptions(), }, class: mergedClassName, diff --git a/components/menu/__tests__/index.test.js b/components/menu/__tests__/index.test.js index 6b26056d4..cc47f2c87 100644 --- a/components/menu/__tests__/index.test.js +++ b/components/menu/__tests__/index.test.js @@ -132,7 +132,7 @@ describe('Menu', () => { props: { openKeys: { type: Array, - default: function() { + default() { return ['1']; }, }, @@ -171,7 +171,7 @@ describe('Menu', () => { props: { openKeys: { type: Array, - default: function() { + default() { return ['1']; }, }, @@ -209,7 +209,7 @@ describe('Menu', () => { props: { openKeys: { type: Array, - default: function() { + default() { return ['1']; }, }, diff --git a/components/menu/index.jsx b/components/menu/index.jsx index d19077b30..1fc146582 100644 --- a/components/menu/index.jsx +++ b/components/menu/index.jsx @@ -79,7 +79,7 @@ const Menu = { inlineCollapsed(val) { this.collapsedChange(val); }, - 'layoutSiderContext.sCollapsed': function(val) { + 'layoutSiderContext.sCollapsed'(val) { this.collapsedChange(val); }, }, diff --git a/components/modal/Modal.jsx b/components/modal/Modal.jsx index 85fb19dfa..13ca61328 100644 --- a/components/modal/Modal.jsx +++ b/components/modal/Modal.jsx @@ -199,7 +199,7 @@ export default { wrapClassName: classNames({ [`${prefixCls}-centered`]: !!centered }, wrapClassName), title, footer: footer === undefined ? defaultFooter : footer, - visible: visible, + visible, mousePosition, closeIcon: closeIconToRender, }, diff --git a/components/modal/__tests__/Modal.test.js b/components/modal/__tests__/Modal.test.js index 50e133f1e..759beecbb 100644 --- a/components/modal/__tests__/Modal.test.js +++ b/components/modal/__tests__/Modal.test.js @@ -1,5 +1,4 @@ import { mount } from '@vue/test-utils'; -import Vue from 'vue'; import Modal from '..'; import mountTest from '../../../tests/shared/mountTest'; diff --git a/components/modal/confirm.js b/components/modal/confirm.js index c319d4654..9eabc437c 100644 --- a/components/modal/confirm.js +++ b/components/modal/confirm.js @@ -46,7 +46,7 @@ export default function confirm(config) { confirmDialogProps.props = props; const V = Base.Vue || Vue; return new V({ - el: el, + el, parent: config.parentContext, data() { return { confirmDialogProps }; diff --git a/components/page-header/index.jsx b/components/page-header/index.jsx index 9d2f6b742..c84fca38d 100644 --- a/components/page-header/index.jsx +++ b/components/page-header/index.jsx @@ -22,6 +22,7 @@ export const PageHeaderProps = { }; const renderBack = (instance, prefixCls, backIcon, onBack) => { + // eslint-disable-next-line no-unused-vars const h = instance.$createElement; if (!backIcon || !onBack) { return null; diff --git a/components/progress/progress.jsx b/components/progress/progress.jsx index eda3b8a98..cf13b631a 100644 --- a/components/progress/progress.jsx +++ b/components/progress/progress.jsx @@ -7,10 +7,6 @@ import Line from './line'; import Circle from './circle'; import { validProgress } from './utils'; -function addUnit(num, unit) { - const unitType = unit || 'px'; - return num ? num + unitType : null; -} const ProgressStatuses = ['normal', 'exception', 'active', 'success']; export const ProgressType = PropTypes.oneOf(['line', 'circle', 'dashboard']); export const ProgressSize = PropTypes.oneOf(['default', 'small']); @@ -91,24 +87,7 @@ export default { }, render() { const props = getOptionProps(this); - const { - prefixCls: customizePrefixCls, - percent = 0, - status, - format, - trailColor, - size, - successPercent, - type, - strokeWidth, - width, - showInfo, - gapDegree = 0, - gapPosition, - strokeColor, - strokeLinecap = 'round', - ...restProps - } = props; + const { prefixCls: customizePrefixCls, size, type, showInfo } = props; const getPrefixCls = this.configProvider.getPrefixCls; const prefixCls = getPrefixCls('progress', customizePrefixCls); const progressStatus = this.getProgressStatus(); @@ -144,9 +123,6 @@ export default { }); const progressProps = { - props: { - ...restProps, - }, on: getListeners(this), class: classString, }; diff --git a/components/radio/Group.jsx b/components/radio/Group.jsx index 0f0815ceb..0b8a6e2d5 100644 --- a/components/radio/Group.jsx +++ b/components/radio/Group.jsx @@ -100,7 +100,7 @@ export default { // 如果存在 options, 优先使用 if (options && options.length > 0) { - children = options.map((option, index) => { + children = options.map(option => { if (typeof option === 'string') { return ( { function createRadioGroup(props, listeners = {}) { diff --git a/components/result/index.jsx b/components/result/index.jsx index e925bffc3..8523753e9 100644 --- a/components/result/index.jsx +++ b/components/result/index.jsx @@ -1,5 +1,5 @@ import PropTypes from '../_util/vue-types'; -import { getOptionProps, getComponentFromProp } from '../_util/props-util'; +import { getComponentFromProp } from '../_util/props-util'; import { ConfigConsumerProps } from '../config-provider'; import Icon from '../icon'; import Base from '../base'; @@ -57,7 +57,7 @@ const Result = { configProvider: { default: () => ConfigConsumerProps }, }, render(h) { - const { prefixCls: customizePrefixCls, status, ...restProps } = this; + const { prefixCls: customizePrefixCls, status } = this; const getPrefixCls = this.configProvider.getPrefixCls; const prefixCls = getPrefixCls('result', customizePrefixCls); diff --git a/components/skeleton/Paragraph.jsx b/components/skeleton/Paragraph.jsx index bc903cafa..098908018 100644 --- a/components/skeleton/Paragraph.jsx +++ b/components/skeleton/Paragraph.jsx @@ -1,5 +1,4 @@ import PropTypes from '../_util/vue-types'; -import { initDefaultProps } from '../_util/props-util'; const widthUnit = PropTypes.oneOfType([PropTypes.number, PropTypes.string]); diff --git a/components/statistic/__tests__/index.test.js b/components/statistic/__tests__/index.test.js index f01c2bc85..f621e745b 100644 --- a/components/statistic/__tests__/index.test.js +++ b/components/statistic/__tests__/index.test.js @@ -1,10 +1,8 @@ import { mount } from '@vue/test-utils'; -import { asyncExpect } from '@/tests/utils'; import MockDate from 'mockdate'; import moment from 'moment'; import Statistic from '..'; import { formatTimeStr } from '../utils'; -import { sleep } from '../../../tests/utils'; import mountTest from '../../../tests/shared/mountTest'; describe('Statistic', () => { diff --git a/components/table/SelectionCheckboxAll.jsx b/components/table/SelectionCheckboxAll.jsx index d9c22771d..dbe4db0f0 100644 --- a/components/table/SelectionCheckboxAll.jsx +++ b/components/table/SelectionCheckboxAll.jsx @@ -114,7 +114,7 @@ export default { watch: { $props: { - handler: function() { + handler() { this.setCheckState(this.$props); }, deep: true, diff --git a/components/table/Table.jsx b/components/table/Table.jsx index 347450c12..4fa86790d 100755 --- a/components/table/Table.jsx +++ b/components/table/Table.jsx @@ -60,8 +60,6 @@ const defaultPagination = { onShowSizeChange: noop, }; -const ROW_SELECTION_COLUMN_WIDTH = '62px'; - /** * Avoid creating new object, so that parent component's shouldComponentUpdate * can works appropriately。 @@ -1050,7 +1048,6 @@ export default { let filterDropdown; let sortButton; let customHeaderCell = column.customHeaderCell; - const title = this.renderColumnTitle(column.title); const isSortColumn = this.isSortColumn(column); if ((column.filters && column.filters.length > 0) || column.filterDropdown) { const colFilters = key in filters ? filters[key] : []; diff --git a/components/table/__tests__/SelectionBox.test.js b/components/table/__tests__/SelectionBox.test.js index 7c6577c3b..e3157c41a 100644 --- a/components/table/__tests__/SelectionBox.test.js +++ b/components/table/__tests__/SelectionBox.test.js @@ -69,7 +69,7 @@ describe('SelectionBox', () => { const store = getDefaultStore(); const wrapper = mount(SelectionBox, { propsData: { - store: store, + store, rowIndex: '1', disabled: false, defaultSelection: [], diff --git a/components/table/__tests__/Table.rowSelection.test.js b/components/table/__tests__/Table.rowSelection.test.js index 711b1b5da..076593aed 100644 --- a/components/table/__tests__/Table.rowSelection.test.js +++ b/components/table/__tests__/Table.rowSelection.test.js @@ -592,7 +592,7 @@ describe('Table.rowSelection', () => { propsData: { columns: filterColumns, dataSource: data, - rowSelection: rowSelection, + rowSelection, }, sync: false, }); @@ -692,7 +692,7 @@ describe('Table.rowSelection', () => { const wrapper = mount(Table, { propsData: { - columns: columns, + columns, dataSource: newDatas, rowSelection: {}, childrenColumnName: 'test', diff --git a/components/table/__tests__/Table.test.js b/components/table/__tests__/Table.test.js index 2f2fb3755..459027b65 100644 --- a/components/table/__tests__/Table.test.js +++ b/components/table/__tests__/Table.test.js @@ -107,7 +107,7 @@ describe('Table', () => { dataIndex: 'age', key: 'age', align: 'center', - customCell: (record, rowIndex) => { + customCell: () => { return { style: { color: 'red', diff --git a/components/tooltip/Tooltip.jsx b/components/tooltip/Tooltip.jsx index fe94edd65..f4c0977ad 100644 --- a/components/tooltip/Tooltip.jsx +++ b/components/tooltip/Tooltip.jsx @@ -107,7 +107,7 @@ export default { display: 'inline-block', // default inline-block is important ...picked, cursor: 'not-allowed', - width: isAntBtn && ele.componentOptions.propsData.block ? '100%' : null, + width: ele.componentOptions.propsData.block ? '100%' : null, }; const buttonStyle = { ...omitted, diff --git a/components/tree/Tree.jsx b/components/tree/Tree.jsx index 7649990b1..05623c5b9 100644 --- a/components/tree/Tree.jsx +++ b/components/tree/Tree.jsx @@ -7,7 +7,6 @@ import { getOptionProps, filterEmpty, getComponentFromProp, - getClass, getListeners, } from '../_util/props-util'; import { cloneElement } from '../_util/vnode'; diff --git a/components/upload/Upload.jsx b/components/upload/Upload.jsx index 528cd039e..83a30751f 100644 --- a/components/upload/Upload.jsx +++ b/components/upload/Upload.jsx @@ -19,7 +19,7 @@ export default { name: 'AUpload', mixins: [BaseMixin], inheritAttrs: false, - Dragger: Dragger, + Dragger, props: initDefaultProps(UploadProps, { type: 'select', multiple: false, diff --git a/components/vc-calendar/src/RangeCalendar.jsx b/components/vc-calendar/src/RangeCalendar.jsx index 73f00dfc2..1a35d07be 100644 --- a/components/vc-calendar/src/RangeCalendar.jsx +++ b/components/vc-calendar/src/RangeCalendar.jsx @@ -731,7 +731,7 @@ const RangeCalendar = { mode: mode[0], placeholder: placeholder1, showDateInput: this.showDateInput, - timePicker: timePicker, + timePicker, showTimePicker: sShowTimePicker || mode[0] === 'time', enablePrev: true, enableNext: !isClosestMonths || this.isMonthYearPanelShow(mode[1]), @@ -754,7 +754,7 @@ const RangeCalendar = { value: endValue, mode: mode[1], showDateInput: this.showDateInput, - timePicker: timePicker, + timePicker, showTimePicker: sShowTimePicker || mode[1] === 'time', disabledTime: this.disabledEndTime, disabledMonth: this.disabledEndMonth, diff --git a/components/vc-calendar/src/calendar/CalendarFooter.jsx b/components/vc-calendar/src/calendar/CalendarFooter.jsx index ddad73528..5c807a0be 100644 --- a/components/vc-calendar/src/calendar/CalendarFooter.jsx +++ b/components/vc-calendar/src/calendar/CalendarFooter.jsx @@ -44,7 +44,7 @@ const CalendarFooter = { const btnProps = { props: { ...props, - value: value, + value, }, on: getListeners(this), }; diff --git a/components/vc-cascader/Cascader.jsx b/components/vc-cascader/Cascader.jsx index 0e9bedab6..a290768c5 100644 --- a/components/vc-cascader/Cascader.jsx +++ b/components/vc-cascader/Cascader.jsx @@ -363,9 +363,9 @@ export default { const triggerProps = { props: { ...restProps, - disabled: disabled, - popupPlacement: popupPlacement, - builtinPlacements: builtinPlacements, + disabled, + popupPlacement, + builtinPlacements, popupTransitionName: transitionName, action: disabled ? [] : ['click'], popupVisible: disabled ? false : sPopupVisible, diff --git a/components/vc-collapse/src/Panel.jsx b/components/vc-collapse/src/Panel.jsx index a840eaea6..2a9152f40 100644 --- a/components/vc-collapse/src/Panel.jsx +++ b/components/vc-collapse/src/Panel.jsx @@ -1,6 +1,5 @@ import PanelContent from './PanelContent'; import { initDefaultProps, getComponentFromProp } from '../../_util/props-util'; -import { cloneElement } from '../../_util/vnode'; import { panelProps } from './commonProps'; export default { diff --git a/components/vc-dropdown/src/Dropdown.jsx b/components/vc-dropdown/src/Dropdown.jsx index 4b08d2172..fe28e6cc3 100644 --- a/components/vc-dropdown/src/Dropdown.jsx +++ b/components/vc-dropdown/src/Dropdown.jsx @@ -191,7 +191,7 @@ export default { popupAnimation: animation, popupVisible: this.sVisible, afterPopupVisibleChange: this.afterVisibleChange, - getPopupContainer: getPopupContainer, + getPopupContainer, }, on: { popupVisibleChange: this.onVisibleChange, diff --git a/components/vc-form/src/createBaseForm.jsx b/components/vc-form/src/createBaseForm.jsx index 21b5baa30..2e4942fe1 100644 --- a/components/vc-form/src/createBaseForm.jsx +++ b/components/vc-form/src/createBaseForm.jsx @@ -96,7 +96,7 @@ function createBaseForm(option = {}, mixins = []) { ? {} : { $props: { - handler: function(nextProps) { + handler(nextProps) { if (mapPropsToFields) { this.fieldsStore.updateFields(mapPropsToFields(nextProps)); } diff --git a/components/vc-input-number/src/index.js b/components/vc-input-number/src/index.js index e0f2c5cd0..40a5748cf 100755 --- a/components/vc-input-number/src/index.js +++ b/components/vc-input-number/src/index.js @@ -3,7 +3,6 @@ import PropTypes from '../../_util/vue-types'; import BaseMixin from '../../_util/BaseMixin'; import { initDefaultProps, hasProp, getOptionProps, getListeners } from '../../_util/props-util'; import classNames from 'classnames'; -import isNegativeZero from 'is-negative-zero'; import KeyCode from '../../_util/KeyCode'; import InputHandler from './InputHandler'; diff --git a/components/vc-menu/Menu.jsx b/components/vc-menu/Menu.jsx index ff5d4b949..6e044e770 100644 --- a/components/vc-menu/Menu.jsx +++ b/components/vc-menu/Menu.jsx @@ -65,7 +65,7 @@ const Menu = { } this.__emit('select', { ...selectInfo, - selectedKeys: selectedKeys, + selectedKeys, }); } }, @@ -128,7 +128,7 @@ const Menu = { } this.__emit('deselect', { ...selectInfo, - selectedKeys: selectedKeys, + selectedKeys, }); } }, diff --git a/components/vc-menu/SubMenu.jsx b/components/vc-menu/SubMenu.jsx index 31899bded..4d5c87eda 100644 --- a/components/vc-menu/SubMenu.jsx +++ b/components/vc-menu/SubMenu.jsx @@ -10,7 +10,6 @@ import { getComponentFromProp, filterEmpty, getListeners } from '../_util/props- import { requestAnimationTimeout, cancelAnimationTimeout } from '../_util/requestAnimationTimeout'; import { noop, loopMenuItemRecursively, getMenuIdFromSubMenuEventKey } from './util'; import getTransitionProps from '../_util/getTransitionProps'; -import { MenuItem } from './MenuItem'; let guid = 0; diff --git a/components/vc-pagination/Options.jsx b/components/vc-pagination/Options.jsx index e6322ca4d..aef1f2975 100644 --- a/components/vc-pagination/Options.jsx +++ b/components/vc-pagination/Options.jsx @@ -38,7 +38,7 @@ export default { goInputText: value, }); }, - handleBlur() { + handleBlur(e) { const { goButton, quickGo, rootPrefixCls } = this.$props; if (goButton) { return; diff --git a/components/vc-select/Select.jsx b/components/vc-select/Select.jsx index 13c1def99..69b85c6b0 100644 --- a/components/vc-select/Select.jsx +++ b/components/vc-select/Select.jsx @@ -181,7 +181,7 @@ const Select = { __propsSymbol__() { Object.assign(this.$data, this.getDerivedStateFromProps(getOptionProps(this), this.$data)); }, - '$data._inputValue': function(val) { + '$data._inputValue'(val) { this.$data._mirrorInputValue = val; }, }, @@ -417,7 +417,7 @@ const Select = { // Aviod trigger form submit when select item // https://github.com/ant-design/ant-design/issues/10861 // https://github.com/ant-design/ant-design/issues/14544 - if (isRealOpen || !props.combobox) { + if (isRealOpen || !combobox) { event.preventDefault(); } // Hard close popup to avoid lock of non option in combobox mode @@ -1149,7 +1149,7 @@ const Select = { }, renderFilterOptions() { const { _inputValue: inputValue } = this.$data; - const { children, tags, filterOption, notFoundContent } = this.$props; + const { children, tags, notFoundContent } = this.$props; const menuItems = []; const childrenKeys = []; let empty = false; @@ -1545,7 +1545,7 @@ const Select = { return null; }, - selectionRefClick(e) { + selectionRefClick() { //e.stopPropagation(); if (!this.disabled) { const input = this.getInputDOMNode(); diff --git a/components/vc-slick/src/arrows.js b/components/vc-slick/src/arrows.js index bdc510629..25fd57a77 100644 --- a/components/vc-slick/src/arrows.js +++ b/components/vc-slick/src/arrows.js @@ -39,8 +39,8 @@ export const PrevArrow = { }, }; const customProps = { - currentSlide: currentSlide, - slideCount: slideCount, + currentSlide, + slideCount, }; let prevArrow; @@ -110,8 +110,8 @@ export const NextArrow = { }, }; const customProps = { - currentSlide: currentSlide, - slideCount: slideCount, + currentSlide, + slideCount, }; let nextArrow; diff --git a/components/vc-slick/src/dots.js b/components/vc-slick/src/dots.js index 250d9396c..a4fb77b44 100644 --- a/components/vc-slick/src/dots.js +++ b/components/vc-slick/src/dots.js @@ -29,10 +29,10 @@ export default { dotsClass, } = props; const dotCount = getDotCount({ - slideCount: slideCount, - slidesToScroll: slidesToScroll, - slidesToShow: slidesToShow, - infinite: infinite, + slideCount, + slidesToScroll, + slidesToShow, + infinite, }); // Apply join & split to Array to pre-fill it for IE8 @@ -55,8 +55,8 @@ export default { const dotOptions = { message: 'dots', index: i, - slidesToScroll: slidesToScroll, - currentSlide: currentSlide, + slidesToScroll, + currentSlide, }; function onClick(e) { // In Autoplay the focus stays on clicked button even after transition diff --git a/components/vc-slick/src/inner-slider.js b/components/vc-slick/src/inner-slider.js index a7b9cf0cc..9778b77ef 100644 --- a/components/vc-slick/src/inner-slider.js +++ b/components/vc-slick/src/inner-slider.js @@ -161,7 +161,7 @@ export default { }; this.setState({ slideWidth: slideWidth + '%', - trackStyle: trackStyle, + trackStyle, }); }, checkImagesLoad() { diff --git a/components/vc-slick/src/slider.js b/components/vc-slick/src/slider.js index 8caddc8e8..999627d61 100644 --- a/components/vc-slick/src/slider.js +++ b/components/vc-slick/src/slider.js @@ -73,7 +73,7 @@ export default { // when not using server side rendering canUseDOM() && this.media(bQuery, () => { - this.setState({ breakpoint: breakpoint }); + this.setState({ breakpoint }); }); }); diff --git a/components/vc-slick/src/track.js b/components/vc-slick/src/track.js index 503a97e90..20ed21ee0 100644 --- a/components/vc-slick/src/track.js +++ b/components/vc-slick/src/track.js @@ -88,7 +88,7 @@ const renderSlides = function(spec, children, createElement) { let child; const childOnClickOptions = { message: 'children', - index: index, + index, slidesToScroll: spec.slidesToScroll, currentSlide: spec.currentSlide, }; diff --git a/components/vc-slider/src/Range.jsx b/components/vc-slider/src/Range.jsx index 151167397..740ed5d80 100644 --- a/components/vc-slider/src/Range.jsx +++ b/components/vc-slider/src/Range.jsx @@ -185,7 +185,7 @@ const Range = { const value = trimAlignValue({ value: mutatedValue, handle: sHandle, - bounds: bounds, + bounds, props: this.$props, }); if (value === oldValue) return; diff --git a/components/vc-table/src/BaseTable.jsx b/components/vc-table/src/BaseTable.jsx index d29fdc4fb..fe152d1de 100644 --- a/components/vc-table/src/BaseTable.jsx +++ b/components/vc-table/src/BaseTable.jsx @@ -110,7 +110,7 @@ const BaseTable = { record, index: i, prefixCls: rowPrefixCls, - childrenColumnName: childrenColumnName, + childrenColumnName, columns: leafColumns, rowKey: key, ancestorKeys, diff --git a/components/vc-tabs/src/TabBarTabsNode.jsx b/components/vc-tabs/src/TabBarTabsNode.jsx index 3fb7f17a5..8bab1b939 100644 --- a/components/vc-tabs/src/TabBarTabsNode.jsx +++ b/components/vc-tabs/src/TabBarTabsNode.jsx @@ -72,7 +72,7 @@ export default { class={cls} key={key} style={style} - {...{ directives: directives }} + {...{ directives }} > {tab} diff --git a/components/vc-tabs/src/TabContent.jsx b/components/vc-tabs/src/TabContent.jsx index 35e3d340d..207a1e22d 100644 --- a/components/vc-tabs/src/TabContent.jsx +++ b/components/vc-tabs/src/TabContent.jsx @@ -57,7 +57,7 @@ export default { }, }, render() { - const { activeKey, tabBarPosition, animated, animatedWithMargin, classes } = this; + const { activeKey, tabBarPosition, animated, animatedWithMargin, direction, classes } = this; let style = {}; if (animated && this.$slots.default) { const activeIndex = getActiveIndex(this.$slots.default, activeKey); diff --git a/components/vc-time-picker/Header.jsx b/components/vc-time-picker/Header.jsx index 04d53cb29..5ab94db92 100644 --- a/components/vc-time-picker/Header.jsx +++ b/components/vc-time-picker/Header.jsx @@ -1,8 +1,6 @@ import PropTypes from '../_util/vue-types'; import BaseMixin from '../_util/BaseMixin'; import moment from 'moment'; -import { getComponentFromProp } from '../_util/props-util'; -import { isIE, isIE9 } from '../_util/env'; const Header = { mixins: [BaseMixin], diff --git a/components/vc-time-picker/Panel.jsx b/components/vc-time-picker/Panel.jsx index 8f12cdff1..f560d2726 100644 --- a/components/vc-time-picker/Panel.jsx +++ b/components/vc-time-picker/Panel.jsx @@ -129,7 +129,6 @@ const Panel = { addon, disabledSeconds, hideDisabledOptions, - allowEmpty, showHour, showMinute, showSecond, @@ -146,7 +145,7 @@ const Panel = { currentSelectPanel, } = this; const clearIcon = getComponentFromProp(this, 'clearIcon'); - const { esc = noop, clear = noop, keydown = noop } = getListeners(this); + const { esc = noop, keydown = noop } = getListeners(this); const disabledHourOptions = this.disabledHours2(); const disabledMinuteOptions = disabledMinutes(sValue ? sValue.hour() : null); diff --git a/components/vc-time-picker/Select.jsx b/components/vc-time-picker/Select.jsx index 4cf15a920..78e42e331 100644 --- a/components/vc-time-picker/Select.jsx +++ b/components/vc-time-picker/Select.jsx @@ -5,11 +5,6 @@ import raf from 'raf'; function noop() {} const scrollTo = (element, to, duration) => { - const requestAnimationFrame = - window.requestAnimationFrame || - function requestAnimationFrameTimeout() { - return setTimeout(arguments[0], 10); - }; // jump to target if duration zero if (duration <= 0) { raf(() => { diff --git a/components/vc-time-picker/TimePicker.jsx b/components/vc-time-picker/TimePicker.jsx index 738c1da31..4a757ccfc 100644 --- a/components/vc-time-picker/TimePicker.jsx +++ b/components/vc-time-picker/TimePicker.jsx @@ -192,7 +192,6 @@ export default { disabledSeconds, hideDisabledOptions, inputReadOnly, - allowEmpty, showHour, showMinute, showSecond, diff --git a/components/vc-tooltip/Tooltip.jsx b/components/vc-tooltip/Tooltip.jsx index fa33b058f..e38cbe478 100644 --- a/components/vc-tooltip/Tooltip.jsx +++ b/components/vc-tooltip/Tooltip.jsx @@ -73,7 +73,7 @@ export default { const triggerProps = { props: { popupClassName: overlayClassName, - prefixCls: prefixCls, + prefixCls, action: trigger, builtinPlacements: placements, popupPlacement: placement, @@ -84,9 +84,9 @@ export default { popupAnimation: animation, defaultPopupVisible: defaultVisible, destroyPopupOnHide: destroyTooltipOnHide, - mouseLeaveDelay: mouseLeaveDelay, + mouseLeaveDelay, popupStyle: overlayStyle, - mouseEnterDelay: mouseEnterDelay, + mouseEnterDelay, ...extraProps, }, on: { diff --git a/components/vc-tree-select/src/Base/BasePopup.jsx b/components/vc-tree-select/src/Base/BasePopup.jsx index 8494e6d5b..6de0cede9 100644 --- a/components/vc-tree-select/src/Base/BasePopup.jsx +++ b/components/vc-tree-select/src/Base/BasePopup.jsx @@ -255,12 +255,12 @@ const BasePopup = { selectable: !treeCheckable, checkable: treeCheckable, checkStrictly: treeCheckStrictly, - multiple: multiple, - loadData: loadData, - loadedKeys: loadedKeys, + multiple, + loadData, + loadedKeys, expandedKeys: expandedKeyList, filterTreeNode: this.filterTreeNode, - switcherIcon: switcherIcon, + switcherIcon, ...treeProps, __propsSymbol__: Symbol(), children: $treeNodes, diff --git a/components/vc-tree-select/src/Select.jsx b/components/vc-tree-select/src/Select.jsx index 86ca875ff..81e770043 100644 --- a/components/vc-tree-select/src/Select.jsx +++ b/components/vc-tree-select/src/Select.jsx @@ -219,12 +219,12 @@ const Select = { this.setState(state); this.needSyncKeys = {}; }, - '$data._valueList': function() { + '$data._valueList'() { this.$nextTick(() => { this.forcePopupAlign(); }); }, - '$data._open': function() { + '$data._open'() { this.$nextTick(() => { const { prefixCls } = this.$props; const { _selectorValueList: selectorValueList, _valueEntities: valueEntities } = this.$data; diff --git a/components/vc-tree-select/src/util.js b/components/vc-tree-select/src/util.js index c8b6ea133..c0d30e884 100644 --- a/components/vc-tree-select/src/util.js +++ b/components/vc-tree-select/src/util.js @@ -350,7 +350,7 @@ function processProps(props) { props: omit(props, ['on', 'key', 'class', 'className', 'style']), on, class: cls || props.className, - style: style, + style, key, }; // Warning user not to use deprecated label prop. diff --git a/components/vc-tree/src/TreeNode.jsx b/components/vc-tree/src/TreeNode.jsx index fab9b9846..112ebd763 100644 --- a/components/vc-tree/src/TreeNode.jsx +++ b/components/vc-tree/src/TreeNode.jsx @@ -4,7 +4,6 @@ import { getNodeChildren, mapChildren, warnOnlyTreeNode } from './util'; import { initDefaultProps, filterEmpty, getComponentFromProp } from '../../_util/props-util'; import BaseMixin from '../../_util/BaseMixin'; import getTransitionProps from '../../_util/getTransitionProps'; -import { cloneElement } from '../../_util/vnode'; function noop() {} const ICON_OPEN = 'open'; diff --git a/components/vc-trigger/Trigger.jsx b/components/vc-trigger/Trigger.jsx index 909bb6367..f7fd90848 100644 --- a/components/vc-trigger/Trigger.jsx +++ b/components/vc-trigger/Trigger.jsx @@ -112,7 +112,7 @@ export default { this.prevPopupVisible = val; } }, - sPopupVisible(val) { + sPopupVisible() { this.$nextTick(() => { this.renderComponent(null, () => { this.afterPopupVisibleChange(this.sPopupVisible);