Skip to content

test(html-self-closing): make tests more strict #2840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 98 additions & 15 deletions tests/lib/rules/html-self-closing.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,68 @@ tester.run('html-self-closing', rule, {
{
code: '<template><div></div></template>',
output: '<template><div/></template>',
errors: ['Require self-closing on HTML elements (<div>).']
errors: [
{
message: 'Require self-closing on HTML elements (<div>).',
line: 1,
column: 16,
endLine: 1,
endColumn: 22
}
]
},
{
code: '<template><img/></template>',
output: '<template><img></template>',
errors: ['Disallow self-closing on HTML void elements (<img/>).']
errors: [
{
message: 'Disallow self-closing on HTML void elements (<img/>).',
line: 1,
column: 15,
endLine: 1,
endColumn: 17
}
]
},
{
code: '<template><x-test></x-test></template>',
output: '<template><x-test/></template>',
errors: ['Require self-closing on Vue.js custom components (<x-test>).']
errors: [
{
message:
'Require self-closing on Vue.js custom components (<x-test>).',
line: 1,
column: 19,
endLine: 1,
endColumn: 28
}
]
},
{
code: '<template><svg><path></path></svg></template>',
output: '<template><svg><path/></svg></template>',
errors: ['Require self-closing on SVG elements (<path>).']
errors: [
{
message: 'Require self-closing on SVG elements (<path>).',
line: 1,
column: 22,
endLine: 1,
endColumn: 29
}
]
},
{
code: '<template><math><mspace></mspace></math></template>',
output: '<template><math><mspace/></math></template>',
errors: ['Require self-closing on MathML elements (<mspace>).']
errors: [
{
message: 'Require self-closing on MathML elements (<mspace>).',
line: 1,
column: 25,
endLine: 1,
endColumn: 34
}
]
},

// others
Expand All @@ -130,7 +171,13 @@ tester.run('html-self-closing', rule, {
</template>`,
options: [anyWith({ html: { normal: 'always' } })],
errors: [
{ message: 'Require self-closing on HTML elements (<div>).', line: 2 }
{
message: 'Require self-closing on HTML elements (<div>).',
line: 2,
column: 8,
endLine: 2,
endColumn: 14
}
]
},
{
Expand All @@ -149,7 +196,13 @@ tester.run('html-self-closing', rule, {
</template>`,
options: [anyWith({ html: { normal: 'never' } })],
errors: [
{ message: 'Disallow self-closing on HTML elements (<div/>).', line: 3 }
{
message: 'Disallow self-closing on HTML elements (<div/>).',
line: 3,
column: 7,
endLine: 3,
endColumn: 9
}
]
},
{
Expand All @@ -170,7 +223,10 @@ tester.run('html-self-closing', rule, {
errors: [
{
message: 'Require self-closing on HTML void elements (<img>).',
line: 4
line: 4,
column: 3,
endLine: 4,
endColumn: 8
}
]
},
Expand All @@ -192,7 +248,10 @@ tester.run('html-self-closing', rule, {
errors: [
{
message: 'Disallow self-closing on HTML void elements (<img/>).',
line: 5
line: 5,
column: 7,
endLine: 5,
endColumn: 9
}
]
},
Expand All @@ -215,7 +274,10 @@ tester.run('html-self-closing', rule, {
{
message:
'Require self-closing on Vue.js custom components (<x-test>).',
line: 6
line: 6,
column: 11,
endLine: 6,
endColumn: 20
}
]
},
Expand All @@ -238,7 +300,10 @@ tester.run('html-self-closing', rule, {
{
message:
'Disallow self-closing on Vue.js custom components (<x-test/>).',
line: 7
line: 7,
column: 10,
endLine: 7,
endColumn: 12
}
]
},
Expand All @@ -258,7 +323,13 @@ tester.run('html-self-closing', rule, {
</template>`,
options: [anyWith({ svg: 'always' })],
errors: [
{ message: 'Require self-closing on SVG elements (<path>).', line: 8 }
{
message: 'Require self-closing on SVG elements (<path>).',
line: 8,
column: 14,
endLine: 8,
endColumn: 21
}
]
},
{
Expand All @@ -277,7 +348,13 @@ tester.run('html-self-closing', rule, {
</template>`,
options: [anyWith({ svg: 'never' })],
errors: [
{ message: 'Disallow self-closing on SVG elements (<path/>).', line: 9 }
{
message: 'Disallow self-closing on SVG elements (<path/>).',
line: 9,
column: 13,
endLine: 9,
endColumn: 15
}
]
},
{
Expand All @@ -298,7 +375,10 @@ tester.run('html-self-closing', rule, {
errors: [
{
message: 'Require self-closing on MathML elements (<mspace>).',
line: 10
line: 10,
column: 17,
endLine: 10,
endColumn: 26
}
]
},
Expand All @@ -320,7 +400,10 @@ tester.run('html-self-closing', rule, {
errors: [
{
message: 'Disallow self-closing on MathML elements (<mspace/>).',
line: 11
line: 11,
column: 16,
endLine: 11,
endColumn: 18
}
]
}
Expand Down