From ff3b95ebf6d3d7d2f84e1a13193b90afe08f9e88 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 24 Apr 2024 18:45:51 -0400 Subject: [PATCH] more --- .../svelte/messages/compile-errors/parse.md | 42 ++-- .../svelte/messages/compile-errors/slots.md | 31 --- .../messages/compile-errors/template.md | 32 +++ packages/svelte/src/compiler/errors.js | 231 ++++++++---------- .../src/compiler/phases/1-parse/index.js | 6 +- .../compiler/phases/1-parse/read/script.js | 6 +- .../compiler/phases/1-parse/state/element.js | 14 +- .../src/compiler/phases/1-parse/state/tag.js | 14 +- .../compiler/phases/2-analyze/validation.js | 20 +- .../samples/attribute-empty/_config.js | 2 +- .../samples/catch-without-await/_config.js | 2 +- .../_config.js | 2 +- .../_config.js | 2 +- .../_config.js | 2 +- .../_config.js | 2 +- .../_config.js | 2 +- .../component-slot-duplicate-error/_config.js | 2 +- .../component-slot-nested-error-2/_config.js | 2 +- .../component-slot-nested-error-3/_config.js | 2 +- .../component-slot-nested-error/_config.js | 2 +- .../samples/else-before-closing-3/_config.js | 2 +- .../samples/else-before-closing/_config.js | 2 +- .../else-if-before-closing-2/_config.js | 2 +- .../empty-classname-binding/_config.js | 6 +- .../samples/empty-directive-name/_config.js | 6 +- .../raw-mustaches-whitespace/_config.js | 2 +- .../samples/script-unclosed/_config.js | 2 +- .../snippet-children-conflict/_config.js | 2 +- .../samples/then-before-closing/_config.js | 2 +- .../samples/then-without-await/_config.js | 2 +- .../_config.js | 4 +- .../unexpected-end-of-input-d/_config.js | 2 +- .../unexpected-end-of-input/_config.js | 2 +- .../errors.json | 2 +- .../errors.json | 2 +- .../component-slot-dynamic/errors.json | 2 +- .../errors.json | 2 +- .../component-slotted-each-block/errors.json | 2 +- .../component-slotted-if-block/errors.json | 2 +- .../samples/debug-invalid-args/errors.json | 2 +- .../directive-non-expression/errors.json | 2 +- .../html-block-in-attribute/errors.json | 2 +- .../html-block-in-textarea/errors.json | 2 +- .../logic-block-in-attribute/errors.json | 2 +- .../logic-block-in-textarea/errors.json | 2 +- .../script-invalid-context/errors.json | 2 +- .../slot-attribute-invalid/errors.json | 2 +- 47 files changed, 227 insertions(+), 255 deletions(-) delete mode 100644 packages/svelte/messages/compile-errors/slots.md diff --git a/packages/svelte/messages/compile-errors/parse.md b/packages/svelte/messages/compile-errors/parse.md index c7270f0d45..3da67adcfc 100644 --- a/packages/svelte/messages/compile-errors/parse.md +++ b/packages/svelte/messages/compile-errors/parse.md @@ -1,12 +1,12 @@ -## unclosed_element +## element_unclosed > `<%name%>` was left open -## unclosed_block +## block_unclosed > Block was left open -## unexpected_block_close +## block_unexpected_close > Unexpected block closing tag @@ -26,7 +26,7 @@ > '%word%' is a reserved word in JavaScript and cannot be used here -## missing_whitespace +## expected_whitespace > Expected whitespace @@ -34,23 +34,19 @@ > Expected identifier or destructure pattern -## invalid_script_context +## script_invalid_context > If the context attribute is supplied, its value must be "module" -## invalid_elseif +## block_invalid_elseif > 'elseif' should be 'else if' -## invalid_continuing_block_placement +## block_invalid_continuation_placement > {:...} block is invalid at this position (did you forget to close the preceeding element or block?) -## invalid_block_missing_parent - -> %child% block must be a child of %parent% - -## duplicate_block_part +## block_duplicate_clause > %name% cannot appear more than once within a block @@ -62,37 +58,33 @@ > Expected an identifier -## invalid_debug +## debug_tag_invalid_arguments > {@debug ...} arguments must be identifiers, not arbitrary expressions -## invalid_const +## const_tag_invalid_expression > {@const ...} must be an assignment -## invalid_block_placement +## block_invalid_placement > {#%name% ...} block cannot be %location% -## invalid_tag_placement +## tag_invalid_placement > {@%name% ...} tag cannot be %location% -## missing_attribute_value +## expected_attribute_value > Expected attribute value -## unclosed_attribute_value - -> Expected closing %delimiter% character - -## invalid_directive_value +## directive_invalid_value > Directive value must be a JavaScript expression enclosed in curly braces -## empty_directive_name +## directive_missing_name -> %type% name cannot be empty +> `%type%` name cannot be empty ## invalid_closing_tag @@ -144,4 +136,4 @@ ## invalid_snippet_rest_parameter -> snippets do not support rest parameters; use an array instead \ No newline at end of file +> snippets do not support rest parameters; use an array instead diff --git a/packages/svelte/messages/compile-errors/slots.md b/packages/svelte/messages/compile-errors/slots.md deleted file mode 100644 index 9f92448847..0000000000 --- a/packages/svelte/messages/compile-errors/slots.md +++ /dev/null @@ -1,31 +0,0 @@ -## invalid_slot_element_attribute - -> `` can only receive attributes and (optionally) let directives - -## invalid_slot_attribute - -> slot attribute must be a static value - -## invalid_slot_name_default - -> `default` is a reserved word — it cannot be used as a slot name - -## invalid_slot_name - -> slot attribute must be a static value - -## invalid_slot_placement - -> Element with a slot='...' attribute must be a child of a component or a descendant of a custom element - -## duplicate_slot_name - -> Duplicate slot name '%name%' in <%component%> - -## invalid_default_slot_content - -> Found default slot content alongside an explicit slot="default" - -## conflicting_children_snippet - -> Cannot use explicit children snippet at the same time as implicit children content. Remove either the non-whitespace content or the children snippet block \ No newline at end of file diff --git a/packages/svelte/messages/compile-errors/template.md b/packages/svelte/messages/compile-errors/template.md index ffcf300e7a..71f51f0b37 100644 --- a/packages/svelte/messages/compile-errors/template.md +++ b/packages/svelte/messages/compile-errors/template.md @@ -96,10 +96,42 @@ > %thing% is invalid inside <%parent%> +## slot_attribute_invalid + +> slot attribute must be a static value + +## slot_attribute_invalid_placement + +> Element with a slot='...' attribute must be a child of a component or a descendant of a custom element + +## slot_element_invalid_attribute + +> `` can only receive attributes and (optionally) let directives + +## slot_element_invalid_name + +> slot attribute must be a static value + +## slot_element_invalid_name_default + +> `default` is a reserved word — it cannot be used as a slot name + +## slot_attribute_duplicate + +> Duplicate slot name '%name%' in <%component%> + +## slot_default_duplicate + +> Found default slot content alongside an explicit slot="default" + ## slot_snippet_conflict > Cannot use `` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely. +## snippet_conflict + +> Cannot use explicit children snippet at the same time as implicit children content. Remove either the non-whitespace content or the children snippet block + ## style_directive_invalid_modifier > `style:` directive can only use the `important` modifier diff --git a/packages/svelte/src/compiler/errors.js b/packages/svelte/src/compiler/errors.js index d0b4bbe327..4c8eefda13 100644 --- a/packages/svelte/src/compiler/errors.js +++ b/packages/svelte/src/compiler/errors.js @@ -210,8 +210,8 @@ export function cyclical_reactive_declaration(node, cycle) { * @param {string} name * @returns {never} */ -export function unclosed_element(node, name) { - e(node, "unclosed_element", `\`<${name}>\` was left open`); +export function element_unclosed(node, name) { + e(node, "element_unclosed", `\`<${name}>\` was left open`); } /** @@ -219,8 +219,8 @@ export function unclosed_element(node, name) { * @param {null | number | NodeLike} node * @returns {never} */ -export function unclosed_block(node) { - e(node, "unclosed_block", "Block was left open"); +export function block_unclosed(node) { + e(node, "block_unclosed", "Block was left open"); } /** @@ -228,8 +228,8 @@ export function unclosed_block(node) { * @param {null | number | NodeLike} node * @returns {never} */ -export function unexpected_block_close(node) { - e(node, "unexpected_block_close", "Unexpected block closing tag"); +export function block_unexpected_close(node) { + e(node, "block_unexpected_close", "Unexpected block closing tag"); } /** @@ -276,8 +276,8 @@ export function unexpected_reserved_word(node, word) { * @param {null | number | NodeLike} node * @returns {never} */ -export function missing_whitespace(node) { - e(node, "missing_whitespace", "Expected whitespace"); +export function expected_whitespace(node) { + e(node, "expected_whitespace", "Expected whitespace"); } /** @@ -294,8 +294,8 @@ export function expected_pattern(node) { * @param {null | number | NodeLike} node * @returns {never} */ -export function invalid_script_context(node) { - e(node, "invalid_script_context", "If the context attribute is supplied, its value must be \"module\""); +export function script_invalid_context(node) { + e(node, "script_invalid_context", "If the context attribute is supplied, its value must be \"module\""); } /** @@ -303,8 +303,8 @@ export function invalid_script_context(node) { * @param {null | number | NodeLike} node * @returns {never} */ -export function invalid_elseif(node) { - e(node, "invalid_elseif", "'elseif' should be 'else if'"); +export function block_invalid_elseif(node) { + e(node, "block_invalid_elseif", "'elseif' should be 'else if'"); } /** @@ -312,19 +312,8 @@ export function invalid_elseif(node) { * @param {null | number | NodeLike} node * @returns {never} */ -export function invalid_continuing_block_placement(node) { - e(node, "invalid_continuing_block_placement", "{:...} block is invalid at this position (did you forget to close the preceeding element or block?)"); -} - -/** - * %child% block must be a child of %parent% - * @param {null | number | NodeLike} node - * @param {string} child - * @param {string} parent - * @returns {never} - */ -export function invalid_block_missing_parent(node, child, parent) { - e(node, "invalid_block_missing_parent", `${child} block must be a child of ${parent}`); +export function block_invalid_continuation_placement(node) { + e(node, "block_invalid_continuation_placement", "{:...} block is invalid at this position (did you forget to close the preceeding element or block?)"); } /** @@ -333,8 +322,8 @@ export function invalid_block_missing_parent(node, child, parent) { * @param {string} name * @returns {never} */ -export function duplicate_block_part(node, name) { - e(node, "duplicate_block_part", `${name} cannot appear more than once within a block`); +export function block_duplicate_clause(node, name) { + e(node, "block_duplicate_clause", `${name} cannot appear more than once within a block`); } /** @@ -360,8 +349,8 @@ export function expected_identifier(node) { * @param {null | number | NodeLike} node * @returns {never} */ -export function invalid_debug(node) { - e(node, "invalid_debug", "{@debug ...} arguments must be identifiers, not arbitrary expressions"); +export function debug_tag_invalid_arguments(node) { + e(node, "debug_tag_invalid_arguments", "{@debug ...} arguments must be identifiers, not arbitrary expressions"); } /** @@ -369,8 +358,8 @@ export function invalid_debug(node) { * @param {null | number | NodeLike} node * @returns {never} */ -export function invalid_const(node) { - e(node, "invalid_const", "{@const ...} must be an assignment"); +export function const_tag_invalid_expression(node) { + e(node, "const_tag_invalid_expression", "{@const ...} must be an assignment"); } /** @@ -380,8 +369,8 @@ export function invalid_const(node) { * @param {string} location * @returns {never} */ -export function invalid_block_placement(node, name, location) { - e(node, "invalid_block_placement", `{#${name} ...} block cannot be ${location}`); +export function block_invalid_placement(node, name, location) { + e(node, "block_invalid_placement", `{#${name} ...} block cannot be ${location}`); } /** @@ -391,8 +380,8 @@ export function invalid_block_placement(node, name, location) { * @param {string} location * @returns {never} */ -export function invalid_tag_placement(node, name, location) { - e(node, "invalid_tag_placement", `{@${name} ...} tag cannot be ${location}`); +export function tag_invalid_placement(node, name, location) { + e(node, "tag_invalid_placement", `{@${name} ...} tag cannot be ${location}`); } /** @@ -400,18 +389,8 @@ export function invalid_tag_placement(node, name, location) { * @param {null | number | NodeLike} node * @returns {never} */ -export function missing_attribute_value(node) { - e(node, "missing_attribute_value", "Expected attribute value"); -} - -/** - * Expected closing %delimiter% character - * @param {null | number | NodeLike} node - * @param {string} delimiter - * @returns {never} - */ -export function unclosed_attribute_value(node, delimiter) { - e(node, "unclosed_attribute_value", `Expected closing ${delimiter} character`); +export function expected_attribute_value(node) { + e(node, "expected_attribute_value", "Expected attribute value"); } /** @@ -419,18 +398,18 @@ export function unclosed_attribute_value(node, delimiter) { * @param {null | number | NodeLike} node * @returns {never} */ -export function invalid_directive_value(node) { - e(node, "invalid_directive_value", "Directive value must be a JavaScript expression enclosed in curly braces"); +export function directive_invalid_value(node) { + e(node, "directive_invalid_value", "Directive value must be a JavaScript expression enclosed in curly braces"); } /** - * %type% name cannot be empty + * `%type%` name cannot be empty * @param {null | number | NodeLike} node * @param {string} type * @returns {never} */ -export function empty_directive_name(node, type) { - e(node, "empty_directive_name", `${type} name cannot be empty`); +export function directive_missing_name(node, type) { + e(node, "directive_missing_name", `\`${type}\` name cannot be empty`); } /** @@ -777,80 +756,6 @@ export function conflicting_property_name(node) { e(node, "conflicting_property_name", "Cannot have a property and a component export with the same name"); } -/** - * `` can only receive attributes and (optionally) let directives - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function invalid_slot_element_attribute(node) { - e(node, "invalid_slot_element_attribute", "`` can only receive attributes and (optionally) let directives"); -} - -/** - * slot attribute must be a static value - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function invalid_slot_attribute(node) { - e(node, "invalid_slot_attribute", "slot attribute must be a static value"); -} - -/** - * `default` is a reserved word — it cannot be used as a slot name - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function invalid_slot_name_default(node) { - e(node, "invalid_slot_name_default", "`default` is a reserved word — it cannot be used as a slot name"); -} - -/** - * slot attribute must be a static value - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function invalid_slot_name(node) { - e(node, "invalid_slot_name", "slot attribute must be a static value"); -} - -/** - * Element with a slot='...' attribute must be a child of a component or a descendant of a custom element - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function invalid_slot_placement(node) { - e(node, "invalid_slot_placement", "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"); -} - -/** - * Duplicate slot name '%name%' in <%component%> - * @param {null | number | NodeLike} node - * @param {string} name - * @param {string} component - * @returns {never} - */ -export function duplicate_slot_name(node, name, component) { - e(node, "duplicate_slot_name", `Duplicate slot name '${name}' in <${component}>`); -} - -/** - * Found default slot content alongside an explicit slot="default" - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function invalid_default_slot_content(node) { - e(node, "invalid_default_slot_content", "Found default slot content alongside an explicit slot=\"default\""); -} - -/** - * Cannot use explicit children snippet at the same time as implicit children content. Remove either the non-whitespace content or the children snippet block - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function conflicting_children_snippet(node) { - e(node, "conflicting_children_snippet", "Cannot use explicit children snippet at the same time as implicit children content. Remove either the non-whitespace content or the children snippet block"); -} - /** * An element that uses the `animate:` directive must be the only child of a keyed `{#each ...}` block * @param {null | number | NodeLike} node @@ -1077,6 +982,71 @@ export function node_invalid_placement(node, thing, parent) { e(node, "node_invalid_placement", `${thing} is invalid inside <${parent}>`); } +/** + * slot attribute must be a static value + * @param {null | number | NodeLike} node + * @returns {never} + */ +export function slot_attribute_invalid(node) { + e(node, "slot_attribute_invalid", "slot attribute must be a static value"); +} + +/** + * Element with a slot='...' attribute must be a child of a component or a descendant of a custom element + * @param {null | number | NodeLike} node + * @returns {never} + */ +export function slot_attribute_invalid_placement(node) { + e(node, "slot_attribute_invalid_placement", "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"); +} + +/** + * `` can only receive attributes and (optionally) let directives + * @param {null | number | NodeLike} node + * @returns {never} + */ +export function slot_element_invalid_attribute(node) { + e(node, "slot_element_invalid_attribute", "`` can only receive attributes and (optionally) let directives"); +} + +/** + * slot attribute must be a static value + * @param {null | number | NodeLike} node + * @returns {never} + */ +export function slot_element_invalid_name(node) { + e(node, "slot_element_invalid_name", "slot attribute must be a static value"); +} + +/** + * `default` is a reserved word — it cannot be used as a slot name + * @param {null | number | NodeLike} node + * @returns {never} + */ +export function slot_element_invalid_name_default(node) { + e(node, "slot_element_invalid_name_default", "`default` is a reserved word — it cannot be used as a slot name"); +} + +/** + * Duplicate slot name '%name%' in <%component%> + * @param {null | number | NodeLike} node + * @param {string} name + * @param {string} component + * @returns {never} + */ +export function slot_attribute_duplicate(node, name, component) { + e(node, "slot_attribute_duplicate", `Duplicate slot name '${name}' in <${component}>`); +} + +/** + * Found default slot content alongside an explicit slot="default" + * @param {null | number | NodeLike} node + * @returns {never} + */ +export function slot_default_duplicate(node) { + e(node, "slot_default_duplicate", "Found default slot content alongside an explicit slot=\"default\""); +} + /** * Cannot use `` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely. * @param {null | number | NodeLike} node @@ -1086,6 +1056,15 @@ export function slot_snippet_conflict(node) { e(node, "slot_snippet_conflict", "Cannot use `` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely."); } +/** + * Cannot use explicit children snippet at the same time as implicit children content. Remove either the non-whitespace content or the children snippet block + * @param {null | number | NodeLike} node + * @returns {never} + */ +export function snippet_conflict(node) { + e(node, "snippet_conflict", "Cannot use explicit children snippet at the same time as implicit children content. Remove either the non-whitespace content or the children snippet block"); +} + /** * `style:` directive can only use the `important` modifier * @param {null | number | NodeLike} node diff --git a/packages/svelte/src/compiler/phases/1-parse/index.js b/packages/svelte/src/compiler/phases/1-parse/index.js index d5f5cda052..69889bfce8 100644 --- a/packages/svelte/src/compiler/phases/1-parse/index.js +++ b/packages/svelte/src/compiler/phases/1-parse/index.js @@ -92,10 +92,10 @@ export class Parser { if (current.type === 'RegularElement') { current.end = current.start + 1; - e.unclosed_element(current, current.name); + e.element_unclosed(current, current.name); } else { current.end = current.start + 1; - e.unclosed_block(current); + e.block_unclosed(current); } } @@ -263,7 +263,7 @@ export class Parser { require_whitespace() { if (!regex_whitespace.test(this.template[this.index])) { - e.missing_whitespace(this.index); + e.expected_whitespace(this.index); } this.allow_whitespace(); diff --git a/packages/svelte/src/compiler/phases/1-parse/read/script.js b/packages/svelte/src/compiler/phases/1-parse/read/script.js index 172e1dddf1..19137fea34 100644 --- a/packages/svelte/src/compiler/phases/1-parse/read/script.js +++ b/packages/svelte/src/compiler/phases/1-parse/read/script.js @@ -16,13 +16,13 @@ function get_context(attributes) { if (!context) return 'default'; if (context.value.length !== 1 || context.value[0].type !== 'Text') { - e.invalid_script_context(context.start); + e.script_invalid_context(context.start); } const value = context.value[0].data; if (value !== 'module') { - e.invalid_script_context(context.start); + e.script_invalid_context(context.start); } return value; @@ -38,7 +38,7 @@ export function read_script(parser, start, attributes) { const script_start = parser.index; const data = parser.read_until(regex_closing_script_tag); if (parser.index >= parser.template.length) { - e.unclosed_element(parser.template.length, 'script'); + e.element_unclosed(parser.template.length, 'script'); } const source = diff --git a/packages/svelte/src/compiler/phases/1-parse/state/element.js b/packages/svelte/src/compiler/phases/1-parse/state/element.js index 04ad3b327e..4a2b4fbb42 100644 --- a/packages/svelte/src/compiler/phases/1-parse/state/element.js +++ b/packages/svelte/src/compiler/phases/1-parse/state/element.js @@ -436,7 +436,7 @@ function read_static_attribute(parser) { parser.allow_whitespace(); let raw = parser.match_regex(regex_attribute_value); if (!raw) { - e.missing_attribute_value(parser.index); + e.expected_attribute_value(parser.index); } parser.index += raw.length; @@ -552,7 +552,7 @@ function read_attribute(parser) { const [directive_name, ...modifiers] = name.slice(colon_index + 1).split('|'); if (directive_name === '') { - e.empty_directive_name(start + colon_index + 1, type); + e.directive_missing_name({ start, end: start + colon_index + 1 }, name); } if (type === 'StyleDirective') { @@ -577,7 +577,7 @@ function read_attribute(parser) { const attribute_contains_text = /** @type {any[]} */ (value).length > 1 || first_value.type === 'Text'; if (attribute_contains_text) { - e.invalid_directive_value(/** @type {number} */ (first_value.start)); + e.directive_invalid_value(/** @type {number} */ (first_value.start)); } else { expression = first_value.expression; } @@ -678,14 +678,14 @@ function read_attribute_value(parser) { const pos = error.position?.[0]; if (pos !== undefined && parser.template.slice(pos - 1, pos + 1) === '/>') { parser.index = pos; - e.unclosed_attribute_value(pos, quote_mark || '}'); + e.expected_token(pos, quote_mark || '}'); } } throw error; } if (value.length === 0 && !quote_mark) { - e.missing_attribute_value(parser.index); + e.expected_attribute_value(parser.index); } if (quote_mark) parser.index += 1; @@ -732,12 +732,12 @@ function read_sequence(parser, done, location) { const index = parser.index - 1; parser.eat('#'); const name = parser.read_until(/[^a-z]/); - e.invalid_block_placement(index, name, location); + e.block_invalid_placement(index, name, location); } else if (parser.match('@')) { const index = parser.index - 1; parser.eat('@'); const name = parser.read_until(/[^a-z]/); - e.invalid_tag_placement(index, name, location); + e.tag_invalid_placement(index, name, location); } flush(parser.index - 1); diff --git a/packages/svelte/src/compiler/phases/1-parse/state/tag.js b/packages/svelte/src/compiler/phases/1-parse/state/tag.js index 537e0b6b34..1e722808e2 100644 --- a/packages/svelte/src/compiler/phases/1-parse/state/tag.js +++ b/packages/svelte/src/compiler/phases/1-parse/state/tag.js @@ -331,7 +331,7 @@ function next(parser) { if (block.type === 'IfBlock') { if (!parser.eat('else')) e.expected_token(start, '{:else} or {:else if}'); - if (parser.eat('if')) e.invalid_elseif(start); + if (parser.eat('if')) e.block_invalid_elseif(start); parser.allow_whitespace(); @@ -389,7 +389,7 @@ function next(parser) { if (block.type === 'AwaitBlock') { if (parser.eat('then')) { if (block.then) { - e.duplicate_block_part(start, '{:then}'); + e.block_duplicate_clause(start, '{:then}'); } if (!parser.eat('}')) { @@ -408,7 +408,7 @@ function next(parser) { if (parser.eat('catch')) { if (block.catch) { - e.duplicate_block_part(start, '{:catch}'); + e.block_duplicate_clause(start, '{:catch}'); } if (!parser.eat('}')) { @@ -428,7 +428,7 @@ function next(parser) { e.expected_token(start, '{:then ...} or {:catch ...}'); } - e.invalid_continuing_block_placement(start); + e.block_invalid_continuation_placement(start); } /** @param {import('../index.js').Parser} parser */ @@ -466,11 +466,11 @@ function close(parser) { case 'RegularElement': // TODO handle implicitly closed elements - e.unexpected_block_close(start); + e.block_unexpected_close(start); break; default: - e.unexpected_block_close(start); + e.block_unexpected_close(start); } parser.allow_whitespace(); @@ -522,7 +522,7 @@ function special(parser) { identifiers.forEach( /** @param {any} node */ (node) => { if (node.type !== 'Identifier') { - e.invalid_debug(/** @type {number} */ (node.start)); + e.debug_tag_invalid_arguments(/** @type {number} */ (node.start)); } } ); diff --git a/packages/svelte/src/compiler/phases/2-analyze/validation.js b/packages/svelte/src/compiler/phases/2-analyze/validation.js index 7b72ef3475..ed0422098a 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/validation.js +++ b/packages/svelte/src/compiler/phases/2-analyze/validation.js @@ -253,7 +253,7 @@ function validate_slot_attribute(context, attribute) { if (owner) { if (!is_text_attribute(attribute)) { - e.invalid_slot_attribute(attribute); + e.slot_attribute_invalid(attribute); } if ( @@ -262,13 +262,13 @@ function validate_slot_attribute(context, attribute) { owner.type === 'SvelteSelf' ) { if (owner !== context.path.at(-2)) { - e.invalid_slot_placement(attribute); + e.slot_attribute_invalid_placement(attribute); } const name = attribute.value[0].data; if (context.state.component_slots.has(name)) { - e.duplicate_slot_name(attribute, name, owner.name); + e.slot_attribute_duplicate(attribute, name, owner.name); } context.state.component_slots.add(name); @@ -285,12 +285,12 @@ function validate_slot_attribute(context, attribute) { } } - e.invalid_default_slot_content(node); + e.slot_default_duplicate(node); } } } } else { - e.invalid_slot_placement(attribute); + e.slot_attribute_invalid_placement(attribute); } } @@ -593,7 +593,7 @@ const validation = { ); }); if (is_inside_textarea) { - e.invalid_tag_placement( + e.tag_invalid_placement( node, 'inside