Skip to content

Commit ac00295

Browse files
authored
fix: wrong report for surrogate pair (#379)
* fix: wrong report for surrogate pair * Create metal-mirrors-beam.md
1 parent c78709d commit ac00295

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.changeset/metal-mirrors-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-lodash-template": patch
3+
---
4+
5+
fix: wrong report for surrogate pair

lib/parser/micro-template-eslint-parser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ function* genMicroTemplateTokens(code, options, sourceCodeStore) {
225225
* @returns {string} whitespaces
226226
*/
227227
function replaceToWhitespace(s) {
228-
return s.replace(/[^\t\n\f\r \u2028\u2029]/gu, " ");
228+
// DON'T use `u`/`v` flag!!
229+
// Characters with surrogate pairs must be replaced with two spaces.
230+
return s.replace(/[^\t\n\f\r \u2028\u2029]/g, " ");
229231
}
230232

231233
/**

tests/lib/rules/no-semi-in-template-interpolation.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ tester.run("no-semi-in-template-interpolation", rule, {
7474
<div>
7575
<% } %>
7676
`,
77+
`
78+
<p>Hello! 💰</p>
79+
<a href="<%= href %>"></a>
80+
`,
81+
`
82+
<p>Hello! AA</p>
83+
<a href="<%= href %>"></a>
84+
`,
7785
],
7886
invalid: [
7987
{

0 commit comments

Comments
 (0)