Skip to content

Commit 8f4bcc0

Browse files
Merge pull request #2701 from johanrd/day_fix/template-table-groups
Post-merge-review: Fix template-table-groups: align with upstream's table semantics
2 parents a009cd1 + 92a5cf4 commit 8f4bcc0

2 files changed

Lines changed: 5 additions & 18 deletions

File tree

lib/rules/template-table-groups.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,6 @@ module.exports = {
178178
return;
179179
}
180180

181-
// Truly empty table (no content at all between tags) must have table groups
182-
if (!node.children || node.children.length === 0) {
183-
const sourceCode = context.sourceCode;
184-
const text = sourceCode.getText(node);
185-
const openEnd = text.indexOf('>') + 1;
186-
const closeStart = text.lastIndexOf('</');
187-
if (closeStart >= 0 && closeStart <= openEnd) {
188-
context.report({ node, messageId: 'missing' });
189-
return;
190-
}
191-
}
192-
193181
const children = getEffectiveChildren(node.children);
194182

195183
let currentAllowedMinimumIndices = new Set([0]);
@@ -198,7 +186,9 @@ module.exports = {
198186
for (const child of children) {
199187
if (child === CONTROL_FLOW_START_MARK) {
200188
scopedIndices.push(currentAllowedMinimumIndices);
201-
currentAllowedMinimumIndices = new Set(currentAllowedMinimumIndices);
189+
currentAllowedMinimumIndices = new Set(
190+
scopedIndices.reduce((acc, indices) => [...acc, ...indices])
191+
);
202192
continue;
203193
}
204194
if (child === CONTROL_FLOW_END_MARK) {

tests/lib/rules/template-table-groups.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ ruleTester.run('template-table-groups', rule, {
145145
'<template><table><!-- this --></table></template>',
146146
'<template><table>{{! or this }}</table></template>',
147147
'<template><table> </table></template>',
148+
// Empty <table></table> matches upstream (ember-template-lint) behavior of not flagging.
149+
'<template><table></table></template>',
148150
'<template><table> <caption>Foo</caption></table></template>',
149151
'<template><table><colgroup><col style="background-color: red"></colgroup></table></template>',
150152
'<template><table><thead><tr><td>Header</td></tr></thead></table></template>',
@@ -310,11 +312,6 @@ ruleTester.run('template-table-groups', rule, {
310312
output: null,
311313
errors: [{ messageId: 'missing' }],
312314
},
313-
{
314-
code: '<template><table></table></template>',
315-
output: null,
316-
errors: [{ messageId: 'missing' }],
317-
},
318315
{
319316
code: '<template><table> whitespace<thead></thead></table></template>',
320317
output: null,

0 commit comments

Comments
 (0)