Skip to content

Commit ef1ec73

Browse files
Merge pull request #2663 from johanrd/night_fix/template-no-empty-headings
Post-merge-review: Fix `template-no-empty-headings`: recognize `<this.X>`, `<@x>`, `<ns.X>` as accessible content
2 parents 1d95da7 + 130773d commit ef1ec73

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/rules/template-no-empty-headings.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ function isComponent(node) {
1919
return false;
2020
}
2121
const tag = node.tag;
22-
return /^[A-Z]/.test(tag) || tag.includes('::');
22+
// PascalCase (<MyComponent>), namespaced (<Foo::Bar>), this.-prefixed
23+
// (<this.Component>), arg-prefixed (<@component>), or dot-path (<ns.Widget>)
24+
return (
25+
/^[A-Z]/.test(tag) ||
26+
tag.includes('::') ||
27+
tag.startsWith('this.') ||
28+
tag.startsWith('@') ||
29+
tag.includes('.')
30+
);
2331
}
2432

2533
function isTextEmpty(text) {

tests/lib/rules/template-no-empty-headings.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ ruleTester.run('template-no-empty-headings', rule, {
3838
'<template><h2><div><span>{{@title}}</span></div></h2></template>',
3939
'<template><h2><span>Some text{{@title}}</span></h2></template>',
4040
'<template><h2><span><div></div>{{@title}}</span></h2></template>',
41+
42+
// Non-PascalCase component forms count as accessible content
43+
'<template><h1><this.Heading /></h1></template>',
44+
'<template><h2><@heading /></h2></template>',
45+
'<template><h3><ns.Heading /></h3></template>',
4146
],
4247
invalid: [
4348
{

0 commit comments

Comments
 (0)