Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion lib/rules/template-no-empty-headings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ function isComponent(node) {
return false;
}
const tag = node.tag;
return /^[A-Z]/.test(tag) || tag.includes('::');
// PascalCase (<MyComponent>), namespaced (<Foo::Bar>), this.-prefixed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we couldl also have a web-component here, too -- kebab-case

// (<this.Component>), arg-prefixed (<@component>), or dot-path (<ns.Widget>)
return (
/^[A-Z]/.test(tag) ||
tag.includes('::') ||
tag.startsWith('this.') ||
tag.startsWith('@') ||
tag.includes('.')
);
}

function isTextEmpty(text) {
Expand Down
5 changes: 5 additions & 0 deletions tests/lib/rules/template-no-empty-headings.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ ruleTester.run('template-no-empty-headings', rule, {
'<template><h2><div><span>{{@title}}</span></div></h2></template>',
'<template><h2><span>Some text{{@title}}</span></h2></template>',
'<template><h2><span><div></div>{{@title}}</span></h2></template>',

// Non-PascalCase component forms count as accessible content
'<template><h1><this.Heading /></h1></template>',
'<template><h2><@heading /></h2></template>',
'<template><h3><ns.Heading /></h3></template>',
],
invalid: [
{
Expand Down
Loading