Commit 37b30b5
authored
Linter: Make
Now that we have support for detecting Action View Tag helpers we can
update the `html-no-duplicate-attributes` linter rule to make it Action
View Tag helpers aware.
Since the parser already transforms the nodes we only need to add
`action_view_helpers: true` to the parser options and handle
`ERBOpenTagNode` in the visitor to reset attribute tracking for tag
helper elements.
With this pull request, the following snippets are now also flagged by
the `html-no-duplicate-attributes` linter rule:
```erb
<%= tag.div data: { value: "value-one" }, data_value: "value-two" %>
<%= tag.div aria: { label: "Label one" }, aria_label: "Label two" %>
<%= image_tag image_path("image.png"), src: "image-2.png" %>
<%= turbo_frame_tag "my-frame", id: "other-frame" %>
<%= link_to "Click here", "/path", href: "/other-path" %>
<%= javascript_include_tag "application", src: "other.js" %>
```
For example, the first example now reports as:
```
Duplicate attribute `data-value`. Browsers only use the first occurrence and ignore duplicate attributes. Remove the duplicate or merge the values.
```html-no-duplicate-attributes Action View Helpers aware (#1449)1 parent bd698f4 commit 37b30b5
File tree
2 files changed
+94
-2
lines changed- javascript/packages/linter
- src/rules
- test/rules
2 files changed
+94
-2
lines changedLines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
27 | 37 | | |
28 | 38 | | |
29 | 39 | | |
30 | | - | |
31 | 40 | | |
32 | 41 | | |
33 | 42 | | |
| |||
172 | 181 | | |
173 | 182 | | |
174 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
175 | 188 | | |
176 | 189 | | |
177 | 190 | | |
| |||
Lines changed: 79 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
294 | 373 | | |
0 commit comments