From 196194056199cb85982699a931537fc7f409c8c8 Mon Sep 17 00:00:00 2001 From: Caique Torres Date: Thu, 5 Dec 2024 08:22:34 -0300 Subject: [PATCH] fix: resolve formatting issues --- .../docs/98-reference/.generated/compile-errors.md | 12 ++++++------ packages/svelte/messages/compile-errors/template.md | 8 ++++---- packages/svelte/src/compiler/errors.js | 2 +- .../src/compiler/phases/1-parse/read/context.js | 10 +++++++--- .../src/compiler/phases/1-parse/utils/quote.js | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/documentation/docs/98-reference/.generated/compile-errors.md b/documentation/docs/98-reference/.generated/compile-errors.md index a7ff9e7f627d..05304d747f43 100644 --- a/documentation/docs/98-reference/.generated/compile-errors.md +++ b/documentation/docs/98-reference/.generated/compile-errors.md @@ -400,12 +400,6 @@ Expected token %token% Expected whitespace ``` -### unterminated_string_constant - -``` -Unterminated string constant -``` - ### export_undefined ``` @@ -994,6 +988,12 @@ Unexpected end of input '%word%' is a reserved word in JavaScript and cannot be used here ``` +### unterminated_string_constant + +``` +Unterminated string constant +``` + ### void_element_invalid_content ``` diff --git a/packages/svelte/messages/compile-errors/template.md b/packages/svelte/messages/compile-errors/template.md index 6540af7c76d7..599a1d77a57f 100644 --- a/packages/svelte/messages/compile-errors/template.md +++ b/packages/svelte/messages/compile-errors/template.md @@ -172,10 +172,6 @@ > Expected whitespace -## unterminated_string_constant - -> Unterminated string constant - ## illegal_element_attribute > `<%name%>` does not support non-event attributes or spread attributes @@ -414,6 +410,10 @@ See https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-ele > '%word%' is a reserved word in JavaScript and cannot be used here +## unterminated_string_constant + +> Unterminated string constant + ## void_element_invalid_content > Void elements cannot have children or closing tags diff --git a/packages/svelte/src/compiler/errors.js b/packages/svelte/src/compiler/errors.js index 97b284af8b35..34bf3dfdf99b 100644 --- a/packages/svelte/src/compiler/errors.js +++ b/packages/svelte/src/compiler/errors.js @@ -1553,4 +1553,4 @@ export function unexpected_reserved_word(node, word) { */ export function void_element_invalid_content(node) { e(node, "void_element_invalid_content", "Void elements cannot have children or closing tags"); -} +} \ No newline at end of file diff --git a/packages/svelte/src/compiler/phases/1-parse/read/context.js b/packages/svelte/src/compiler/phases/1-parse/read/context.js index 20f021f3a38e..08a0cc482295 100644 --- a/packages/svelte/src/compiler/phases/1-parse/read/context.js +++ b/packages/svelte/src/compiler/phases/1-parse/read/context.js @@ -102,7 +102,10 @@ function read_expression_length(parser, start) { } else if (is_bracket_close(code)) { const popped = /** @type {number} */ (bracket_stack.pop()); if (!is_bracket_pair(popped, code)) { - e.expected_token(i, String.fromCharCode(/** @type {number} */(get_bracket_close(popped)))); + e.expected_token( + i, + String.fromCharCode(/** @type {number} */ (get_bracket_close(popped))) + ); } if (bracket_stack.length === 0) { i += code <= 0xffff ? 1 : 2; @@ -145,10 +148,11 @@ function read_string_length(parser, start, quote) { if ( i < parser.template.length - 1 && is_back_quote(quote) && - code === DOLAR && full_char_code_at(parser.template, i + 1) === LEFT_BRACKET + code === DOLAR && + full_char_code_at(parser.template, i + 1) === LEFT_BRACKET ) { i++; - i = read_expression_length(parser, i) + i = read_expression_length(parser, i); } else { i += code <= 0xffff ? 1 : 2; } diff --git a/packages/svelte/src/compiler/phases/1-parse/utils/quote.js b/packages/svelte/src/compiler/phases/1-parse/utils/quote.js index 25f9e1fac8ab..517e7b3a55da 100644 --- a/packages/svelte/src/compiler/phases/1-parse/utils/quote.js +++ b/packages/svelte/src/compiler/phases/1-parse/utils/quote.js @@ -1,4 +1,4 @@ -const SINGLE_QUOTE = '\''.charCodeAt(0); +const SINGLE_QUOTE = "'".charCodeAt(0); const DOUBLE_QUOTE = '"'.charCodeAt(0); const BACK_QUOTE = '`'.charCodeAt(0);