Commit bdbd2a4
[Fix]
When an HTML entity such as — is checked with ESLint, the `value`
property becomes the actual unicode character instead of the raw
literal.
This means if `—` is in the allowed strings array, and `—`
is in the code being checked, the actual value used in the JSXText check
will be `—`, which will not match against `—`, so it causes a
false positive error.
When checking against the set of allowed strings, this will now check
both the `value` and the `raw` properties of the node. For `—`, the
`raw` property will still be `—`.
If _either_ of these match the list of allowed values, then no error
will be returned.
Fixes #3130
Co-authored-by: Joe Attardi <[email protected]>
Co-authored-by: Ross <[email protected]>jsx-no-literals: properly handle HTML entities when allowed1 parent 3963193 commit bdbd2a4
File tree
2 files changed
+15
-1
lines changed- lib/rules
- tests/lib/rules
2 files changed
+15
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
287 | 299 | | |
288 | 300 | | |
289 | 301 | | |
| |||
0 commit comments