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

@@ -317,7 +317,7 @@ describe('compiler: transform <slot> outlets', () => {
parseWithSlots(source, { onError })
const index = source.indexOf('v-foo')
expect(onError.mock.calls[0][0]).toMatchObject({
code: ErrorCodes.X_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
code: ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
loc: {
source: `v-foo`,
start: {

View File

@@ -219,7 +219,7 @@ describe('compiler: v-for', () => {
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
code: ErrorCodes.X_FOR_NO_EXPRESSION
code: ErrorCodes.X_V_FOR_NO_EXPRESSION
})
)
})
@@ -231,7 +231,7 @@ describe('compiler: v-for', () => {
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
code: ErrorCodes.X_FOR_MALFORMED_EXPRESSION
code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
})
)
})
@@ -243,7 +243,7 @@ describe('compiler: v-for', () => {
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
code: ErrorCodes.X_FOR_MALFORMED_EXPRESSION
code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
})
)
})
@@ -255,7 +255,7 @@ describe('compiler: v-for', () => {
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
code: ErrorCodes.X_FOR_MALFORMED_EXPRESSION
code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
})
)
})
@@ -267,7 +267,7 @@ describe('compiler: v-for', () => {
expect(onError).toHaveBeenCalledTimes(1)
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
code: ErrorCodes.X_FOR_MALFORMED_EXPRESSION
code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
})
)
})

View File

@@ -195,7 +195,7 @@ describe('compiler: v-if', () => {
const { node: node1 } = parseWithIfTransform(`<div v-else/>`, { onError })
expect(onError.mock.calls[0]).toMatchObject([
{
code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node1.loc
}
])
@@ -207,7 +207,7 @@ describe('compiler: v-if', () => {
)
expect(onError.mock.calls[1]).toMatchObject([
{
code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node2.loc
}
])
@@ -219,7 +219,7 @@ describe('compiler: v-if', () => {
)
expect(onError.mock.calls[2]).toMatchObject([
{
code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node3.loc
}
])
@@ -233,7 +233,7 @@ describe('compiler: v-if', () => {
})
expect(onError.mock.calls[0]).toMatchObject([
{
code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node1.loc
}
])
@@ -245,7 +245,7 @@ describe('compiler: v-if', () => {
)
expect(onError.mock.calls[1]).toMatchObject([
{
code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node2.loc
}
])
@@ -257,7 +257,7 @@ describe('compiler: v-if', () => {
)
expect(onError.mock.calls[2]).toMatchObject([
{
code: ErrorCodes.X_ELSE_NO_ADJACENT_IF,
code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
loc: node3.loc
}
])

View File

@@ -556,7 +556,7 @@ describe('compiler: transform component slots', () => {
parseWithSlots(source, { onError })
const index = source.indexOf('bar')
expect(onError.mock.calls[0][0]).toMatchObject({
code: ErrorCodes.X_EXTRANEOUS_NON_SLOT_CHILDREN,
code: ErrorCodes.X_V_SLOT_EXTRANEOUS_NON_SLOT_CHILDREN,
loc: {
source: `bar`,
start: {
@@ -579,7 +579,7 @@ describe('compiler: transform component slots', () => {
parseWithSlots(source, { onError })
const index = source.lastIndexOf('#foo')
expect(onError.mock.calls[0][0]).toMatchObject({
code: ErrorCodes.X_DUPLICATE_SLOT_NAMES,
code: ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES,
loc: {
source: `#foo`,
start: {
@@ -602,7 +602,7 @@ describe('compiler: transform component slots', () => {
parseWithSlots(source, { onError })
const index = source.lastIndexOf('#foo')
expect(onError.mock.calls[0][0]).toMatchObject({
code: ErrorCodes.X_MIXED_SLOT_USAGE,
code: ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE,
loc: {
source: `#foo`,
start: {
@@ -625,7 +625,7 @@ describe('compiler: transform component slots', () => {
parseWithSlots(source, { onError })
const index = source.indexOf('v-slot')
expect(onError.mock.calls[0][0]).toMatchObject({
code: ErrorCodes.X_MISPLACED_V_SLOT,
code: ErrorCodes.X_V_SLOT_MISPLACED,
loc: {
source: `v-slot`,
start: {
@@ -648,7 +648,7 @@ describe('compiler: transform component slots', () => {
parseWithSlots(source, { onError })
const index = source.indexOf('v-slot')
expect(onError.mock.calls[0][0]).toMatchObject({
code: ErrorCodes.X_NAMED_SLOT_ON_COMPONENT,
code: ErrorCodes.X_V_SLOT_NAMED_SLOT_ON_COMPONENT,
loc: {
source: `v-slot:foo`,
start: {