Skip to content

Commit 5227eed

Browse files
authored
Add missing suggestions and messages to tests (#2402)
1 parent e936a15 commit 5227eed

10 files changed

+371
-19
lines changed

lib/rules/require-expose.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ module.exports = {
6767
messages: {
6868
requireExpose:
6969
'The public properties of the component must be explicitly declared using `expose`. If the component does not have public properties, declare it empty.',
70-
7170
addExposeOptionForEmpty:
7271
'Add the `expose` option to give an empty array.',
7372
addExposeOptionForAll:

tests/lib/rules/define-macros-order.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,21 @@ tester.run('define-macros-order', rule, {
928928
},
929929
{
930930
message: defineExposeNotTheLast,
931-
line: 6
931+
line: 6,
932+
suggestions: [
933+
{
934+
messageId: 'putExposeAtTheLast',
935+
output: `
936+
<script setup>
937+
const a = defineModel('a')
938+
defineOptions({})
939+
const c = defineModel('c')
940+
const b = defineModel('b')
941+
defineExpose({})
942+
</script>
943+
`
944+
}
945+
]
932946
}
933947
]
934948
}

tests/lib/rules/no-child-content.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ ruleTester.run('no-child-content', rule, {
7777
column: 29,
7878
endColumn: 32,
7979
suggestions: [
80-
{ output: '<template><div v-html="foo"></div></template>' }
80+
{
81+
messageId: 'removeChildContent',
82+
output: '<template><div v-html="foo"></div></template>'
83+
}
8184
]
8285
}
8386
]
@@ -93,7 +96,10 @@ ruleTester.run('no-child-content', rule, {
9396
column: 29,
9497
endColumn: 38,
9598
suggestions: [
96-
{ output: '<template><div v-html="foo"></div></template>' }
99+
{
100+
messageId: 'removeChildContent',
101+
output: '<template><div v-html="foo"></div></template>'
102+
}
97103
]
98104
}
99105
]
@@ -109,7 +115,10 @@ ruleTester.run('no-child-content', rule, {
109115
column: 29,
110116
endColumn: 37,
111117
suggestions: [
112-
{ output: '<template><div v-html="foo"></div></template>' }
118+
{
119+
messageId: 'removeChildContent',
120+
output: '<template><div v-html="foo"></div></template>'
121+
}
113122
]
114123
}
115124
]
@@ -125,7 +134,10 @@ ruleTester.run('no-child-content', rule, {
125134
column: 29,
126135
endColumn: 41,
127136
suggestions: [
128-
{ output: '<template><div v-html="foo"></div></template>' }
137+
{
138+
messageId: 'removeChildContent',
139+
output: '<template><div v-html="foo"></div></template>'
140+
}
129141
]
130142
}
131143
]
@@ -152,6 +164,7 @@ ruleTester.run('no-child-content', rule, {
152164
endColumn: 11,
153165
suggestions: [
154166
{
167+
messageId: 'removeChildContent',
155168
output: `
156169
<template>
157170
<div v-html="foo"></div>
@@ -173,7 +186,10 @@ ruleTester.run('no-child-content', rule, {
173186
column: 29,
174187
endColumn: 32,
175188
suggestions: [
176-
{ output: '<template><div v-text="foo"></div></template>' }
189+
{
190+
messageId: 'removeChildContent',
191+
output: '<template><div v-text="foo"></div></template>'
192+
}
177193
]
178194
}
179195
]
@@ -190,7 +206,10 @@ ruleTester.run('no-child-content', rule, {
190206
column: 26,
191207
endColumn: 29,
192208
suggestions: [
193-
{ output: '<template><div v-t="foo"></div></template>' }
209+
{
210+
messageId: 'removeChildContent',
211+
output: '<template><div v-t="foo"></div></template>'
212+
}
194213
]
195214
}
196215
]
@@ -207,7 +226,10 @@ ruleTester.run('no-child-content', rule, {
207226
column: 29,
208227
endColumn: 32,
209228
suggestions: [
210-
{ output: '<template><div v-html="foo"></div></template>' }
229+
{
230+
messageId: 'removeChildContent',
231+
output: '<template><div v-html="foo"></div></template>'
232+
}
211233
]
212234
}
213235
]

tests/lib/rules/no-required-prop-with-default.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,25 @@ tester.run('no-required-prop-with-default', rule, {
867867
errors: [
868868
{
869869
message: 'Prop "name" should be optional.',
870-
line: 6
870+
line: 6,
871+
suggestions: [
872+
{
873+
messageId: 'fixRequiredProp',
874+
output: `
875+
<script>
876+
import { defineComponent } from 'vue'
877+
export default defineComponent({
878+
props: {
879+
name: {
880+
required: false,
881+
default: 'Hello'
882+
}
883+
}
884+
})
885+
</script>
886+
`
887+
}
888+
]
871889
}
872890
]
873891
},

tests/lib/rules/no-unused-vars.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,18 @@ tester.run('no-unused-vars', rule, {
123123
{
124124
code: '<template><div v-for="(a, _i) in foo" ></div></template>',
125125
options: [{ ignorePattern: '^_' }],
126-
errors: ["'a' is defined but never used."]
126+
errors: [
127+
{
128+
message: "'a' is defined but never used.",
129+
suggestions: [
130+
{
131+
messageId: 'replaceWithUnderscore',
132+
output:
133+
'<template><div v-for="(_a, _i) in foo" ></div></template>'
134+
}
135+
]
136+
}
137+
]
127138
},
128139
{
129140
code: '<template><my-component v-slot="a" >{{d}}</my-component></template>',

tests/lib/rules/prefer-true-attribute-shorthand.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,14 @@ tester.run('prefer-true-attribute-shorthand', rule, {
264264
column: 17,
265265
suggestions: [
266266
{
267+
messageId: 'rewriteIntoLongVueProp',
267268
output: `
268269
<template>
269270
<MyComp :show="true" />
270271
</template>`
271272
},
272273
{
274+
messageId: 'rewriteIntoLongHtmlAttr',
273275
output: `
274276
<template>
275277
<MyComp show="show" />

tests/lib/rules/require-emit-validator.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,17 @@ ruleTester.run('require-emit-validator', rule, {
383383
{
384384
messageId: 'skipped',
385385
data: { name: 'foo' },
386-
line: 3
386+
line: 3,
387+
suggestions: [
388+
{
389+
messageId: 'emptyValidation',
390+
output: `
391+
<script setup>
392+
const emit = defineEmits({foo:() => true})
393+
</script>
394+
`
395+
}
396+
]
387397
}
388398
],
389399
languageOptions: {

0 commit comments

Comments
 (0)