mirror of https://github.com/vuejs/core.git
style: respect root prettier config
This commit is contained in:
parent
17af64c0c1
commit
63aacf6194
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"semi": false,
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "all"
|
|
||||||
}
|
|
|
@ -291,11 +291,11 @@ export function generate(
|
||||||
if (vaporHelpers.size)
|
if (vaporHelpers.size)
|
||||||
// TODO: extract import codegen
|
// TODO: extract import codegen
|
||||||
preamble = `import { ${[...vaporHelpers]
|
preamble = `import { ${[...vaporHelpers]
|
||||||
.map((h) => `${h} as _${h}`)
|
.map(h => `${h} as _${h}`)
|
||||||
.join(', ')} } from 'vue/vapor';`
|
.join(', ')} } from 'vue/vapor';`
|
||||||
if (helpers.size)
|
if (helpers.size)
|
||||||
preamble = `import { ${[...helpers]
|
preamble = `import { ${[...helpers]
|
||||||
.map((h) => `${h} as _${h}`)
|
.map(h => `${h} as _${h}`)
|
||||||
.join(', ')} } from 'vue';`
|
.join(', ')} } from 'vue';`
|
||||||
|
|
||||||
if (!isSetupInlined) {
|
if (!isSetupInlined) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ export function genWithDirective(
|
||||||
// directive
|
// directive
|
||||||
pushMulti(
|
pushMulti(
|
||||||
['[', ']', ', '],
|
['[', ']', ', '],
|
||||||
...opers.map((oper) => () => {
|
...opers.map(oper => () => {
|
||||||
push('[')
|
push('[')
|
||||||
|
|
||||||
const { dir, builtin } = oper
|
const { dir, builtin } = oper
|
||||||
|
@ -73,7 +73,7 @@ export function genWithDirective(
|
||||||
function genDirectiveModifiers(modifiers: string[]) {
|
function genDirectiveModifiers(modifiers: string[]) {
|
||||||
return modifiers
|
return modifiers
|
||||||
.map(
|
.map(
|
||||||
(value) =>
|
value =>
|
||||||
`${isSimpleIdentifier(value) ? value : JSON.stringify(value)}: true`,
|
`${isSimpleIdentifier(value) ? value : JSON.stringify(value)}: true`,
|
||||||
)
|
)
|
||||||
.join(', ')
|
.join(', ')
|
||||||
|
|
|
@ -8,7 +8,7 @@ import type {
|
||||||
export function genInsertNode(oper: InsertNodeIRNode, context: CodegenContext) {
|
export function genInsertNode(oper: InsertNodeIRNode, context: CodegenContext) {
|
||||||
const { newline, pushFnCall, vaporHelper } = context
|
const { newline, pushFnCall, vaporHelper } = context
|
||||||
const elements = ([] as number[]).concat(oper.element)
|
const elements = ([] as number[]).concat(oper.element)
|
||||||
let element = elements.map((el) => `n${el}`).join(', ')
|
let element = elements.map(el => `n${el}`).join(', ')
|
||||||
if (elements.length > 1) element = `[${element}]`
|
if (elements.length > 1) element = `[${element}]`
|
||||||
newline()
|
newline()
|
||||||
pushFnCall(
|
pushFnCall(
|
||||||
|
@ -28,7 +28,7 @@ export function genPrependNode(
|
||||||
pushFnCall(
|
pushFnCall(
|
||||||
vaporHelper('prepend'),
|
vaporHelper('prepend'),
|
||||||
`n${oper.parent}`,
|
`n${oper.parent}`,
|
||||||
oper.elements.map((el) => `n${el}`).join(', '),
|
oper.elements.map(el => `n${el}`).join(', '),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,6 @@ export function genAppendNode(oper: AppendNodeIRNode, context: CodegenContext) {
|
||||||
pushFnCall(
|
pushFnCall(
|
||||||
vaporHelper('append'),
|
vaporHelper('append'),
|
||||||
`n${oper.parent}`,
|
`n${oper.parent}`,
|
||||||
oper.elements.map((el) => `n${el}`).join(', '),
|
oper.elements.map(el => `n${el}`).join(', '),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ export function genSetEvent(oper: SetEventIRNode, context: CodegenContext) {
|
||||||
},
|
},
|
||||||
// 4th arg, gen options
|
// 4th arg, gen options
|
||||||
!!options.length &&
|
!!options.length &&
|
||||||
(() => push(`{ ${options.map((v) => `${v}: true`).join(', ')} }`)),
|
(() => push(`{ ${options.map(v => `${v}: true`).join(', ')} }`)),
|
||||||
)
|
)
|
||||||
|
|
||||||
function genEventHandler(context: CodegenContext) {
|
function genEventHandler(context: CodegenContext) {
|
||||||
|
@ -83,5 +83,5 @@ export function genSetEvent(oper: SetEventIRNode, context: CodegenContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function genArrayExpression(elements: string[]) {
|
function genArrayExpression(elements: string[]) {
|
||||||
return `[${elements.map((it) => JSON.stringify(it)).join(', ')}]`
|
return `[${elements.map(it => JSON.stringify(it)).join(', ')}]`
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ function createRootContext(
|
||||||
) {
|
) {
|
||||||
return this.registerOperation(...operations)
|
return this.registerOperation(...operations)
|
||||||
}
|
}
|
||||||
const existing = this.block.effect.find((e) =>
|
const existing = this.block.effect.find(e =>
|
||||||
isSameExpression(e.expressions, expressions as IRExpression[]),
|
isSameExpression(e.expressions, expressions as IRExpression[]),
|
||||||
)
|
)
|
||||||
if (existing) {
|
if (existing) {
|
||||||
|
@ -174,7 +174,7 @@ function createRootContext(
|
||||||
registerTemplate() {
|
registerTemplate() {
|
||||||
let templateNode: TemplateFactoryIRNode | FragmentFactoryIRNode
|
let templateNode: TemplateFactoryIRNode | FragmentFactoryIRNode
|
||||||
|
|
||||||
const existing = root.template.findIndex((t) =>
|
const existing = root.template.findIndex(t =>
|
||||||
this.template
|
this.template
|
||||||
? t.type === IRNodeTypes.TEMPLATE_FACTORY &&
|
? t.type === IRNodeTypes.TEMPLATE_FACTORY &&
|
||||||
t.template === this.template
|
t.template === this.template
|
||||||
|
@ -356,7 +356,7 @@ function processDynamicChildren(ctx: TransformContext<RootNode | ElementNode>) {
|
||||||
ctx.registerOperation({
|
ctx.registerOperation({
|
||||||
type: IRNodeTypes.INSERT_NODE,
|
type: IRNodeTypes.INSERT_NODE,
|
||||||
loc: node.loc,
|
loc: node.loc,
|
||||||
element: prevChildren.map((child) => child.id!),
|
element: prevChildren.map(child => child.id!),
|
||||||
parent: ctx.reference(),
|
parent: ctx.reference(),
|
||||||
anchor,
|
anchor,
|
||||||
})
|
})
|
||||||
|
@ -364,7 +364,7 @@ function processDynamicChildren(ctx: TransformContext<RootNode | ElementNode>) {
|
||||||
ctx.registerOperation({
|
ctx.registerOperation({
|
||||||
type: IRNodeTypes.PREPEND_NODE,
|
type: IRNodeTypes.PREPEND_NODE,
|
||||||
loc: node.loc,
|
loc: node.loc,
|
||||||
elements: prevChildren.map((child) => child.id!),
|
elements: prevChildren.map(child => child.id!),
|
||||||
parent: ctx.reference(),
|
parent: ctx.reference(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ function processDynamicChildren(ctx: TransformContext<RootNode | ElementNode>) {
|
||||||
ctx.registerOperation({
|
ctx.registerOperation({
|
||||||
type: IRNodeTypes.APPEND_NODE,
|
type: IRNodeTypes.APPEND_NODE,
|
||||||
loc: node.loc,
|
loc: node.loc,
|
||||||
elements: prevChildren.map((child) => child.id!),
|
elements: prevChildren.map(child => child.id!),
|
||||||
parent: ctx.reference(),
|
parent: ctx.reference(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ export function createIfBranch(
|
||||||
children: [
|
children: [
|
||||||
extend({}, node, {
|
extend({}, node, {
|
||||||
props: node.props.filter(
|
props: node.props.filter(
|
||||||
(p) => p.type !== NodeTypes.DIRECTIVE && p.name !== 'if',
|
p => p.type !== NodeTypes.DIRECTIVE && p.name !== 'if',
|
||||||
),
|
),
|
||||||
} as TemplateChildNode),
|
} as TemplateChildNode),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"semi": false,
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "all"
|
|
||||||
}
|
|
|
@ -16,7 +16,7 @@ describe('watchEffect and onEffectCleanup', () => {
|
||||||
|
|
||||||
scope.run(() => {
|
scope.run(() => {
|
||||||
source = ref(0)
|
source = ref(0)
|
||||||
watchEffect((onCleanup) => {
|
watchEffect(onCleanup => {
|
||||||
source.value
|
source.value
|
||||||
|
|
||||||
onCleanup(() => (dummy += 2))
|
onCleanup(() => (dummy += 2))
|
||||||
|
|
|
@ -114,7 +114,7 @@ describe('renderWatch', () => {
|
||||||
return { source, change, renderSource, changeRender }
|
return { source, change, renderSource, changeRender }
|
||||||
},
|
},
|
||||||
// render
|
// render
|
||||||
(_ctx) => {
|
_ctx => {
|
||||||
// Render Watch API
|
// Render Watch API
|
||||||
renderEffect(() => {
|
renderEffect(() => {
|
||||||
const current = _ctx.renderSource
|
const current = _ctx.renderSource
|
||||||
|
@ -123,7 +123,7 @@ describe('renderWatch', () => {
|
||||||
})
|
})
|
||||||
renderWatch(
|
renderWatch(
|
||||||
() => _ctx.renderSource,
|
() => _ctx.renderSource,
|
||||||
(value) => {
|
value => {
|
||||||
calls.push(`renderWatch ${value}`)
|
calls.push(`renderWatch ${value}`)
|
||||||
onEffectCleanup(() => calls.push(`renderWatch cleanup ${value}`))
|
onEffectCleanup(() => calls.push(`renderWatch cleanup ${value}`))
|
||||||
},
|
},
|
||||||
|
@ -175,7 +175,7 @@ describe('renderWatch', () => {
|
||||||
return { source, update }
|
return { source, update }
|
||||||
},
|
},
|
||||||
// render
|
// render
|
||||||
(ctx) => {
|
ctx => {
|
||||||
renderEffect(() => {
|
renderEffect(() => {
|
||||||
ctx.source
|
ctx.source
|
||||||
})
|
})
|
||||||
|
@ -206,7 +206,7 @@ describe('renderWatch', () => {
|
||||||
return { source, update }
|
return { source, update }
|
||||||
},
|
},
|
||||||
// render
|
// render
|
||||||
(ctx) => {
|
ctx => {
|
||||||
renderEffect(() => {
|
renderEffect(() => {
|
||||||
ctx.source
|
ctx.source
|
||||||
})
|
})
|
||||||
|
|
|
@ -259,7 +259,7 @@ function getTypeIndex(
|
||||||
expectedTypes: PropType<any> | void | null | true,
|
expectedTypes: PropType<any> | void | null | true,
|
||||||
): number {
|
): number {
|
||||||
if (isArray(expectedTypes)) {
|
if (isArray(expectedTypes)) {
|
||||||
return expectedTypes.findIndex((t) => isSameType(t, type))
|
return expectedTypes.findIndex(t => isSameType(t, type))
|
||||||
} else if (isFunction(expectedTypes)) {
|
} else if (isFunction(expectedTypes)) {
|
||||||
return isSameType(expectedTypes, type) ? 0 : -1
|
return isSameType(expectedTypes, type) ? 0 : -1
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ function getModelAssigner(
|
||||||
): AssignerFn {
|
): AssignerFn {
|
||||||
const metadata = instance.metadata.get(el)!
|
const metadata = instance.metadata.get(el)!
|
||||||
const fn: any = metadata.props['onUpdate:modelValue']
|
const fn: any = metadata.props['onUpdate:modelValue']
|
||||||
return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn
|
return isArray(fn) ? value => invokeArrayFns(fn, value) : fn
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCompositionStart(e: Event) {
|
function onCompositionStart(e: Event) {
|
||||||
|
@ -38,7 +38,7 @@ export const vModelText: ObjectDirective<
|
||||||
assignKeyMap.set(el, assigner)
|
assignKeyMap.set(el, assigner)
|
||||||
|
|
||||||
const castToNumber = number // || (vnode.props && vnode.props.type === 'number')
|
const castToNumber = number // || (vnode.props && vnode.props.type === 'number')
|
||||||
on(el, lazy ? 'change' : 'input', (e) => {
|
on(el, lazy ? 'change' : 'input', e => {
|
||||||
if ((e.target as any).composing) return
|
if ((e.target as any).composing) return
|
||||||
let domValue: string | number = el.value
|
let domValue: string | number = el.value
|
||||||
if (trim) {
|
if (trim) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ export function callWithAsyncErrorHandling(
|
||||||
if (isFunction(fn)) {
|
if (isFunction(fn)) {
|
||||||
const res = callWithErrorHandling(fn, instance, type, args)
|
const res = callWithErrorHandling(fn, instance, type, args)
|
||||||
if (res && isPromise(res)) {
|
if (res && isPromise(res)) {
|
||||||
res.catch((err) => {
|
res.catch(err => {
|
||||||
handleError(err, instance, type)
|
handleError(err, instance, type)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ export const createIf = (
|
||||||
|
|
||||||
renderWatch(
|
renderWatch(
|
||||||
() => !!condition(),
|
() => !!condition(),
|
||||||
(value) => {
|
value => {
|
||||||
parent ||= anchor.parentNode
|
parent ||= anchor.parentNode
|
||||||
if ((branch = value ? b1 : b2)) {
|
if ((branch = value ? b1 : b2)) {
|
||||||
let scope = effectScope()
|
let scope = effectScope()
|
||||||
|
|
|
@ -74,7 +74,7 @@ function doWatch(
|
||||||
|
|
||||||
const createMiddleware =
|
const createMiddleware =
|
||||||
(instance: ComponentInternalInstance | null): BaseWatchMiddleware =>
|
(instance: ComponentInternalInstance | null): BaseWatchMiddleware =>
|
||||||
(next) => {
|
next => {
|
||||||
let value: unknown
|
let value: unknown
|
||||||
// with lifecycle
|
// with lifecycle
|
||||||
if (instance && instance.isMounted) {
|
if (instance && instance.isMounted) {
|
||||||
|
|
|
@ -189,7 +189,7 @@ export const createVaporSyncScheduler: SchedulerFactory =
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createVaporPreScheduler: SchedulerFactory =
|
export const createVaporPreScheduler: SchedulerFactory =
|
||||||
(instance) => (job, effect, isInit) => {
|
instance => (job, effect, isInit) => {
|
||||||
if (isInit) {
|
if (isInit) {
|
||||||
effect.run()
|
effect.run()
|
||||||
} else {
|
} else {
|
||||||
|
@ -200,7 +200,7 @@ export const createVaporPreScheduler: SchedulerFactory =
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createVaporRenderingScheduler: SchedulerFactory =
|
export const createVaporRenderingScheduler: SchedulerFactory =
|
||||||
(instance) => (job, effect, isInit) => {
|
instance => (job, effect, isInit) => {
|
||||||
if (isInit) {
|
if (isInit) {
|
||||||
effect.run()
|
effect.run()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue