Skip to content

Commit

Permalink
Add missing suggestions and messages to tests (#2402)
Browse files Browse the repository at this point in the history
  • Loading branch information
FloEdelmann committed Feb 18, 2024
1 parent e936a15 commit 5227eed
Show file tree
Hide file tree
Showing 10 changed files with 371 additions and 19 deletions.
1 change: 0 additions & 1 deletion lib/rules/require-expose.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ module.exports = {
messages: {
requireExpose:
'The public properties of the component must be explicitly declared using `expose`. If the component does not have public properties, declare it empty.',

addExposeOptionForEmpty:
'Add the `expose` option to give an empty array.',
addExposeOptionForAll:
Expand Down
16 changes: 15 additions & 1 deletion tests/lib/rules/define-macros-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,21 @@ tester.run('define-macros-order', rule, {
},
{
message: defineExposeNotTheLast,
line: 6
line: 6,
suggestions: [
{
messageId: 'putExposeAtTheLast',
output: `
<script setup>
const a = defineModel('a')
defineOptions({})
const c = defineModel('c')
const b = defineModel('b')
defineExpose({})
</script>
`
}
]
}
]
}
Expand Down
36 changes: 29 additions & 7 deletions tests/lib/rules/no-child-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ ruleTester.run('no-child-content', rule, {
column: 29,
endColumn: 32,
suggestions: [
{ output: '<template><div v-html="foo"></div></template>' }
{
messageId: 'removeChildContent',
output: '<template><div v-html="foo"></div></template>'
}
]
}
]
Expand All @@ -93,7 +96,10 @@ ruleTester.run('no-child-content', rule, {
column: 29,
endColumn: 38,
suggestions: [
{ output: '<template><div v-html="foo"></div></template>' }
{
messageId: 'removeChildContent',
output: '<template><div v-html="foo"></div></template>'
}
]
}
]
Expand All @@ -109,7 +115,10 @@ ruleTester.run('no-child-content', rule, {
column: 29,
endColumn: 37,
suggestions: [
{ output: '<template><div v-html="foo"></div></template>' }
{
messageId: 'removeChildContent',
output: '<template><div v-html="foo"></div></template>'
}
]
}
]
Expand All @@ -125,7 +134,10 @@ ruleTester.run('no-child-content', rule, {
column: 29,
endColumn: 41,
suggestions: [
{ output: '<template><div v-html="foo"></div></template>' }
{
messageId: 'removeChildContent',
output: '<template><div v-html="foo"></div></template>'
}
]
}
]
Expand All @@ -152,6 +164,7 @@ ruleTester.run('no-child-content', rule, {
endColumn: 11,
suggestions: [
{
messageId: 'removeChildContent',
output: `
<template>
<div v-html="foo"></div>
Expand All @@ -173,7 +186,10 @@ ruleTester.run('no-child-content', rule, {
column: 29,
endColumn: 32,
suggestions: [
{ output: '<template><div v-text="foo"></div></template>' }
{
messageId: 'removeChildContent',
output: '<template><div v-text="foo"></div></template>'
}
]
}
]
Expand All @@ -190,7 +206,10 @@ ruleTester.run('no-child-content', rule, {
column: 26,
endColumn: 29,
suggestions: [
{ output: '<template><div v-t="foo"></div></template>' }
{
messageId: 'removeChildContent',
output: '<template><div v-t="foo"></div></template>'
}
]
}
]
Expand All @@ -207,7 +226,10 @@ ruleTester.run('no-child-content', rule, {
column: 29,
endColumn: 32,
suggestions: [
{ output: '<template><div v-html="foo"></div></template>' }
{
messageId: 'removeChildContent',
output: '<template><div v-html="foo"></div></template>'
}
]
}
]
Expand Down
20 changes: 19 additions & 1 deletion tests/lib/rules/no-required-prop-with-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,25 @@ tester.run('no-required-prop-with-default', rule, {
errors: [
{
message: 'Prop "name" should be optional.',
line: 6
line: 6,
suggestions: [
{
messageId: 'fixRequiredProp',
output: `
<script>
import { defineComponent } from 'vue'
export default defineComponent({
props: {
name: {
required: false,
default: 'Hello'
}
}
})
</script>
`
}
]
}
]
},
Expand Down
13 changes: 12 additions & 1 deletion tests/lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,18 @@ tester.run('no-unused-vars', rule, {
{
code: '<template><div v-for="(a, _i) in foo" ></div></template>',
options: [{ ignorePattern: '^_' }],
errors: ["'a' is defined but never used."]
errors: [
{
message: "'a' is defined but never used.",
suggestions: [
{
messageId: 'replaceWithUnderscore',
output:
'<template><div v-for="(_a, _i) in foo" ></div></template>'
}
]
}
]
},
{
code: '<template><my-component v-slot="a" >{{d}}</my-component></template>',
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/rules/prefer-true-attribute-shorthand.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@ tester.run('prefer-true-attribute-shorthand', rule, {
column: 17,
suggestions: [
{
messageId: 'rewriteIntoLongVueProp',
output: `
<template>
<MyComp :show="true" />
</template>`
},
{
messageId: 'rewriteIntoLongHtmlAttr',
output: `
<template>
<MyComp show="show" />
Expand Down
12 changes: 11 additions & 1 deletion tests/lib/rules/require-emit-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,17 @@ ruleTester.run('require-emit-validator', rule, {
{
messageId: 'skipped',
data: { name: 'foo' },
line: 3
line: 3,
suggestions: [
{
messageId: 'emptyValidation',
output: `
<script setup>
const emit = defineEmits({foo:() => true})
</script>
`
}
]
}
],
languageOptions: {
Expand Down
Loading

0 comments on commit 5227eed

Please sign in to comment.