Skip to content

Commit 4bf7953

Browse files
committed
test: add case for multiline template literals
1 parent defb316 commit 4bf7953

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

test/prefer-string-raw.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ test.snapshot({
7979
'a = {[`a\\\\b${foo}cd${foo.bar}e\\\\f`]: b}',
8080
'a = `a${foo}${foo.bar}b\\\\c`',
8181
'a = `a\\\\b${"c\\\\d"}e`',
82+
outdent`
83+
a = \`\\\\a
84+
b\`
85+
`,
86+
outdent`
87+
a = \`\\\\a\${foo}
88+
b\${bar}c
89+
d\\\\\\\\e\`
90+
`,
8291
],
8392
});
8493

test/snapshots/prefer-string-raw.js.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,57 @@ Generated by [AVA](https://avajs.dev).
241241
> 1 | a = \`a\\\\b${"c\\\\d"}e\`␊
242242
| ^^^^^^ \`String.raw\` should be used to avoid escaping \`\\\`.␊
243243
`
244+
245+
## invalid(6): a = `\\a b`
246+
247+
> Input
248+
249+
`␊
250+
1 | a = \`\\\\a␊
251+
2 | b\`␊
252+
`
253+
254+
> Output
255+
256+
`␊
257+
1 | a = String.raw\`\\a␊
258+
2 | b\`␊
259+
`
260+
261+
> Error 1/1
262+
263+
`␊
264+
> 1 | a = \`\\\\a␊
265+
| ^^^^␊
266+
> 2 | b\`␊
267+
| ^^^ \`String.raw\` should be used to avoid escaping \`\\\`.␊
268+
`
269+
270+
## invalid(7): a = `\\a${foo} b${bar}c d\\\\e`
271+
272+
> Input
273+
274+
`␊
275+
1 | a = \`\\\\a${foo}␊
276+
2 | b${bar}c␊
277+
3 | d\\\\\\\\e\`␊
278+
`
279+
280+
> Output
281+
282+
`␊
283+
1 | a = String.raw\`\\a${foo}␊
284+
2 | b${bar}c␊
285+
3 | d\\\\e\`␊
286+
`
287+
288+
> Error 1/1
289+
290+
`␊
291+
> 1 | a = \`\\\\a${foo}␊
292+
| ^^^^^^^^^^␊
293+
> 2 | b${bar}c␊
294+
| ^^^^^^^^␊
295+
> 3 | d\\\\\\\\e\`␊
296+
| ^^^^^^^^ \`String.raw\` should be used to avoid escaping \`\\\`.␊
297+
`
134 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)