Skip to content

Commit

Permalink
fix: fixing code in accordance with the latest vue eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Sep 20, 2020
1 parent 396ce7b commit 64efe20
Show file tree
Hide file tree
Showing 80 changed files with 210 additions and 218 deletions.
5 changes: 1 addition & 4 deletions packages/alert/Alert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default {
},
emits: ['close'],
setup(props, { emit, slots }) {
const { title, description, type } = toRefs(props)
const { description, type } = toRefs(props)
const visible = ref(true)
const close = () => {
Expand All @@ -107,9 +107,6 @@ export default {
})
return {
title,
description,
type,
visible,
typeClass,
iconClass,
Expand Down
4 changes: 3 additions & 1 deletion packages/autocomplete/src/autocomplete-suggestions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
},
updated() {
this.$nextTick((_) => {
this.$nextTick(() => {
this.popperJS && this.updatePopper()
})
},
Expand All @@ -74,6 +74,8 @@ export default {
},
created() {
// TODO $on 已经废弃了
// eslint-disable-next-line vue/no-deprecated-events-api
this.$on('visible', (val, inputWidth) => {
this.dropdownWidth = inputWidth + 'px'
this.showPopper = val
Expand Down
26 changes: 14 additions & 12 deletions packages/autocomplete/src/autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
@focus="handleFocus"
@blur="handleBlur"
@clear="handleClear"
@keydown.up.native.prevent="highlight(highlightedIndex - 1)"
@keydown.down.native.prevent="highlight(highlightedIndex + 1)"
@keydown.enter.native="handleKeyEnter"
@keydown.native.tab="close"
@keydown.up.prevent="highlight(highlightedIndex - 1)"
@keydown.down.prevent="highlight(highlightedIndex + 1)"
@keydown.enter="handleKeyEnter"
@keydown.tab="close"
>
<template slot="prepend" v-if="$slots.prepend">
<template v-slot:prepend v-if="$slots.prepend">
<slot name="prepend"></slot>
</template>
<template slot="append" v-if="$slots.append">
<template v-slot:append v-if="$slots.append">
<slot name="append"></slot>
</template>
<template slot="prefix" v-if="$slots.prefix">
<template v-slot:prefix v-if="$slots.prefix">
<slot name="prefix"></slot>
</template>
<template slot="suffix" v-if="$slots.suffix">
<template v-slot:suffix v-if="$slots.suffix">
<slot name="suffix"></slot>
</template>
</el-input>
Expand Down Expand Up @@ -217,7 +217,7 @@ export default {
this.activated = false
this.$emit('clear')
},
close(e) {
close() {
this.activated = false
},
handleKeyEnter(e) {
Expand All @@ -230,7 +230,7 @@ export default {
this.select(this.suggestions[this.highlightedIndex])
} else if (this.selectWhenUnmatched) {
this.$emit('select', { value: this.value })
this.$nextTick((_) => {
this.$nextTick(() => {
this.suggestions = []
this.highlightedIndex = -1
})
Expand All @@ -239,7 +239,7 @@ export default {
select(item) {
this.$emit('input', item[this.valueKey])
this.$emit('select', item)
this.$nextTick((_) => {
this.$nextTick(() => {
this.suggestions = []
this.highlightedIndex = -1
})
Expand Down Expand Up @@ -288,6 +288,8 @@ export default {
},
mounted() {
this.debouncedGetData = debounce(this.debounce, this.getData)
// TODO $on 已经废弃
// eslint-disable-next-line vue/no-deprecated-events-api
this.$on('item-click', (item) => {
this.select(item)
})
Expand All @@ -300,7 +302,7 @@ export default {
`${this.id}-item-${this.highlightedIndex}`
)
},
beforeDestroy() {
beforeUnmount() {
this.$refs.suggestions.$destroy()
}
}
Expand Down
9 changes: 4 additions & 5 deletions packages/breadcrumb/BreadcrumbItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,22 @@ export default {
replace: Boolean
},
setup(props) {
const { to, replace } = toRefs(props)
const { replace } = toRefs(props)
const separator = inject('separator')
const separatorClass = inject('separatorClass')
const link = ref(null)
const { ctx } = getCurrentInstance()
onMounted(() => {
link.value.setAttribute('role', 'link')
link.value.addEventListener('click', () => {
if (!to || !ctx.$router) return
replace ? ctx.$router.replace(to) : ctx.$router.push(to)
if (!props.to || !ctx.$router) return
replace ? ctx.$router.replace(props.to) : ctx.$router.push(props.to)
})
})
return {
separator,
separatorClass,
link,
to
link
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/calendar/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
}
},
emits: ['input', 'update:modelValue'],
setup(props, { attrs, emit, slots }) {
setup(props, { emit }) {
const instance = getCurrentInstance()
provide('elCalendar', instance)
Expand Down Expand Up @@ -167,8 +167,8 @@ export default {
if (realSelectedDay.value) {
const d = state.selectedDay.split('-')
return new Date(d[0], d[1] - 1, d[2])
} else if (validatedRange.length) {
return validatedRange[0][0]
} else if (validatedRange.value.length) {
return validatedRange.value[0][0]
}
return state.now
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/calendar/DateTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {
firstDayOfWeek: Number
},
setup(props, { attrs, emit, slots }) {
setup(props, { emit }) {
const { selectedDay, date, hideHeader, firstDayOfWeek } = toRefs(props)
const WEEK_DAYS = ref(getI18nSettings().dayNames)
Expand Down
3 changes: 1 addition & 2 deletions packages/carousel/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ export default {
items,
activeIndex,
hover,
loop,
arrowDisplay,
handleButtonEnter,
handleButtonLeave,
Expand Down Expand Up @@ -383,7 +382,7 @@ const useIndicator = (props, initData) => {
'el-carousel__indicators',
'el-carousel__indicators--' + props.direction
]
if (hasLabel) {
if (hasLabel.value) {
classes.push('el-carousel__indicators--labels')
}
if (props.indicatorPosition === 'outside' || props.type === 'card') {
Expand Down
4 changes: 2 additions & 2 deletions packages/cascader-panel/src/cascader-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ export default {
hoverZone.innerHTML = ''
},
renderEmptyText(h) {
renderEmptyText() {
return (
<div class="el-cascader-menu__empty-text">
{this.t('el.cascader.noData')}
</div>
)
},
renderNodeList(h) {
renderNodeList() {
const { menuId } = this
const { isHoverMenu } = this.panel
const events = { on: {} }
Expand Down
12 changes: 6 additions & 6 deletions packages/cascader-panel/src/cascader-node.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default {
return null
},
renderCheckbox(h) {
renderCheckbox() {
const { node, config, isDisabled } = this
const events = {
on: { change: this.handleMultiCheckChange },
Expand All @@ -141,7 +141,7 @@ export default {
)
},
renderRadio(h) {
renderRadio() {
let { checkedValue, value, isDisabled } = this
// to keep same reference if value cause radio's checked state is calculated by reference comparision;
Expand All @@ -163,19 +163,19 @@ export default {
)
},
renderCheckIcon(h) {
renderCheckIcon() {
return <i class="el-icon-check el-cascader-node__prefix"></i>
},
renderLoadingIcon(h) {
renderLoadingIcon() {
return <i class="el-icon-loading el-cascader-node__postfix"></i>
},
renderExpandIcon(h) {
renderExpandIcon() {
return <i class="el-icon-arrow-right el-cascader-node__postfix"></i>
},
renderContent(h) {
renderContent() {
const { panel, node } = this
const render = panel.renderLabelFn
const vnode = render ? render({ node, data: node.data }) : null
Expand Down
16 changes: 10 additions & 6 deletions packages/cascader-panel/src/cascader-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const getSibling = (el, distance) => {
return null
}
const getMenuIndex = (el, distance) => {
const getMenuIndex = (el) => {
if (!el) return
const pieces = el.id.split('-')
return Number(pieces[pieces.length - 2])
Expand Down Expand Up @@ -132,7 +132,7 @@ export default {
return this.config.expandTrigger === 'hover'
},
renderLabelFn() {
return this.renderLabel || this.$scopedSlots.default
return this.renderLabel || this.$slots.default
}
},
Expand Down Expand Up @@ -230,15 +230,17 @@ export default {
const { target, keyCode } = e
switch (keyCode) {
case KeyCode.up:
case KeyCode.up: {
const prev = getSibling(target, -1)
focusNode(prev)
break
case KeyCode.down:
}
case KeyCode.down: {
const next = getSibling(target, 1)
focusNode(next)
break
case KeyCode.left:
}
case KeyCode.left: {
const preMenu = this.$refs.menu[getMenuIndex(target) - 1]
if (preMenu) {
const expandedNode = preMenu.$el.querySelector(
Expand All @@ -247,7 +249,8 @@ export default {
focusNode(expandedNode)
}
break
case KeyCode.right:
}
case KeyCode.right: {
const nextMenu = this.$refs.menu[getMenuIndex(target) + 1]
if (nextMenu) {
const firstNode = nextMenu.$el.querySelector(
Expand All @@ -256,6 +259,7 @@ export default {
focusNode(firstNode)
}
break
}
case KeyCode.enter:
checkNode(target)
break
Expand Down
12 changes: 7 additions & 5 deletions packages/cascader/src/cascader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
:options="options"
:props="config"
:border="false"
:render-label="$scopedSlots.default"
:render-label="$slots.default"
@expand-change="handleExpandChange"
@close="toggleDropDownVisible(false)"
></el-cascader-panel>
Expand Down Expand Up @@ -319,7 +319,7 @@ export default {
this.$nextTick(this.updateStyle)
}
},
filtering(val) {
filtering() {
this.$nextTick(this.updatePopper)
}
},
Expand Down Expand Up @@ -356,7 +356,7 @@ export default {
addResizeListener(this.$el, this.updateStyle)
},
beforeDestroy() {
beforeUnmount() {
removeResizeListener(this.$el, this.updateStyle)
},
Expand Down Expand Up @@ -559,14 +559,16 @@ export default {
case KeyCode.enter:
target.click()
break
case KeyCode.up:
case KeyCode.up: {
const prev = target.previousElementSibling
prev && prev.focus()
break
case KeyCode.down:
}
case KeyCode.down: {
const next = target.nextElementSibling
next && next.focus()
break
}
case KeyCode.esc:
case KeyCode.tab:
this.toggleDropDownVisible(false)
Expand Down
2 changes: 1 addition & 1 deletion packages/checkbox-button/CheckboxButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
emits: ['update:modelValue', 'change'],
setup(props) {
setup() {
const state = reactive({
focus: false
})
Expand Down
2 changes: 1 addition & 1 deletion packages/checkbox/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default {
emits: ['update:modelValue', 'change'],
setup(props, ctx) {
setup() {
const state = reactive({
focus: false
})
Expand Down
2 changes: 1 addition & 1 deletion packages/col/Col.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {
lg: [Number, Object],
xl: [Number, Object]
},
setup(props, { attrs, emit, slots }) {
setup(props, { slots }) {
const { tag } = toRefs(props)
const gutter = computed(() => {
let { parent } = getCurrentInstance()
Expand Down
2 changes: 2 additions & 0 deletions packages/collapse/src/collapse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export default {
},
created() {
// TODO $on 已经废弃
// eslint-disable-next-line vue/no-deprecated-events-api
this.$on('item-click', this.handleItemClick)
}
}
Expand Down
Loading

0 comments on commit 64efe20

Please sign in to comment.