diff --git a/lib/rules/template-no-autofocus-attribute.js b/lib/rules/template-no-autofocus-attribute.js
index b0d775d14a..34acbbe2ed 100644
--- a/lib/rules/template-no-autofocus-attribute.js
+++ b/lib/rules/template-no-autofocus-attribute.js
@@ -27,7 +27,6 @@ module.exports = {
node: autofocusAttr,
messageId: 'noAutofocus',
fix(fixer) {
- // Remove the attribute including preceding whitespace
const sourceCode = context.sourceCode;
const text = sourceCode.getText();
const attrStart = autofocusAttr.range[0];
@@ -43,6 +42,19 @@ module.exports = {
});
}
},
+
+ GlimmerMustacheStatement(node) {
+ if (!node.hash || !node.hash.pairs) {
+ return;
+ }
+ const autofocusPair = node.hash.pairs.find((pair) => pair.key === 'autofocus');
+ if (autofocusPair) {
+ context.report({
+ node: autofocusPair,
+ messageId: 'noAutofocus',
+ });
+ }
+ },
};
},
};
diff --git a/tests/lib/rules/template-no-autofocus-attribute.js b/tests/lib/rules/template-no-autofocus-attribute.js
index afee5842d2..ad67f03943 100644
--- a/tests/lib/rules/template-no-autofocus-attribute.js
+++ b/tests/lib/rules/template-no-autofocus-attribute.js
@@ -53,5 +53,75 @@ ruleTester.run('template-no-autofocus-attribute', rule, {
},
],
},
+ {
+ code: `
+ {{input type="text" autofocus=true}}
+ `,
+ output: null,
+ errors: [
+ {
+ messageId: 'noAutofocus',
+ type: 'GlimmerHashPair',
+ },
+ ],
+ },
+ {
+ code: `
+ {{component "input" type="text" autofocus=true}}
+ `,
+ output: null,
+ errors: [
+ {
+ messageId: 'noAutofocus',
+ type: 'GlimmerHashPair',
+ },
+ ],
+ },
+ {
+ code: `
+
+
+ `,
+ output: `
+
+
+ `,
+ errors: [
+ {
+ messageId: 'noAutofocus',
+ type: 'GlimmerAttrNode',
+ },
+ ],
+ },
+ {
+ code: `
+
+
+ `,
+ output: `
+
+
+ `,
+ errors: [
+ {
+ messageId: 'noAutofocus',
+ type: 'GlimmerAttrNode',
+ },
+ ],
+ },
+ {
+ code: `
+
+ `,
+ output: `
+
+ `,
+ errors: [
+ {
+ messageId: 'noAutofocus',
+ type: 'GlimmerAttrNode',
+ },
+ ],
+ },
],
});