Skip to content

Commit c107f14

Browse files
committed
handle template literals, except for super edge case where match occurs inside nested template literal
1 parent dc533b7 commit c107f14

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/kit/src/exports/vite/comment_utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export function is_within_comment(content, match_index) {
9595
in_multi_line_comment ||
9696
in_html_comment ||
9797
in_single_quote ||
98-
in_double_quote
98+
in_double_quote ||
99+
in_template_literal
99100
);
100101
}

packages/kit/src/exports/vite/comment_utils.spec.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ test.each([
142142
'+page.svelte',
143143
true
144144
],
145-
['page option match inside string', '"export const trailingSlash = true"', '+page.svelte', false]
145+
['page option match inside string', '"export const trailingSlash = true"', '+page.svelte', false],
146+
[
147+
'page option match inside template literal',
148+
'`${42}export const trailingSlash = true`',
149+
'+page.svelte',
150+
false
151+
]
146152
])('warning behavior: %s', (_description, content, filename, should_warn) => {
147153
const result = should_warn_for_content(content, filename);
148154
expect(result).toBe(should_warn);

0 commit comments

Comments
 (0)