refactor(compiler-core): use directive name in error code identifier (#163)

This commit is contained in:
Rahul Kadyan
2019-10-09 19:57:24 +05:30
committed by Evan You
parent 723dc8791b
commit 19c65a61ea
10 changed files with 52 additions and 49 deletions

View File

@@ -228,7 +228,7 @@ export function buildProps(
if (name === 'slot') {
if (!isComponent) {
context.onError(
createCompilerError(ErrorCodes.X_MISPLACED_V_SLOT, loc)
createCompilerError(ErrorCodes.X_V_SLOT_MISPLACED, loc)
)
}
continue

View File

@@ -59,7 +59,7 @@ export const transformSlotOutlet: NodeTransform = (node, context) => {
if (directives.length) {
context.onError(
createCompilerError(
ErrorCodes.X_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
directives[0].loc
)
)

View File

@@ -159,12 +159,12 @@ export const transformFor = createStructuralDirectiveTransform(
}
} else {
context.onError(
createCompilerError(ErrorCodes.X_FOR_MALFORMED_EXPRESSION, dir.loc)
createCompilerError(ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION, dir.loc)
)
}
} else {
context.onError(
createCompilerError(ErrorCodes.X_FOR_NO_EXPRESSION, dir.loc)
createCompilerError(ErrorCodes.X_V_FOR_NO_EXPRESSION, dir.loc)
)
}
}

View File

@@ -46,7 +46,7 @@ export const transformIf = createStructuralDirectiveTransform(
) {
const loc = dir.exp ? dir.exp.loc : node.loc
context.onError(
createCompilerError(ErrorCodes.X_IF_NO_EXPRESSION, dir.loc)
createCompilerError(ErrorCodes.X_V_IF_NO_EXPRESSION, dir.loc)
)
dir.exp = createSimpleExpression(`true`, false, loc)
}
@@ -125,7 +125,7 @@ export const transformIf = createStructuralDirectiveTransform(
}
} else {
context.onError(
createCompilerError(ErrorCodes.X_ELSE_NO_ADJACENT_IF, node.loc)
createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, node.loc)
)
}
break

View File

@@ -119,7 +119,7 @@ export function buildSlots(
const { arg, exp, loc } = explicitDefaultSlot
if (arg) {
context.onError(
createCompilerError(ErrorCodes.X_NAMED_SLOT_ON_COMPONENT, loc)
createCompilerError(ErrorCodes.X_V_SLOT_NAMED_SLOT_ON_COMPONENT, loc)
)
}
slotsProperties.push(buildDefaultSlot(exp, children, loc))
@@ -148,7 +148,7 @@ export function buildSlots(
if (explicitDefaultSlot) {
// already has on-component default slot - this is incorrect usage.
context.onError(
createCompilerError(ErrorCodes.X_MIXED_SLOT_USAGE, slotDir.loc)
createCompilerError(ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE, slotDir.loc)
)
break
}
@@ -224,7 +224,7 @@ export function buildSlots(
: buildDynamicSlot(slotName, slotFunction)
} else {
context.onError(
createCompilerError(ErrorCodes.X_ELSE_NO_ADJACENT_IF, vElse.loc)
createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, vElse.loc)
)
}
} else if ((vFor = findDir(slotElement, 'for'))) {
@@ -247,7 +247,7 @@ export function buildSlots(
)
} else {
context.onError(
createCompilerError(ErrorCodes.X_FOR_MALFORMED_EXPRESSION, vFor.loc)
createCompilerError(ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION, vFor.loc)
)
}
} else {
@@ -255,7 +255,10 @@ export function buildSlots(
if (staticSlotName) {
if (seenSlotNames.has(staticSlotName)) {
context.onError(
createCompilerError(ErrorCodes.X_DUPLICATE_SLOT_NAMES, dirLoc)
createCompilerError(
ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES,
dirLoc
)
)
continue
}
@@ -268,7 +271,7 @@ export function buildSlots(
if (hasTemplateSlots && extraneousChild) {
context.onError(
createCompilerError(
ErrorCodes.X_EXTRANEOUS_NON_SLOT_CHILDREN,
ErrorCodes.X_V_SLOT_EXTRANEOUS_NON_SLOT_CHILDREN,
extraneousChild.loc
)
)