Skip to content

Commit 152f800

Browse files
committed
fix: docs limitations note, correct exemption count, static mustache names, type default, array includes
1 parent b6decbc commit 152f800

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

docs/rules/template-no-duplicate-form-names.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Duplicate names break form serialization: both values are emitted into
1010
the entry list, and server-side code that expects a single value typically
1111
reads only one — often not the one the author intended.
1212

13-
Two categories are exempt from the duplicate check:
13+
Three categories are exempt from the duplicate check:
1414

1515
- **Non-submitting controls** (`<input type="button">`, `<input type="reset">`,
1616
`<button type="button">`, `<button type="reset">`) are skipped entirely.
@@ -64,6 +64,9 @@ real collision.
6464

6565
## Limitations
6666

67+
- Controls associated with a form via the `form="id"` attribute (rather than
68+
by nesting inside a `<form>` element) are not tracked by this rule. Only
69+
controls that are descendants of a `<form>` element are scoped to that form.
6770
- `name` values via mustache (`name={{this.fieldName}}`) are skipped — we
6871
cannot know the value at lint time.
6972
- The `name[]` PHP-style array pattern is treated as an ordinary name; if

lib/rules/template-no-duplicate-form-names.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function buildSubmitLikeInputTypes() {
4141
if (schema.name !== 'input') {
4242
continue;
4343
}
44-
if (![...rolesSet].includes('button')) {
44+
if (!rolesSet.includes('button')) {
4545
continue;
4646
}
4747
const typeAttr = (schema.attributes || []).find((a) => a.name === 'type');
@@ -90,6 +90,17 @@ function getStaticAttrValue(node, name) {
9090
if (attr.value.type === 'GlimmerTextNode') {
9191
return { kind: 'static', value: attr.value.chars };
9292
}
93+
if (
94+
attr.value.type === 'GlimmerMustacheStatement' &&
95+
attr.value.path
96+
) {
97+
if (attr.value.path.type === 'GlimmerStringLiteral') {
98+
return { kind: 'static', value: attr.value.path.value };
99+
}
100+
if (attr.value.path.type === 'GlimmerBooleanLiteral') {
101+
return { kind: 'static', value: String(attr.value.path.value) };
102+
}
103+
}
93104
return { kind: 'dynamic', value: '' };
94105
}
95106

@@ -140,7 +151,7 @@ function getControlType(node) {
140151
if (t.kind === 'static') {
141152
return INPUT_TYPES.has(t.value.toLowerCase()) ? t.value.toLowerCase() : 'text';
142153
}
143-
if (t.kind === 'absent') {
154+
if (t.kind === 'absent' || t.kind === 'empty') {
144155
return 'text';
145156
}
146157
return 'unknown';

0 commit comments

Comments
 (0)