Commit 5588e6a
committed
Fix template-no-quoteless-attributes false positive on quoted values containing
Master's detection uses an unanchored regex `/=\s*[^"'{]/` against the
full attribute source text. For an attribute like `data-x="foo=bar"`,
the regex matches the `=` between `foo` and `bar` (followed by `b`),
incorrectly flagging the well-quoted attribute as quoteless. The
"autofix" then replaces the attribute text with itself — a no-op fix
that still surfaces the spurious error.
Replaces both detection regexes with a direct first-character check on
the value node's source text. `sourceCode.getText(node.value)` returns
the value verbatim including its surrounding quotes when present
(`"foo"` for `class="foo"`, `foo` for `class=foo`, `""` for the empty
range of a valueless attribute), so a single character comparison is
sufficient and unambiguous.
Adds two regression tests (one in each parser suite) for the
`data-x="foo=bar"` case. Both fail on master and pass on the branch.
The valueless-attribute case (`<input disabled>`, `...attributes`) is
already covered by existing valid tests and is preserved by the
`valueSource.length === 0` guard.=
1 parent c97528a commit 5588e6a
2 files changed
Lines changed: 19 additions & 18 deletions
File tree
- lib/rules
- tests/lib/rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
45 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
0 commit comments