Skip to content

Commit d017425

Browse files
committed
fix: update expected error message for SFC block order validation
1 parent 0e4ef40 commit d017425

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/rules/enforce-sfc-order.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export default {
139139
messageId: 'wrongOrder',
140140
data: {
141141
currentBlock: block.type,
142-
expected: 'after',
142+
expected: 'before',
143143
otherBlock: expectedPreviousType,
144144
},
145145
})

tests/enforce-sfc-order.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ export default { name: 'Test' }
118118
const wrongOrderErrors = testRule(invalidSfc2) // template before script with script-first order
119119
expect(wrongOrderErrors).toHaveLength(1)
120120
expect(wrongOrderErrors[0].messageId).toBe('wrongOrder')
121+
// Verify the error message is correct: script should come before template
122+
expect(wrongOrderErrors[0].data.currentBlock).toBe('script')
123+
expect(wrongOrderErrors[0].data.expected).toBe('before')
124+
expect(wrongOrderErrors[0].data.otherBlock).toBe('template')
121125

122126
const invalidSfc3 = `<script>
123127
export default { name: 'Test' }

0 commit comments

Comments
 (0)