mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-30 11:16:12 +08:00
fix(project):fix gc.sh generating wrong format templates
fix(utils):fix utils linting issues
This commit is contained in:
parent
bde4eb190d
commit
44b641c4a7
@ -1,7 +1,7 @@
|
||||
export function isDef(val) {
|
||||
export function isDef(val: unknown): boolean {
|
||||
return val !== undefined && val !== null
|
||||
}
|
||||
export function isKorean(text: string) {
|
||||
export function isKorean(text: string): boolean {
|
||||
const reg = /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi
|
||||
return reg.test(text)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {eventKeys, triggerEvent} from '../aria'
|
||||
import { eventKeys, triggerEvent } from '../aria'
|
||||
import SubMenu from './submenu'
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {eventKeys, triggerEvent } from '../aria'
|
||||
import { eventKeys, triggerEvent } from '../aria'
|
||||
import MenuItem from './menu-item'
|
||||
|
||||
class SubMenu {
|
||||
|
@ -1,7 +0,0 @@
|
||||
export default function(target: Object, ...args: Array<Object>) {
|
||||
target = { ...target }
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
Object.assign(target, args[i])
|
||||
}
|
||||
return target
|
||||
}
|
@ -2,7 +2,7 @@ import ResizeObserver from 'resize-observer-polyfill'
|
||||
import isServer from './isServer'
|
||||
|
||||
type ResizableElement = CustomizedHTMLElement<{
|
||||
__resizeListeners__: Array<Function>;
|
||||
__resizeListeners__: Array<(...args: unknown[]) => unknown>;
|
||||
__ro__: ResizeObserver;
|
||||
}>;
|
||||
|
||||
@ -22,8 +22,8 @@ const resizeHandler = function(entries: ResizeObserverEntry[]) {
|
||||
/* istanbul ignore next */
|
||||
export const addResizeListener = function(
|
||||
element: ResizableElement,
|
||||
fn: Function,
|
||||
) {
|
||||
fn: (...args: unknown[]) => unknown,
|
||||
): void {
|
||||
if (isServer) return
|
||||
if (!element.__resizeListeners__) {
|
||||
element.__resizeListeners__ = []
|
||||
@ -36,8 +36,8 @@ export const addResizeListener = function(
|
||||
/* istanbul ignore next */
|
||||
export const removeResizeListener = function(
|
||||
element: ResizableElement,
|
||||
fn: Function,
|
||||
) {
|
||||
fn: (...args: unknown[]) => unknown,
|
||||
): void {
|
||||
if (!element || !element.__resizeListeners__) return
|
||||
element.__resizeListeners__.splice(
|
||||
element.__resizeListeners__.indexOf(fn),
|
||||
|
@ -3,7 +3,7 @@ import isServer from './isServer'
|
||||
export default function scrollIntoView(
|
||||
container: HTMLElement,
|
||||
selected: HTMLElement,
|
||||
) {
|
||||
): void {
|
||||
if (isServer) return
|
||||
|
||||
if (!selected) {
|
||||
|
@ -2,7 +2,7 @@ import isServer from './isServer'
|
||||
|
||||
let scrollBarWidth: number
|
||||
|
||||
export default function() {
|
||||
export default function(): number {
|
||||
if (isServer) return 0
|
||||
if (scrollBarWidth !== undefined) return scrollBarWidth
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Utils, {triggerEvent, isFocusable, attemptFocus} from '../aria'
|
||||
import { triggerEvent, isFocusable } from '../aria'
|
||||
|
||||
const CE = (tag: string) => document.createElement(tag)
|
||||
|
||||
|
@ -132,7 +132,7 @@ export {
|
||||
capitalize,
|
||||
}
|
||||
|
||||
export function rafThrottle(fn: (args: Record<string, unknown>) => unknown): (...args: any[]) => any {
|
||||
export function rafThrottle(fn: (args: Record<string, unknown>) => unknown): (...args: unknown[]) => unknown {
|
||||
let locked = false
|
||||
return function(...args) {
|
||||
if (locked) return
|
||||
@ -145,3 +145,5 @@ export function rafThrottle(fn: (args: Record<string, unknown>) => unknown): (..
|
||||
}
|
||||
|
||||
export const objToArray = castArray
|
||||
|
||||
export { isVNode } from 'vue'
|
||||
|
@ -33,16 +33,18 @@ mkdir -p "$DIRNAME/__tests__"
|
||||
cat > $DIRNAME/src/index.vue <<EOF
|
||||
<template>
|
||||
<div>
|
||||
<slot/>
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
<script lang='ts'>
|
||||
export default {
|
||||
NAME: 'El${NAME}',
|
||||
props: {
|
||||
},
|
||||
setup(props,ctx) { }
|
||||
};
|
||||
import { defineComponent } from 'vue'
|
||||
export default defineComponent({
|
||||
name: 'El${NAME}',
|
||||
props: { },
|
||||
setup(props) {
|
||||
// init here
|
||||
},
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
</style>
|
||||
@ -51,7 +53,7 @@ EOF
|
||||
cat <<EOF >"$DIRNAME/index.ts"
|
||||
import { App } from 'vue'
|
||||
import ${NAME} from './src/index.vue'
|
||||
export default (app: App) => {
|
||||
export default (app: App): void => {
|
||||
app.component(${NAME}.name, ${NAME})
|
||||
}
|
||||
EOF
|
||||
@ -72,7 +74,7 @@ cat > $DIRNAME/package.json <<EOF
|
||||
EOF
|
||||
|
||||
cat > $DIRNAME/__tests__/$INPUT_NAME.spec.ts <<EOF
|
||||
import {mount} from '@vue/test-utils'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import $NAME from '../src/index.vue'
|
||||
|
||||
const AXIOM = 'Rem is the best girl'
|
||||
@ -81,7 +83,7 @@ describe('$NAME.vue', () => {
|
||||
test('render test', () => {
|
||||
const wrapper = mount($NAME, {
|
||||
slots: {
|
||||
default: AXIOM
|
||||
default: AXIOM,
|
||||
},
|
||||
})
|
||||
expect(wrapper.text()).toEqual(AXIOM)
|
||||
@ -93,7 +95,7 @@ cat <<EOF >"$DIRNAME/doc/index.stories.ts"
|
||||
import El${NAME} from '../index'
|
||||
|
||||
export default {
|
||||
title: "${NAME}"
|
||||
title: '${NAME}',
|
||||
}
|
||||
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user