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
|
return val !== undefined && val !== null
|
||||||
}
|
}
|
||||||
export function isKorean(text: string) {
|
export function isKorean(text: string): boolean {
|
||||||
const reg = /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi
|
const reg = /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi
|
||||||
return reg.test(text)
|
return reg.test(text)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {eventKeys, triggerEvent} from '../aria'
|
import { eventKeys, triggerEvent } from '../aria'
|
||||||
import SubMenu from './submenu'
|
import SubMenu from './submenu'
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {eventKeys, triggerEvent } from '../aria'
|
import { eventKeys, triggerEvent } from '../aria'
|
||||||
import MenuItem from './menu-item'
|
import MenuItem from './menu-item'
|
||||||
|
|
||||||
class SubMenu {
|
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'
|
import isServer from './isServer'
|
||||||
|
|
||||||
type ResizableElement = CustomizedHTMLElement<{
|
type ResizableElement = CustomizedHTMLElement<{
|
||||||
__resizeListeners__: Array<Function>;
|
__resizeListeners__: Array<(...args: unknown[]) => unknown>;
|
||||||
__ro__: ResizeObserver;
|
__ro__: ResizeObserver;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
@ -22,8 +22,8 @@ const resizeHandler = function(entries: ResizeObserverEntry[]) {
|
|||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
export const addResizeListener = function(
|
export const addResizeListener = function(
|
||||||
element: ResizableElement,
|
element: ResizableElement,
|
||||||
fn: Function,
|
fn: (...args: unknown[]) => unknown,
|
||||||
) {
|
): void {
|
||||||
if (isServer) return
|
if (isServer) return
|
||||||
if (!element.__resizeListeners__) {
|
if (!element.__resizeListeners__) {
|
||||||
element.__resizeListeners__ = []
|
element.__resizeListeners__ = []
|
||||||
@ -36,8 +36,8 @@ export const addResizeListener = function(
|
|||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
export const removeResizeListener = function(
|
export const removeResizeListener = function(
|
||||||
element: ResizableElement,
|
element: ResizableElement,
|
||||||
fn: Function,
|
fn: (...args: unknown[]) => unknown,
|
||||||
) {
|
): void {
|
||||||
if (!element || !element.__resizeListeners__) return
|
if (!element || !element.__resizeListeners__) return
|
||||||
element.__resizeListeners__.splice(
|
element.__resizeListeners__.splice(
|
||||||
element.__resizeListeners__.indexOf(fn),
|
element.__resizeListeners__.indexOf(fn),
|
||||||
|
@ -3,7 +3,7 @@ import isServer from './isServer'
|
|||||||
export default function scrollIntoView(
|
export default function scrollIntoView(
|
||||||
container: HTMLElement,
|
container: HTMLElement,
|
||||||
selected: HTMLElement,
|
selected: HTMLElement,
|
||||||
) {
|
): void {
|
||||||
if (isServer) return
|
if (isServer) return
|
||||||
|
|
||||||
if (!selected) {
|
if (!selected) {
|
||||||
|
@ -2,7 +2,7 @@ import isServer from './isServer'
|
|||||||
|
|
||||||
let scrollBarWidth: number
|
let scrollBarWidth: number
|
||||||
|
|
||||||
export default function() {
|
export default function(): number {
|
||||||
if (isServer) return 0
|
if (isServer) return 0
|
||||||
if (scrollBarWidth !== undefined) return scrollBarWidth
|
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)
|
const CE = (tag: string) => document.createElement(tag)
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ export {
|
|||||||
capitalize,
|
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
|
let locked = false
|
||||||
return function(...args) {
|
return function(...args) {
|
||||||
if (locked) return
|
if (locked) return
|
||||||
@ -145,3 +145,5 @@ export function rafThrottle(fn: (args: Record<string, unknown>) => unknown): (..
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const objToArray = castArray
|
export const objToArray = castArray
|
||||||
|
|
||||||
|
export { isVNode } from 'vue'
|
||||||
|
@ -33,16 +33,18 @@ mkdir -p "$DIRNAME/__tests__"
|
|||||||
cat > $DIRNAME/src/index.vue <<EOF
|
cat > $DIRNAME/src/index.vue <<EOF
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<slot/>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang='ts'>
|
<script lang='ts'>
|
||||||
export default {
|
import { defineComponent } from 'vue'
|
||||||
NAME: 'El${NAME}',
|
export default defineComponent({
|
||||||
props: {
|
name: 'El${NAME}',
|
||||||
},
|
props: { },
|
||||||
setup(props,ctx) { }
|
setup(props) {
|
||||||
};
|
// init here
|
||||||
|
},
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
</style>
|
</style>
|
||||||
@ -51,7 +53,7 @@ EOF
|
|||||||
cat <<EOF >"$DIRNAME/index.ts"
|
cat <<EOF >"$DIRNAME/index.ts"
|
||||||
import { App } from 'vue'
|
import { App } from 'vue'
|
||||||
import ${NAME} from './src/index.vue'
|
import ${NAME} from './src/index.vue'
|
||||||
export default (app: App) => {
|
export default (app: App): void => {
|
||||||
app.component(${NAME}.name, ${NAME})
|
app.component(${NAME}.name, ${NAME})
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
@ -72,7 +74,7 @@ cat > $DIRNAME/package.json <<EOF
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat > $DIRNAME/__tests__/$INPUT_NAME.spec.ts <<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'
|
import $NAME from '../src/index.vue'
|
||||||
|
|
||||||
const AXIOM = 'Rem is the best girl'
|
const AXIOM = 'Rem is the best girl'
|
||||||
@ -81,7 +83,7 @@ describe('$NAME.vue', () => {
|
|||||||
test('render test', () => {
|
test('render test', () => {
|
||||||
const wrapper = mount($NAME, {
|
const wrapper = mount($NAME, {
|
||||||
slots: {
|
slots: {
|
||||||
default: AXIOM
|
default: AXIOM,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
expect(wrapper.text()).toEqual(AXIOM)
|
expect(wrapper.text()).toEqual(AXIOM)
|
||||||
@ -93,7 +95,7 @@ cat <<EOF >"$DIRNAME/doc/index.stories.ts"
|
|||||||
import El${NAME} from '../index'
|
import El${NAME} from '../index'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: "${NAME}"
|
title: '${NAME}',
|
||||||
}
|
}
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user