Commit 9236dd0
committed
feat(require-input-label): add checkLabelFor option for sibling <label for> verification
Opt-in (default false). When enabled, an input with only a static `id`
(no aria-label/labelledby/wrapping label) is verified against the set
of static `<label for="X">` values collected from the same template.
Inputs without a matching label are flagged.
Implementation:
- Single visitor pass collects `for` values into a Set
- Id-only controls are deferred to Program:exit so forward-declared
labels are captured (label after input)
- Dynamic `id` / `for` (mustache paths, helper invocations,
`(unique-id)` bindings) fall back to the existing skip behaviour —
we deliberately don't resolve bindings symbolically
- Set lookup keeps cross-reference O(n + m)
- collectLabelFor / deferIdOnlyCheck helpers extracted to keep the
GlimmerElementNode visitor under the complexity-20 lint budget
Default off because Ember apps frequently split label/input across
component templates (design system wrappers); enabling without that
caveat would false-positive on those patterns. Documented in the rule
docs.1 parent 41bcb2e commit 9236dd0
3 files changed
Lines changed: 166 additions & 5 deletions
File tree
- docs/rules
- lib/rules
- tests/lib/rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
5 | 22 | | |
6 | 23 | | |
7 | 24 | | |
| |||
20 | 37 | | |
21 | 38 | | |
22 | 39 | | |
23 | | - | |
| 40 | + | |
24 | 41 | | |
25 | 42 | | |
26 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
27 | 47 | | |
28 | | - | |
| 48 | + | |
| 49 | + | |
29 | 50 | | |
30 | 51 | | |
31 | 52 | | |
32 | | - | |
| 53 | + | |
33 | 54 | | |
34 | 55 | | |
35 | 56 | | |
| |||
56 | 77 | | |
57 | 78 | | |
58 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
59 | 83 | | |
60 | 84 | | |
61 | 85 | | |
| |||
88 | 112 | | |
89 | 113 | | |
90 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
91 | 143 | | |
92 | 144 | | |
93 | 145 | | |
| |||
126 | 178 | | |
127 | 179 | | |
128 | 180 | | |
| 181 | + | |
129 | 182 | | |
130 | 183 | | |
131 | 184 | | |
| |||
174 | 227 | | |
175 | 228 | | |
176 | 229 | | |
177 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
178 | 233 | | |
| 234 | + | |
179 | 235 | | |
180 | 236 | | |
181 | 237 | | |
| |||
228 | 284 | | |
229 | 285 | | |
230 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
231 | 298 | | |
232 | 299 | | |
233 | 300 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
72 | 111 | | |
73 | 112 | | |
74 | 113 | | |
| |||
158 | 197 | | |
159 | 198 | | |
160 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
161 | 221 | | |
162 | 222 | | |
163 | 223 | | |
| |||
228 | 288 | | |
229 | 289 | | |
230 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
231 | 310 | | |
232 | 311 | | |
233 | 312 | | |
| |||
326 | 405 | | |
327 | 406 | | |
328 | 407 | | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
329 | 422 | | |
330 | 423 | | |
0 commit comments