From 24549cfbbb47ef1deb85e8fa8fa24f128eb23048 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Fri, 14 Dec 2018 09:56:40 +0800 Subject: [PATCH] style: lint --- .eslintignore | 1 + components/anchor/Anchor.jsx | 2 +- components/calendar/__tests__/index.test.js | 1 - components/card/Card.jsx | 2 +- components/collapse/Collapse.jsx | 2 - components/drawer/index.jsx | 3 +- components/form/FormItem.jsx | 2 +- components/grid/Row.jsx | 2 - components/icon/__tests__/index.test.js | 3 -- components/list/__tests__/loading.test.js | 1 - components/menu/MenuItem.jsx | 3 +- components/menu/__tests__/index.test.js | 8 +-- components/popconfirm/__tests__/index.test.js | 8 +-- components/radio/RadioButton.jsx | 1 - components/tabs/__tests__/index.test.js | 1 - components/tooltip/__tests__/tooltip.test.js | 1 - components/transfer/index.jsx | 5 -- components/vc-dialog/Dialog.jsx | 2 +- components/vc-drawer/demo/multiple.jsx | 5 -- components/vc-drawer/demo/placement.jsx | 3 -- components/vc-input-number/demo/index.vue | 6 +++ components/vc-menu/DOMWrap.jsx | 4 +- components/vc-table/src/BaseTable.jsx | 2 +- components/vc-tree-select/src/PropTypes.js | 52 ------------------- .../vc-tree-select/src/SelectTrigger.jsx | 5 +- components/vc-tree-select/src/util.js | 2 +- components/vc-tree/demo/basic.jsx | 4 +- components/vc-trigger/Popup.jsx | 3 +- 28 files changed, 29 insertions(+), 105 deletions(-) diff --git a/.eslintignore b/.eslintignore index 4c64b6f77..0c337a6d9 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,4 @@ node_modules/ **/*.spec.* **/style/ *.html +/components/test/* diff --git a/components/anchor/Anchor.jsx b/components/anchor/Anchor.jsx index 2667626e7..a0ea8be4a 100644 --- a/components/anchor/Anchor.jsx +++ b/components/anchor/Anchor.jsx @@ -4,7 +4,7 @@ import addEventListener from '../_util/Dom/addEventListener' import Affix from '../affix' import getScroll from '../_util/getScroll' import raf from 'raf' -import { initDefaultProps, getClass, getStyle } from '../_util/props-util' +import { initDefaultProps, getClass } from '../_util/props-util' import BaseMixin from '../_util/BaseMixin' function getDefaultContainer () { diff --git a/components/calendar/__tests__/index.test.js b/components/calendar/__tests__/index.test.js index bc7e9b586..2ec381db6 100644 --- a/components/calendar/__tests__/index.test.js +++ b/components/calendar/__tests__/index.test.js @@ -2,7 +2,6 @@ import Moment from 'moment' import { mount } from '@vue/test-utils' import { asyncExpect } from '@/tests/utils' import MockDate from 'mockdate' -import Vue from 'vue' import Calendar from '..' function $$ (className) { diff --git a/components/card/Card.jsx b/components/card/Card.jsx index 31e218fb7..96960b3ac 100644 --- a/components/card/Card.jsx +++ b/components/card/Card.jsx @@ -4,7 +4,7 @@ import Row from '../row' import Col from '../col' import PropTypes from '../_util/vue-types' import addEventListener from '../_util/Dom/addEventListener' -import { getComponentFromProp, getSlotOptions, isEmptyElement, filterEmpty } from '../_util/props-util' +import { getComponentFromProp, getSlotOptions, filterEmpty } from '../_util/props-util' import throttleByAnimationFrame from '../_util/throttleByAnimationFrame' import BaseMixin from '../_util/BaseMixin' diff --git a/components/collapse/Collapse.jsx b/components/collapse/Collapse.jsx index c0a850bea..a6d8aaae3 100644 --- a/components/collapse/Collapse.jsx +++ b/components/collapse/Collapse.jsx @@ -1,5 +1,3 @@ - -import PropTypes from '../_util/vue-types' import animation from '../_util/openAnimation' import { getOptionProps, initDefaultProps } from '../_util/props-util' import VcCollapse, { collapseProps } from '../vc-collapse' diff --git a/components/drawer/index.jsx b/components/drawer/index.jsx index 81dd88e93..c422588a7 100644 --- a/components/drawer/index.jsx +++ b/components/drawer/index.jsx @@ -1,10 +1,9 @@ -import warning from 'warning' import classNames from 'classnames' import VcDrawer from '../vc-drawer/src' import PropTypes from '../_util/vue-types' import BaseMixin from '../_util/BaseMixin' import Icon from '../icon' -import { getComponentFromProp, getOptionProps, getClass } from '../_util/props-util' +import { getComponentFromProp, getOptionProps } from '../_util/props-util' const Drawer = { name: 'ADrawer', diff --git a/components/form/FormItem.jsx b/components/form/FormItem.jsx index dd7e1bca8..fcc13d0d0 100644 --- a/components/form/FormItem.jsx +++ b/components/form/FormItem.jsx @@ -6,7 +6,7 @@ import Row from '../grid/Row' import Col, { ColProps } from '../grid/Col' import warning from '../_util/warning' import { FIELD_META_PROP, FIELD_DATA_PROP } from './constants' -import { initDefaultProps, getComponentFromProp, filterEmpty, getSlotOptions, isValidElement, getSlots, getAllChildren } from '../_util/props-util' +import { initDefaultProps, getComponentFromProp, filterEmpty, getSlotOptions, isValidElement, getAllChildren } from '../_util/props-util' import getTransitionProps from '../_util/getTransitionProps' import BaseMixin from '../_util/BaseMixin' import { cloneElement, cloneVNodes } from '../_util/vnode' diff --git a/components/grid/Row.jsx b/components/grid/Row.jsx index 334e0781a..09e77bb1d 100644 --- a/components/grid/Row.jsx +++ b/components/grid/Row.jsx @@ -1,8 +1,6 @@ import PropTypes from '../_util/vue-types' import BaseMixin from '../_util/BaseMixin' -import { cloneElement } from '../_util/vnode' -import { isEmptyElement, getStyle, getOptionProps } from '../_util/props-util' // matchMedia polyfill for // https://github.com/WickyNilliams/enquire.js/issues/82 let enquire = null diff --git a/components/icon/__tests__/index.test.js b/components/icon/__tests__/index.test.js index f19340103..fb35cc768 100644 --- a/components/icon/__tests__/index.test.js +++ b/components/icon/__tests__/index.test.js @@ -1,7 +1,6 @@ import { mount } from '@vue/test-utils' import Icon from '..' import VueIcon from '@ant-design/icons-vue' -import Tooltip from '../../tooltip' import { getThemeFromTypeName, withThemeSuffix } from '../utils' import { cloneElement } from '../../_util/vnode' @@ -125,7 +124,6 @@ describe('Icon', () => { render () { const component = { render () { - console.log(this.$slots.default) return ( @@ -137,7 +135,6 @@ describe('Icon', () => { { this.$slots.default.map( child => { - console.log(child) cloneElement(child, { attrs: child.type === 'path' ? { fill: 'scriptUrl(#gradient)' } : {}}) } ) diff --git a/components/list/__tests__/loading.test.js b/components/list/__tests__/loading.test.js index 718447f67..822fa3dae 100644 --- a/components/list/__tests__/loading.test.js +++ b/components/list/__tests__/loading.test.js @@ -1,5 +1,4 @@ import { mount } from '@vue/test-utils' -import { asyncExpect } from '@/tests/utils' import List from '..' import Icon from '../../icon' diff --git a/components/menu/MenuItem.jsx b/components/menu/MenuItem.jsx index eb019abee..d05574ed4 100644 --- a/components/menu/MenuItem.jsx +++ b/components/menu/MenuItem.jsx @@ -1,7 +1,6 @@ import { Item, itemProps } from '../vc-menu' -import { getClass, getStyle, getOptionProps } from '../_util/props-util' -import { cloneVNodes } from '../_util/vnode' +import { getOptionProps } from '../_util/props-util' import Tooltip from '../tooltip' function noop () {} export default { diff --git a/components/menu/__tests__/index.test.js b/components/menu/__tests__/index.test.js index 0670bb9b4..155820da5 100644 --- a/components/menu/__tests__/index.test.js +++ b/components/menu/__tests__/index.test.js @@ -24,7 +24,7 @@ describe('Menu', () => { // jest.useRealTimers() }) it('If has select nested submenu item ,the menu items on the grandfather level should be highlight', async () => { - const wrapper = mount({ + mount({ render () { return ( @@ -46,7 +46,7 @@ describe('Menu', () => { }) }) it('should accept defaultOpenKeys in mode horizontal', async () => { - const wrapper = mount({ + mount({ render () { return ( @@ -65,7 +65,7 @@ describe('Menu', () => { }) it('should accept defaultOpenKeys in mode inline', async () => { - const wrapper = mount({ + mount({ render () { return ( @@ -84,7 +84,7 @@ describe('Menu', () => { }) it('should accept defaultOpenKeys in mode vertical', async () => { - const wrapper = mount({ + mount({ render () { return ( diff --git a/components/popconfirm/__tests__/index.test.js b/components/popconfirm/__tests__/index.test.js index 96ada5b63..374566c9d 100644 --- a/components/popconfirm/__tests__/index.test.js +++ b/components/popconfirm/__tests__/index.test.js @@ -5,10 +5,10 @@ function $$ (className) { return document.body.querySelectorAll(className) } describe('Popconfirm', () => { - const eventObject = expect.objectContaining({ - target: expect.anything(), - preventDefault: expect.any(Function), - }) + // const eventObject = expect.objectContaining({ + // target: expect.anything(), + // preventDefault: expect.any(Function), + // }) it('should popup Popconfirm dialog', async () => { const onVisibleChange = jest.fn() diff --git a/components/radio/RadioButton.jsx b/components/radio/RadioButton.jsx index c99938544..810c10668 100644 --- a/components/radio/RadioButton.jsx +++ b/components/radio/RadioButton.jsx @@ -1,5 +1,4 @@ import Radio from './Radio' -import Wave from '../_util/wave' import { getOptionProps } from '../_util/props-util' export default { diff --git a/components/tabs/__tests__/index.test.js b/components/tabs/__tests__/index.test.js index 0d2adf049..73771e1f5 100644 --- a/components/tabs/__tests__/index.test.js +++ b/components/tabs/__tests__/index.test.js @@ -1,5 +1,4 @@ import { mount } from '@vue/test-utils' -import { asyncExpect } from '@/tests/utils' import Tabs from '..' const { TabPane } = Tabs diff --git a/components/tooltip/__tests__/tooltip.test.js b/components/tooltip/__tests__/tooltip.test.js index 792846bbc..019fc3c35 100644 --- a/components/tooltip/__tests__/tooltip.test.js +++ b/components/tooltip/__tests__/tooltip.test.js @@ -1,7 +1,6 @@ import { asyncExpect } from '@/tests/utils' import { mount } from '@vue/test-utils' import Tooltip from '..' -import Button from '../../button' describe('Tooltip', () => { it('check `onVisibleChange` arguments', async () => { diff --git a/components/transfer/index.jsx b/components/transfer/index.jsx index 7c50168b0..c38159189 100644 --- a/components/transfer/index.jsx +++ b/components/transfer/index.jsx @@ -4,14 +4,9 @@ import BaseMixin from '../_util/BaseMixin' import classNames from 'classnames' import List from './list' import Operation from './operation' -// import Search from './search' -import warning from '../_util/warning' import LocaleReceiver from '../locale-provider/LocaleReceiver' import defaultLocale from '../locale-provider/default' -// function noop () { -// } - export const TransferDirection = 'left' | 'right' export const TransferItem = { diff --git a/components/vc-dialog/Dialog.jsx b/components/vc-dialog/Dialog.jsx index cd396f723..1a6c03ae2 100644 --- a/components/vc-dialog/Dialog.jsx +++ b/components/vc-dialog/Dialog.jsx @@ -191,7 +191,7 @@ export default { }, getDialogElement () { const { closable, prefixCls, width, height, - title, footer: tempFooter, bodyStyle, visible, bodyProps, $props } = this + title, footer: tempFooter, bodyStyle, visible, bodyProps } = this const dest = {} if (width !== undefined) { dest.width = typeof width === 'number' ? `${width}px` : width diff --git a/components/vc-drawer/demo/multiple.jsx b/components/vc-drawer/demo/multiple.jsx index 67e8942cf..41f6016f5 100644 --- a/components/vc-drawer/demo/multiple.jsx +++ b/components/vc-drawer/demo/multiple.jsx @@ -1,15 +1,10 @@ import Drawer from '../src/index' -import Menu from '../../menu/index' -import Icon from '../../icon/index' import Button from '../../button/index' import '../assets/index.less' import '../../menu/style/index' import '../../icon/style/index' import '../../button/style/index' -const SubMenu = Menu.SubMenu -const MenuItemGroup = Menu.ItemGroup - export default { data () { return { diff --git a/components/vc-drawer/demo/placement.jsx b/components/vc-drawer/demo/placement.jsx index 7c27c6811..52a9745ad 100644 --- a/components/vc-drawer/demo/placement.jsx +++ b/components/vc-drawer/demo/placement.jsx @@ -1,8 +1,6 @@ import Drawer from '../src/index' import Menu from '../../menu/index' import Icon from '../../icon/index' -import Button from '../../button/index' -import Select from '../../select/index' import '../assets/index.less' import '../../menu/style/index' import '../../icon/style/index' @@ -11,7 +9,6 @@ import '../../select/style/index' const SubMenu = Menu.SubMenu const MenuItemGroup = Menu.ItemGroup -const Option = Select.Option export default { data () { diff --git a/components/vc-input-number/demo/index.vue b/components/vc-input-number/demo/index.vue index 128fca71d..b987b9bf5 100644 --- a/components/vc-input-number/demo/index.vue +++ b/components/vc-input-number/demo/index.vue @@ -12,6 +12,12 @@ export default { return (
+ + + + + +
) }, diff --git a/components/vc-menu/DOMWrap.jsx b/components/vc-menu/DOMWrap.jsx index 2adbf74e5..ec01b2dcc 100644 --- a/components/vc-menu/DOMWrap.jsx +++ b/components/vc-menu/DOMWrap.jsx @@ -4,7 +4,7 @@ import SubMenu from './SubMenu' import BaseMixin from '../_util/BaseMixin' import { getWidth, setStyle, menuAllProps } from './util' import { cloneElement } from '../_util/vnode' -import { getClass, getPropsData, filterEmpty } from '../_util/props-util' +import { getClass, getPropsData } from '../_util/props-util' const canUseDOM = !!( typeof window !== 'undefined' && @@ -104,7 +104,7 @@ const DOMWrap = { // put all the overflowed item inside a submenu // with a title of overflow indicator ('...') const copy = this.$slots.default[0] - const { title, eventKey, ...rest } = getPropsData(copy) + const { title, eventKey, ...rest } = getPropsData(copy) // eslint-disable-line no-unused-vars let style = {} let key = `${keyPrefix}-overflowed-indicator` diff --git a/components/vc-table/src/BaseTable.jsx b/components/vc-table/src/BaseTable.jsx index 35988f981..81aed2694 100644 --- a/components/vc-table/src/BaseTable.jsx +++ b/components/vc-table/src/BaseTable.jsx @@ -5,7 +5,7 @@ import ColGroup from './ColGroup' import TableHeader from './TableHeader' import TableRow from './TableRow' import ExpandableRow from './ExpandableRow' -import { mergeProps, getOptionProps } from '../../_util/props-util' +import { mergeProps } from '../../_util/props-util' import { connect } from '../../_util/store' function noop () {} const BaseTable = { diff --git a/components/vc-tree-select/src/PropTypes.js b/components/vc-tree-select/src/PropTypes.js index 661715f66..e6495bb03 100644 --- a/components/vc-tree-select/src/PropTypes.js +++ b/components/vc-tree-select/src/PropTypes.js @@ -1,58 +1,6 @@ import PropTypes from '../../_util/vue-types' import { SHOW_ALL, SHOW_PARENT, SHOW_CHILD } from './strategies' -function nonEmptyStringType (props, propsName) { - const value = props[propsName] - if (typeof value !== 'string' || !value) { - return new Error() // Just a flag, so don't need message. - } -} - -function valueType (props, propName, componentName) { - const labelInValueShape = PropTypes.shape({ - value: nonEmptyStringType, - label: PropTypes.node, - }) - if (props.labelInValue) { - const validate = PropTypes.oneOfType([ - PropTypes.arrayOf(labelInValueShape), - labelInValueShape, - ]) - const error = validate(...arguments) - if (error) { - return new Error( - `Invalid prop \`${propName}\` supplied to \`${componentName}\`, ` + - `when \`labelInValue\` is \`true\`, \`${propName}\` should in ` + - `shape of \`{ value: string, label?: string }\`.` - ) - } - } else if (props.treeCheckable && props.treeCheckStrictly) { - const validate = PropTypes.oneOfType([ - PropTypes.arrayOf(labelInValueShape), - labelInValueShape, - ]) - const error = validate(...arguments) - if (error) { - return new Error( - `Invalid prop \`${propName}\` supplied to \`${componentName}\`, ` + - `when \`treeCheckable\` and \`treeCheckStrictly\` are \`true\`, ` + - `\`${propName}\` should in shape of \`{ value: string, label?: string }\`.` - ) - } - } else if (props.multiple && props[propName] === '') { - return new Error( - `Invalid prop \`${propName}\` of type \`string\` supplied to \`${componentName}\`, ` + - `expected \`array\` when \`multiple\` is \`true\`.` - ) - } else { - const validate = PropTypes.oneOfType([ - PropTypes.arrayOf(PropTypes.string), - PropTypes.string, - ]) - return validate(...arguments) - } -} - export const SelectPropTypes = { // className: PropTypes.string, prefixCls: PropTypes.string, diff --git a/components/vc-tree-select/src/SelectTrigger.jsx b/components/vc-tree-select/src/SelectTrigger.jsx index 249a13879..b3fdef475 100644 --- a/components/vc-tree-select/src/SelectTrigger.jsx +++ b/components/vc-tree-select/src/SelectTrigger.jsx @@ -1,6 +1,5 @@ import PropTypes from '../../_util/vue-types' import classnames from 'classnames' -import omit from 'omit.js' import Trigger from '../../vc-trigger' import Tree, { TreeNode } from '../../vc-tree' import { SelectPropTypes } from './PropTypes' @@ -10,12 +9,10 @@ import { flatToHierarchy, getValuePropValue, labelCompatible, - saveRef, } from './util' import { cloneElement } from '../../_util/vnode' -import { isEmptyElement, getSlotOptions, getKey, getAllProps, getComponentFromProp } from '../../_util/props-util' -import { noop } from '../../_util/vue-types/utils' +import { getSlotOptions, getKey, getAllProps, getComponentFromProp } from '../../_util/props-util' const BUILT_IN_PLACEMENTS = { bottomLeft: { diff --git a/components/vc-tree-select/src/util.js b/components/vc-tree-select/src/util.js index 0aede0b40..4b7ebca91 100644 --- a/components/vc-tree-select/src/util.js +++ b/components/vc-tree-select/src/util.js @@ -1,4 +1,4 @@ -import { getPropsData, getAllProps, getKey, getAttrs, getSlotOptions, filterEmpty, getSlots } from '../../_util/props-util' +import { getPropsData, getAllProps, getKey, getAttrs, getSlotOptions, getSlots } from '../../_util/props-util' import { cloneVNodes, cloneElement } from '../../_util/vnode' export function toTitle (title) { if (typeof title === 'string') { diff --git a/components/vc-tree/demo/basic.jsx b/components/vc-tree/demo/basic.jsx index 08f0ef324..9bc265fb2 100644 --- a/components/vc-tree/demo/basic.jsx +++ b/components/vc-tree/demo/basic.jsx @@ -1,7 +1,7 @@ /* eslint no-console:0 */ /* eslint no-alert:0 */ import PropTypes from '../../_util/vue-types' -import Tree, { TreeNode } from '../index' +import Tree from '../index' import '../assets/index.less' import './basic.less' @@ -63,7 +63,7 @@ export default { }, render () { - const customLabel = ( + const customLabel = ( // eslint-disable-line operations: Edit  diff --git a/components/vc-trigger/Popup.jsx b/components/vc-trigger/Popup.jsx index f79f4c2f4..454cdbad7 100644 --- a/components/vc-trigger/Popup.jsx +++ b/components/vc-trigger/Popup.jsx @@ -3,7 +3,6 @@ import PropTypes from '../_util/vue-types' import Align from '../vc-align' import PopupInner from './PopupInner' import LazyRenderBox from './LazyRenderBox' -import { noop } from './utils' import animate from '../_util/css-animation' export default { @@ -143,7 +142,7 @@ export default { const { align, visible, prefixCls, animation, popupStyle, getClassNameFromAlign, destroyPopupOnHide, stretch, } = props - const { mouseenter, mouseleave } = $listeners + // const { mouseenter, mouseleave } = $listeners const className = this.getClassName(this.currentAlignClassName || getClassNameFromAlign(align)) // const hiddenClassName = `${prefixCls}-hidden`