chore: lint + include tsx files for lint
This commit is contained in:
parent
c0adcb5669
commit
37cbd0098d
@ -9,7 +9,7 @@
|
|||||||
"size-runtime": "node scripts/build.js runtime-dom -p -f global",
|
"size-runtime": "node scripts/build.js runtime-dom -p -f global",
|
||||||
"size-compiler": "node scripts/build.js compiler-dom -p -f global",
|
"size-compiler": "node scripts/build.js compiler-dom -p -f global",
|
||||||
"size": "yarn size-runtime && yarn size-compiler",
|
"size": "yarn size-runtime && yarn size-compiler",
|
||||||
"lint": "prettier --write --parser typescript \"packages/**/*.ts\"",
|
"lint": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"gitHooks": {
|
"gitHooks": {
|
||||||
@ -21,7 +21,7 @@
|
|||||||
"prettier --write",
|
"prettier --write",
|
||||||
"git add"
|
"git add"
|
||||||
],
|
],
|
||||||
"*.ts": [
|
"*.ts?(x)": [
|
||||||
"prettier --parser=typescript --write",
|
"prettier --parser=typescript --write",
|
||||||
"git add"
|
"git add"
|
||||||
]
|
]
|
||||||
|
@ -41,7 +41,7 @@ export const transformOn: DirectiveTransform = (dir, node, context) => {
|
|||||||
if (
|
if (
|
||||||
// if event name is dynamic, always wrap with keys guard
|
// if event name is dynamic, always wrap with keys guard
|
||||||
key.type === NodeTypes.COMPOUND_EXPRESSION ||
|
key.type === NodeTypes.COMPOUND_EXPRESSION ||
|
||||||
!(key.isStatic) ||
|
!key.isStatic ||
|
||||||
key.content.toLowerCase() in KEYBOARD_EVENTS
|
key.content.toLowerCase() in KEYBOARD_EVENTS
|
||||||
) {
|
) {
|
||||||
handler = createCallExpression(context.helper(V_ON_KEYS_GUARD), [
|
handler = createCallExpression(context.helper(V_ON_KEYS_GUARD), [
|
||||||
|
@ -67,7 +67,7 @@ test('createComponent type inference', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// test TSX props inference
|
// test TSX props inference
|
||||||
;(<MyComponent a={1} b="foo" dd={['foo']} ddd={['foo']}/>)
|
;<MyComponent a={1} b="foo" dd={['foo']} ddd={['foo']} />
|
||||||
})
|
})
|
||||||
|
|
||||||
test('type inference w/ optional props declaration', () => {
|
test('type inference w/ optional props declaration', () => {
|
||||||
@ -85,14 +85,14 @@ test('type inference w/ optional props declaration', () => {
|
|||||||
return h('div', this.msg)
|
return h('div', this.msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
;(<Comp msg="hello"/>)
|
;<Comp msg="hello" />
|
||||||
})
|
})
|
||||||
|
|
||||||
test('type inference w/ direct setup function', () => {
|
test('type inference w/ direct setup function', () => {
|
||||||
const Comp = createComponent((props: { msg: string }) => {
|
const Comp = createComponent((props: { msg: string }) => {
|
||||||
return () => <div>{props.msg}</div>
|
return () => <div>{props.msg}</div>
|
||||||
})
|
})
|
||||||
;(<Comp msg="hello"/>)
|
;<Comp msg="hello" />
|
||||||
})
|
})
|
||||||
|
|
||||||
test('type inference w/ array props declaration', () => {
|
test('type inference w/ array props declaration', () => {
|
||||||
@ -113,7 +113,7 @@ test('type inference w/ array props declaration', () => {
|
|||||||
this.c
|
this.c
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
;(<Comp a={1} b={2}/>)
|
;<Comp a={1} b={2} />
|
||||||
})
|
})
|
||||||
|
|
||||||
test('with legacy options', () => {
|
test('with legacy options', () => {
|
||||||
|
@ -50,10 +50,8 @@ function injectHook(
|
|||||||
|
|
||||||
const createHook = <T extends Function = () => any>(
|
const createHook = <T extends Function = () => any>(
|
||||||
lifecycle: LifecycleHooks
|
lifecycle: LifecycleHooks
|
||||||
) => (
|
) => (hook: T, target: ComponentInternalInstance | null = currentInstance) =>
|
||||||
hook: T,
|
injectHook(lifecycle, hook, target)
|
||||||
target: ComponentInternalInstance | null = currentInstance
|
|
||||||
) => injectHook(lifecycle, hook, target)
|
|
||||||
|
|
||||||
export const onBeforeMount = createHook(LifecycleHooks.BEFORE_MOUNT)
|
export const onBeforeMount = createHook(LifecycleHooks.BEFORE_MOUNT)
|
||||||
export const onMounted = createHook(LifecycleHooks.MOUNTED)
|
export const onMounted = createHook(LifecycleHooks.MOUNTED)
|
||||||
|
@ -16,10 +16,7 @@ export function renderList(
|
|||||||
}
|
}
|
||||||
} else if (isObject(source)) {
|
} else if (isObject(source)) {
|
||||||
if (source[Symbol.iterator as any]) {
|
if (source[Symbol.iterator as any]) {
|
||||||
ret = Array.from(
|
ret = Array.from(source as Iterable<any>, renderItem)
|
||||||
source as Iterable<any>,
|
|
||||||
renderItem
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
const keys = Object.keys(source)
|
const keys = Object.keys(source)
|
||||||
ret = new Array(keys.length)
|
ret = new Array(keys.length)
|
||||||
|
@ -28,7 +28,6 @@ export const vOnModifiersGuard = (fn: Function, modifiers: string[]) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Kept for 2.x compat.
|
// Kept for 2.x compat.
|
||||||
// Note: IE11 compat for `spacebar` and `del` is removed for now.
|
// Note: IE11 compat for `spacebar` and `del` is removed for now.
|
||||||
const keyNames: Record<string, string | string[]> = {
|
const keyNames: Record<string, string | string[]> = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user