Skip to content

Commit

Permalink
chore/fix-linter-complains
Browse files Browse the repository at this point in the history
- Fix type linting complains for serveral files
  • Loading branch information
jeremywu authored and HerringtonDarkholme committed Jul 28, 2020
1 parent 5cf4b14 commit 3a917bb
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 129 deletions.
3 changes: 2 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line
const importFrom = require('import-from')

function getPackages (context) {
Expand All @@ -23,7 +24,7 @@ const scopes = [
'dev',
'build',
'deploy',
'other'
'other',
]

module.exports = {
Expand Down
6 changes: 3 additions & 3 deletions packages/badge/__tests__/badge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ const AXIOM = 'Rem is the best girl'
describe('Badge', () => {
test('has value', () => {
const wrapper = mount(Badge, {
props: {value: 80}
props: {value: 80},
})
expect(wrapper.vm.content).toEqual(80)
})

test('is fixed', () => {
const wrapper = mount(Badge, {
slots: {default: AXIOM}
slots: {default: AXIOM},
})
expect(wrapper.find('.el-badge__content.is-fixed')).toBeDefined()
})

test('is dot', () => {
const wrapper = mount(Badge, {
props: {isDot: true},
slots: {default: AXIOM}
slots: {default: AXIOM},
})
expect(wrapper.find('.el-badge__content.is-fixed')).toBeDefined()
})
Expand Down
23 changes: 20 additions & 3 deletions packages/badge/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,28 @@
<script lang="ts">
import {computed} from 'vue'
interface IBadgeProps {
value: string | number;
max: number;
isDot: boolean;
hidden: boolean;
type: string;
}
interface IBadgeSetups {
content: number | string;
}
export default {
name: 'ElBadge',
props: {
value: [String, Number],
max: Number,
value: {
type: [String, Number],
default: '',
},
max: {
type: Number,
default: 99,
},
isDot: Boolean,
hidden: Boolean,
type: {
Expand All @@ -37,7 +54,7 @@ export default {
},
},
},
setup(props) {
setup(props: IBadgeProps): IBadgeSetups {
const content = computed(() => {
if (props.isDot) {
return
Expand Down
27 changes: 23 additions & 4 deletions packages/button/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</template>

<script lang='ts'>
import { computed, inject } from 'vue'
import { computed, inject, defineComponent } from 'vue'
const ELEMENT: {
size?: number;
} = {}
Expand All @@ -36,7 +36,26 @@ interface ElFormItem {
elFormItemSize: number;
}
export default {
interface IButtonProps {
type: string;
size: string;
icon: string;
nativeType: string;
loading: boolean;
disabled: boolean;
plain: boolean;
autofocus: boolean;
round: boolean;
circle: boolean;
}
interface IButtonSetups {
_elFormItemSize: string;
buttonSize: string;
buttonDisabled: boolean;
handleClick: EmitFn;
}
export default defineComponent({
name: 'ElButton',
props: {
Expand Down Expand Up @@ -66,7 +85,7 @@ export default {
emits: ['click'],
setup(props, ctx) {
setup(props, ctx): IButtonSetups {
// inject
const elForm = inject<ElForm>('elForm')
const elFormItem = inject<ElFormItem>('elFormItem')
Expand Down Expand Up @@ -95,5 +114,5 @@ export default {
handleClick,
}
},
}
})
</script>
2 changes: 1 addition & 1 deletion packages/element-plus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ElBadge from '@element-plus/badge'
import ElTag from '@element-plus/tag'

export {
ElButton, ElBadge, ElTag
ElButton, ElBadge, ElTag,
}

export default function install(app: App): void {
Expand Down
52 changes: 26 additions & 26 deletions packages/tag/__tests__/tag.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ describe('Tag.vue', () => {
test('render text & class', () => {
const wrapper = mount(Tag, {
slots: {
default: AXIOM
default: AXIOM,
},
})
expect(wrapper.text()).toEqual(AXIOM)

const vm = wrapper.vm;
const vm = wrapper.vm

expect(vm.$el.classList.contains('el-tag')).toEqual(true);
expect(vm.$el.classList.contains('el-tag__close')).toEqual(false);
expect(vm.$el.classList.contains('is-hit')).toEqual(false);
expect(vm.$el.classList.contains('md-fade-center')).toEqual(false);
expect(vm.$el.classList.contains('el-tag')).toEqual(true)
expect(vm.$el.classList.contains('el-tag__close')).toEqual(false)
expect(vm.$el.classList.contains('is-hit')).toEqual(false)
expect(vm.$el.classList.contains('md-fade-center')).toEqual(false)
})

test('type', () => {
const wrapper = mount(Tag, {
props: {
type: 'primary'
type: 'primary',
},
})
const vm = wrapper.vm;
expect(vm.$el.classList.contains('el-tag--primary')).toEqual(true);
const vm = wrapper.vm
expect(vm.$el.classList.contains('el-tag--primary')).toEqual(true)
})

test('hit', () => {
const wrapper = mount(Tag, {
props: {
hit: true
hit: true,
},
})
const vm = wrapper.vm;
expect(vm.$el.classList.contains('is-hit')).toEqual(true);
const vm = wrapper.vm
expect(vm.$el.classList.contains('is-hit')).toEqual(true)
})

test('closeable', async () => {
Expand All @@ -46,11 +46,11 @@ describe('Tag.vue', () => {
closable: true,
},
})
const closeBtn = wrapper.find('.el-tag .el-tag__close');
expect(closeBtn.exists()).toBe(true);
const closeBtn = wrapper.find('.el-tag .el-tag__close')
expect(closeBtn.exists()).toBe(true)

await closeBtn.trigger('click');
expect(wrapper.emitted().close).toBeTruthy();
await closeBtn.trigger('click')
expect(wrapper.emitted().close).toBeTruthy()
})

test('closeTransition', () => {
Expand All @@ -59,8 +59,8 @@ describe('Tag.vue', () => {
closeTransition: true,
},
})
const vm = wrapper.vm;
expect(vm.$el.classList.contains('md-fade-center')).toEqual(false);
const vm = wrapper.vm
expect(vm.$el.classList.contains('md-fade-center')).toEqual(false)
})

test('color', () => {
Expand All @@ -69,8 +69,8 @@ describe('Tag.vue', () => {
color: 'rgb(0, 0, 0)',
},
})
const vm = wrapper.vm;
expect(vm.$el.style.backgroundColor).toEqual('rgb(0, 0, 0)');
const vm = wrapper.vm
expect(vm.$el.style.backgroundColor).toEqual('rgb(0, 0, 0)')
})

test('theme', () => {
Expand All @@ -79,10 +79,10 @@ describe('Tag.vue', () => {
effect: 'dark',
},
})
const vm = wrapper.vm;
const el = vm.$el;
expect(el.className.indexOf('el-tag--dark') > -1).toEqual(true);
expect(el.className.indexOf('el-tag--light') > -1).toEqual(false);
expect(el.className.indexOf('el-tag--plain') > -1).toEqual(false);
const vm = wrapper.vm
const el = vm.$el
expect(el.className.indexOf('el-tag--dark') > -1).toEqual(true)
expect(el.className.indexOf('el-tag--light') > -1).toEqual(false)
expect(el.className.indexOf('el-tag--plain') > -1).toEqual(false)
})
})
})
39 changes: 22 additions & 17 deletions packages/tag/doc/basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
v-for="item in items"
:key="item.label"
:type="item.type"
effect="dark">
effect="dark"
>
{{ item.label }}
</el-tag>
</div>
Expand All @@ -19,30 +20,34 @@
v-for="item in items"
:key="item.label"
:type="item.type"
effect="plain">
effect="plain"
>
{{ item.label }}
</el-tag>
</div>
</template>

<script>
import Vue from 'vue'
const basic = Vue.defineComoponent({
data() {
return {
items: [
{ type: '', label: 'Label 1' },
{ type: 'success', label: 'Label 2' },
{ type: 'info', label: 'Label 3' },
{ type: 'danger', label: 'Label 4' },
{ type: 'warning', label: 'Label 5' },
],
}
},
})
export default basic
</script>

<style scoped>
.el-tag {
margin: 6px;
}
</style>

<script>
export default {
data() {
return {
items: [
{ type: '', label: 'Label 1' },
{ type: 'success', label: 'Label 2' },
{ type: 'info', label: 'Label 3' },
{ type: 'danger', label: 'Label 4' },
{ type: 'warning', label: 'Label 5' }
]
}
}
}
</script>
2 changes: 1 addition & 1 deletion packages/tag/doc/index.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export { default as BasicUsage} from './basic.vue'

export default {
title: 'Tag',
}
}
2 changes: 1 addition & 1 deletion packages/tag/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { App } from 'vue'
import Tag from './src/index.vue'
export default (app: App) => {
export default (app: App): void => {
app.component(Tag.name, Tag)
}
Loading

0 comments on commit 3a917bb

Please sign in to comment.