Skip to content

Commit 86cafb1

Browse files
NullVoxPopuliclaude
andcommitted
Remove one-error-per-file limitation in template-sort-invocations
The rule had a `reported` flag that, once set to true, prevented any further errors from being reported in the same file. The original ember-template-lint rule reports all out-of-order invocations, not just the first one. Remove the flag so all violations are reported. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent e9cbe4e commit 86cafb1

2 files changed

Lines changed: 150 additions & 39 deletions

File tree

lib/rules/template-sort-invocations.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ module.exports = {
2727
},
2828

2929
create(context) {
30-
let reported = false;
31-
3230
function getAttributeName(node) {
3331
return node.name;
3432
}
@@ -163,11 +161,10 @@ module.exports = {
163161
GlimmerElementNode(node) {
164162
const { attributes, modifiers } = node;
165163

166-
if (!reported && attributes && attributes.length > 1) {
164+
if (attributes && attributes.length > 1) {
167165
const index = getUnsortedAttributeIndex(attributes);
168166

169167
if (index !== -1) {
170-
reported = true;
171168
context.report({
172169
node: attributes[index],
173170
messageId: 'attributeOrder',
@@ -179,11 +176,10 @@ module.exports = {
179176
}
180177
}
181178

182-
if (!reported && modifiers && modifiers.length > 1) {
179+
if (modifiers && modifiers.length > 1) {
183180
const index = getUnsortedModifierIndex(modifiers);
184181

185182
if (index !== -1) {
186-
reported = true;
187183
context.report({
188184
node: modifiers[index],
189185
messageId: 'modifierOrder',
@@ -195,9 +191,8 @@ module.exports = {
195191
}
196192
}
197193

198-
if (!reported && !canSkipSplattributesLast(node)) {
194+
if (!canSkipSplattributesLast(node)) {
199195
const splattributes = attributes.at(-1);
200-
reported = true;
201196

202197
// When ...attributes is the only attribute, report as attributeOrder
203198
// (the ordering issue is that ...attributes should appear after modifiers)
@@ -220,11 +215,10 @@ module.exports = {
220215
},
221216

222217
GlimmerBlockStatement(node) {
223-
if (!reported && node.hash && node.hash.pairs && node.hash.pairs.length > 1) {
218+
if (node.hash && node.hash.pairs && node.hash.pairs.length > 1) {
224219
const index = getUnsortedHashPairIndex(node.hash.pairs);
225220

226221
if (index !== -1) {
227-
reported = true;
228222
context.report({
229223
node: node.hash.pairs[index],
230224
messageId: 'hashPairOrder',
@@ -238,12 +232,10 @@ module.exports = {
238232
},
239233

240234
GlimmerMustacheStatement(node) {
241-
if (!reported && node.hash && node.hash.pairs && node.hash.pairs.length > 1) {
235+
if (node.hash && node.hash.pairs && node.hash.pairs.length > 1) {
242236
const index = getUnsortedHashPairIndex(node.hash.pairs);
243237

244238
if (index !== -1) {
245-
reported = true;
246-
247239
// Component invocations with a string positional param (e.g. {{component "ui/button" ...}})
248240
// treat hash pairs as component attributes
249241
const isComponentInvocation =
@@ -277,11 +269,10 @@ module.exports = {
277269
},
278270

279271
GlimmerSubExpression(node) {
280-
if (!reported && node.hash && node.hash.pairs && node.hash.pairs.length > 1) {
272+
if (node.hash && node.hash.pairs && node.hash.pairs.length > 1) {
281273
const index = getUnsortedHashPairIndex(node.hash.pairs);
282274

283275
if (index !== -1) {
284-
reported = true;
285276
context.report({
286277
node: node.hash.pairs[index],
287278
messageId: 'hashPairOrder',

0 commit comments

Comments
 (0)