pull/11327/head
Rich Harris 2 years ago
parent f74aa4f0d6
commit ff3b95ebf6

@ -1,12 +1,12 @@
## unclosed_element ## element_unclosed
> `<%name%>` was left open > `<%name%>` was left open
## unclosed_block ## block_unclosed
> Block was left open > Block was left open
## unexpected_block_close ## block_unexpected_close
> Unexpected block closing tag > Unexpected block closing tag
@ -26,7 +26,7 @@
> '%word%' is a reserved word in JavaScript and cannot be used here > '%word%' is a reserved word in JavaScript and cannot be used here
## missing_whitespace ## expected_whitespace
> Expected whitespace > Expected whitespace
@ -34,23 +34,19 @@
> Expected identifier or destructure pattern > Expected identifier or destructure pattern
## invalid_script_context ## script_invalid_context
> If the context attribute is supplied, its value must be "module" > If the context attribute is supplied, its value must be "module"
## invalid_elseif ## block_invalid_elseif
> 'elseif' should be 'else if' > '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?) > {:...} block is invalid at this position (did you forget to close the preceeding element or block?)
## invalid_block_missing_parent ## block_duplicate_clause
> %child% block must be a child of %parent%
## duplicate_block_part
> %name% cannot appear more than once within a block > %name% cannot appear more than once within a block
@ -62,37 +58,33 @@
> Expected an identifier > Expected an identifier
## invalid_debug ## debug_tag_invalid_arguments
> {@debug ...} arguments must be identifiers, not arbitrary expressions > {@debug ...} arguments must be identifiers, not arbitrary expressions
## invalid_const ## const_tag_invalid_expression
> {@const ...} must be an assignment > {@const ...} must be an assignment
## invalid_block_placement ## block_invalid_placement
> {#%name% ...} block cannot be %location% > {#%name% ...} block cannot be %location%
## invalid_tag_placement ## tag_invalid_placement
> {@%name% ...} tag cannot be %location% > {@%name% ...} tag cannot be %location%
## missing_attribute_value ## expected_attribute_value
> Expected attribute value > Expected attribute value
## unclosed_attribute_value ## directive_invalid_value
> Expected closing %delimiter% character
## invalid_directive_value
> Directive value must be a JavaScript expression enclosed in curly braces > 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 ## invalid_closing_tag

@ -1,31 +0,0 @@
## invalid_slot_element_attribute
> `<slot>` 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

@ -96,10 +96,42 @@
> %thing% is invalid inside <%parent%> > %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
> `<slot>` 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 ## slot_snippet_conflict
> Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely. > Cannot use `<slot>` 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_invalid_modifier
> `style:` directive can only use the `important` modifier > `style:` directive can only use the `important` modifier

@ -210,8 +210,8 @@ export function cyclical_reactive_declaration(node, cycle) {
* @param {string} name * @param {string} name
* @returns {never} * @returns {never}
*/ */
export function unclosed_element(node, name) { export function element_unclosed(node, name) {
e(node, "unclosed_element", `\`<${name}>\` was left open`); e(node, "element_unclosed", `\`<${name}>\` was left open`);
} }
/** /**
@ -219,8 +219,8 @@ export function unclosed_element(node, name) {
* @param {null | number | NodeLike} node * @param {null | number | NodeLike} node
* @returns {never} * @returns {never}
*/ */
export function unclosed_block(node) { export function block_unclosed(node) {
e(node, "unclosed_block", "Block was left open"); e(node, "block_unclosed", "Block was left open");
} }
/** /**
@ -228,8 +228,8 @@ export function unclosed_block(node) {
* @param {null | number | NodeLike} node * @param {null | number | NodeLike} node
* @returns {never} * @returns {never}
*/ */
export function unexpected_block_close(node) { export function block_unexpected_close(node) {
e(node, "unexpected_block_close", "Unexpected block closing tag"); 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 * @param {null | number | NodeLike} node
* @returns {never} * @returns {never}
*/ */
export function missing_whitespace(node) { export function expected_whitespace(node) {
e(node, "missing_whitespace", "Expected whitespace"); e(node, "expected_whitespace", "Expected whitespace");
} }
/** /**
@ -294,8 +294,8 @@ export function expected_pattern(node) {
* @param {null | number | NodeLike} node * @param {null | number | NodeLike} node
* @returns {never} * @returns {never}
*/ */
export function invalid_script_context(node) { export function script_invalid_context(node) {
e(node, "invalid_script_context", "If the context attribute is supplied, its value must be \"module\""); 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 * @param {null | number | NodeLike} node
* @returns {never} * @returns {never}
*/ */
export function invalid_elseif(node) { export function block_invalid_elseif(node) {
e(node, "invalid_elseif", "'elseif' should be 'else if'"); e(node, "block_invalid_elseif", "'elseif' should be 'else if'");
} }
/** /**
@ -312,19 +312,8 @@ export function invalid_elseif(node) {
* @param {null | number | NodeLike} node * @param {null | number | NodeLike} node
* @returns {never} * @returns {never}
*/ */
export function invalid_continuing_block_placement(node) { export function block_invalid_continuation_placement(node) {
e(node, "invalid_continuing_block_placement", "{:...} block is invalid at this position (did you forget to close the preceeding element or block?)"); e(node, "block_invalid_continuation_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}`);
} }
/** /**
@ -333,8 +322,8 @@ export function invalid_block_missing_parent(node, child, parent) {
* @param {string} name * @param {string} name
* @returns {never} * @returns {never}
*/ */
export function duplicate_block_part(node, name) { export function block_duplicate_clause(node, name) {
e(node, "duplicate_block_part", `${name} cannot appear more than once within a block`); 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 * @param {null | number | NodeLike} node
* @returns {never} * @returns {never}
*/ */
export function invalid_debug(node) { export function debug_tag_invalid_arguments(node) {
e(node, "invalid_debug", "{@debug ...} arguments must be identifiers, not arbitrary expressions"); 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 * @param {null | number | NodeLike} node
* @returns {never} * @returns {never}
*/ */
export function invalid_const(node) { export function const_tag_invalid_expression(node) {
e(node, "invalid_const", "{@const ...} must be an assignment"); e(node, "const_tag_invalid_expression", "{@const ...} must be an assignment");
} }
/** /**
@ -380,8 +369,8 @@ export function invalid_const(node) {
* @param {string} location * @param {string} location
* @returns {never} * @returns {never}
*/ */
export function invalid_block_placement(node, name, location) { export function block_invalid_placement(node, name, location) {
e(node, "invalid_block_placement", `{#${name} ...} block cannot be ${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 * @param {string} location
* @returns {never} * @returns {never}
*/ */
export function invalid_tag_placement(node, name, location) { export function tag_invalid_placement(node, name, location) {
e(node, "invalid_tag_placement", `{@${name} ...} tag cannot be ${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 * @param {null | number | NodeLike} node
* @returns {never} * @returns {never}
*/ */
export function missing_attribute_value(node) { export function expected_attribute_value(node) {
e(node, "missing_attribute_value", "Expected attribute value"); e(node, "expected_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`);
} }
/** /**
@ -419,18 +398,18 @@ export function unclosed_attribute_value(node, delimiter) {
* @param {null | number | NodeLike} node * @param {null | number | NodeLike} node
* @returns {never} * @returns {never}
*/ */
export function invalid_directive_value(node) { export function directive_invalid_value(node) {
e(node, "invalid_directive_value", "Directive value must be a JavaScript expression enclosed in curly braces"); 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 {null | number | NodeLike} node
* @param {string} type * @param {string} type
* @returns {never} * @returns {never}
*/ */
export function empty_directive_name(node, type) { export function directive_missing_name(node, type) {
e(node, "empty_directive_name", `${type} name cannot be empty`); 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"); e(node, "conflicting_property_name", "Cannot have a property and a component export with the same name");
} }
/**
* `<slot>` 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", "`<slot>` 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 * An element that uses the `animate:` directive must be the only child of a keyed `{#each ...}` block
* @param {null | number | NodeLike} node * @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}>`); 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");
}
/**
* `<slot>` 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", "`<slot>` 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 `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely. * Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely.
* @param {null | number | NodeLike} node * @param {null | number | NodeLike} node
@ -1086,6 +1056,15 @@ export function slot_snippet_conflict(node) {
e(node, "slot_snippet_conflict", "Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely."); e(node, "slot_snippet_conflict", "Cannot use `<slot>` 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 * `style:` directive can only use the `important` modifier
* @param {null | number | NodeLike} node * @param {null | number | NodeLike} node

@ -92,10 +92,10 @@ export class Parser {
if (current.type === 'RegularElement') { if (current.type === 'RegularElement') {
current.end = current.start + 1; current.end = current.start + 1;
e.unclosed_element(current, current.name); e.element_unclosed(current, current.name);
} else { } else {
current.end = current.start + 1; current.end = current.start + 1;
e.unclosed_block(current); e.block_unclosed(current);
} }
} }
@ -263,7 +263,7 @@ export class Parser {
require_whitespace() { require_whitespace() {
if (!regex_whitespace.test(this.template[this.index])) { if (!regex_whitespace.test(this.template[this.index])) {
e.missing_whitespace(this.index); e.expected_whitespace(this.index);
} }
this.allow_whitespace(); this.allow_whitespace();

@ -16,13 +16,13 @@ function get_context(attributes) {
if (!context) return 'default'; if (!context) return 'default';
if (context.value.length !== 1 || context.value[0].type !== 'Text') { 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; const value = context.value[0].data;
if (value !== 'module') { if (value !== 'module') {
e.invalid_script_context(context.start); e.script_invalid_context(context.start);
} }
return value; return value;
@ -38,7 +38,7 @@ export function read_script(parser, start, attributes) {
const script_start = parser.index; const script_start = parser.index;
const data = parser.read_until(regex_closing_script_tag); const data = parser.read_until(regex_closing_script_tag);
if (parser.index >= parser.template.length) { if (parser.index >= parser.template.length) {
e.unclosed_element(parser.template.length, 'script'); e.element_unclosed(parser.template.length, 'script');
} }
const source = const source =

@ -436,7 +436,7 @@ function read_static_attribute(parser) {
parser.allow_whitespace(); parser.allow_whitespace();
let raw = parser.match_regex(regex_attribute_value); let raw = parser.match_regex(regex_attribute_value);
if (!raw) { if (!raw) {
e.missing_attribute_value(parser.index); e.expected_attribute_value(parser.index);
} }
parser.index += raw.length; parser.index += raw.length;
@ -552,7 +552,7 @@ function read_attribute(parser) {
const [directive_name, ...modifiers] = name.slice(colon_index + 1).split('|'); const [directive_name, ...modifiers] = name.slice(colon_index + 1).split('|');
if (directive_name === '') { 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') { if (type === 'StyleDirective') {
@ -577,7 +577,7 @@ function read_attribute(parser) {
const attribute_contains_text = const attribute_contains_text =
/** @type {any[]} */ (value).length > 1 || first_value.type === 'Text'; /** @type {any[]} */ (value).length > 1 || first_value.type === 'Text';
if (attribute_contains_text) { if (attribute_contains_text) {
e.invalid_directive_value(/** @type {number} */ (first_value.start)); e.directive_invalid_value(/** @type {number} */ (first_value.start));
} else { } else {
expression = first_value.expression; expression = first_value.expression;
} }
@ -678,14 +678,14 @@ function read_attribute_value(parser) {
const pos = error.position?.[0]; const pos = error.position?.[0];
if (pos !== undefined && parser.template.slice(pos - 1, pos + 1) === '/>') { if (pos !== undefined && parser.template.slice(pos - 1, pos + 1) === '/>') {
parser.index = pos; parser.index = pos;
e.unclosed_attribute_value(pos, quote_mark || '}'); e.expected_token(pos, quote_mark || '}');
} }
} }
throw error; throw error;
} }
if (value.length === 0 && !quote_mark) { if (value.length === 0 && !quote_mark) {
e.missing_attribute_value(parser.index); e.expected_attribute_value(parser.index);
} }
if (quote_mark) parser.index += 1; if (quote_mark) parser.index += 1;
@ -732,12 +732,12 @@ function read_sequence(parser, done, location) {
const index = parser.index - 1; const index = parser.index - 1;
parser.eat('#'); parser.eat('#');
const name = parser.read_until(/[^a-z]/); 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('@')) { } else if (parser.match('@')) {
const index = parser.index - 1; const index = parser.index - 1;
parser.eat('@'); parser.eat('@');
const name = parser.read_until(/[^a-z]/); 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); flush(parser.index - 1);

@ -331,7 +331,7 @@ function next(parser) {
if (block.type === 'IfBlock') { if (block.type === 'IfBlock') {
if (!parser.eat('else')) e.expected_token(start, '{:else} or {:else if}'); 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(); parser.allow_whitespace();
@ -389,7 +389,7 @@ function next(parser) {
if (block.type === 'AwaitBlock') { if (block.type === 'AwaitBlock') {
if (parser.eat('then')) { if (parser.eat('then')) {
if (block.then) { if (block.then) {
e.duplicate_block_part(start, '{:then}'); e.block_duplicate_clause(start, '{:then}');
} }
if (!parser.eat('}')) { if (!parser.eat('}')) {
@ -408,7 +408,7 @@ function next(parser) {
if (parser.eat('catch')) { if (parser.eat('catch')) {
if (block.catch) { if (block.catch) {
e.duplicate_block_part(start, '{:catch}'); e.block_duplicate_clause(start, '{:catch}');
} }
if (!parser.eat('}')) { if (!parser.eat('}')) {
@ -428,7 +428,7 @@ function next(parser) {
e.expected_token(start, '{:then ...} or {:catch ...}'); 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 */ /** @param {import('../index.js').Parser} parser */
@ -466,11 +466,11 @@ function close(parser) {
case 'RegularElement': case 'RegularElement':
// TODO handle implicitly closed elements // TODO handle implicitly closed elements
e.unexpected_block_close(start); e.block_unexpected_close(start);
break; break;
default: default:
e.unexpected_block_close(start); e.block_unexpected_close(start);
} }
parser.allow_whitespace(); parser.allow_whitespace();
@ -522,7 +522,7 @@ function special(parser) {
identifiers.forEach( identifiers.forEach(
/** @param {any} node */ (node) => { /** @param {any} node */ (node) => {
if (node.type !== 'Identifier') { if (node.type !== 'Identifier') {
e.invalid_debug(/** @type {number} */ (node.start)); e.debug_tag_invalid_arguments(/** @type {number} */ (node.start));
} }
} }
); );

@ -253,7 +253,7 @@ function validate_slot_attribute(context, attribute) {
if (owner) { if (owner) {
if (!is_text_attribute(attribute)) { if (!is_text_attribute(attribute)) {
e.invalid_slot_attribute(attribute); e.slot_attribute_invalid(attribute);
} }
if ( if (
@ -262,13 +262,13 @@ function validate_slot_attribute(context, attribute) {
owner.type === 'SvelteSelf' owner.type === 'SvelteSelf'
) { ) {
if (owner !== context.path.at(-2)) { if (owner !== context.path.at(-2)) {
e.invalid_slot_placement(attribute); e.slot_attribute_invalid_placement(attribute);
} }
const name = attribute.value[0].data; const name = attribute.value[0].data;
if (context.state.component_slots.has(name)) { 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); 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 { } else {
e.invalid_slot_placement(attribute); e.slot_attribute_invalid_placement(attribute);
} }
} }
@ -593,7 +593,7 @@ const validation = {
); );
}); });
if (is_inside_textarea) { if (is_inside_textarea) {
e.invalid_tag_placement( e.tag_invalid_placement(
node, node,
'inside <textarea> or <svelte:element this="textarea">', 'inside <textarea> or <svelte:element this="textarea">',
'render' 'render'
@ -634,7 +634,7 @@ const validation = {
(node) => node.type !== 'SnippetBlock' && (node.type !== 'Text' || node.data.trim()) (node) => node.type !== 'SnippetBlock' && (node.type !== 'Text' || node.data.trim())
) )
) { ) {
e.conflicting_children_snippet(node); e.snippet_conflict(node);
} }
} }
}, },
@ -677,15 +677,15 @@ const validation = {
if (attribute.type === 'Attribute') { if (attribute.type === 'Attribute') {
if (attribute.name === 'name') { if (attribute.name === 'name') {
if (!is_text_attribute(attribute)) { if (!is_text_attribute(attribute)) {
e.invalid_slot_name(attribute); e.slot_element_invalid_name(attribute);
} }
const slot_name = attribute.value[0].data; const slot_name = attribute.value[0].data;
if (slot_name === 'default') { if (slot_name === 'default') {
e.invalid_slot_name_default(attribute); e.slot_element_invalid_name_default(attribute);
} }
} }
} else if (attribute.type !== 'SpreadAttribute' && attribute.type !== 'LetDirective') { } else if (attribute.type !== 'SpreadAttribute' && attribute.type !== 'LetDirective') {
e.invalid_slot_element_attribute(attribute); e.slot_element_invalid_attribute(attribute);
} }
} }
}, },

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'missing_attribute_value', code: 'expected_attribute_value',
message: 'Expected attribute value', message: 'Expected attribute value',
position: [12, 12] position: [12, 12]
} }

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'invalid_continuing_block_placement', code: 'block_invalid_continuation_placement',
message: message:
'{:...} block is invalid at this position (did you forget to close the preceeding element or block?)', '{:...} block is invalid at this position (did you forget to close the preceeding element or block?)',
position: [1, 1] position: [1, 1]

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'duplicate_slot_name', code: 'slot_attribute_duplicate',
message: "Duplicate slot name 'foo' in <Nested>" message: "Duplicate slot name 'foo' in <Nested>"
} }
}); });

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'duplicate_slot_name', code: 'slot_attribute_duplicate',
message: "Duplicate slot name 'foo' in <Nested>" message: "Duplicate slot name 'foo' in <Nested>"
} }
}); });

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'invalid_default_slot_content', code: 'slot_default_duplicate',
message: 'Found default slot content alongside an explicit slot="default"' message: 'Found default slot content alongside an explicit slot="default"'
} }
}); });

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'duplicate_slot_name', code: 'slot_attribute_duplicate',
message: "Duplicate slot name 'foo' in <Nested>" message: "Duplicate slot name 'foo' in <Nested>"
} }
}); });

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'duplicate_slot_name', code: 'slot_attribute_duplicate',
message: "Duplicate slot name 'foo' in <Nested>" message: "Duplicate slot name 'foo' in <Nested>"
} }
}); });

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'duplicate_slot_name', code: 'slot_attribute_duplicate',
message: "Duplicate slot name 'foo' in <Nested>" message: "Duplicate slot name 'foo' in <Nested>"
} }
}); });

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'invalid_slot_placement', code: 'slot_attribute_invalid_placement',
message: message:
"Element with a slot='...' attribute must be a child of a component or a descendant of a custom element" "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"
} }

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'invalid_slot_placement', code: 'slot_attribute_invalid_placement',
message: message:
"Element with a slot='...' attribute must be a child of a component or a descendant of a custom element" "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"
} }

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'invalid_slot_placement', code: 'slot_attribute_invalid_placement',
message: message:
"Element with a slot='...' attribute must be a child of a component or a descendant of a custom element" "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element"
} }

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'invalid_continuing_block_placement', code: 'block_invalid_continuation_placement',
message: message:
'{:...} block is invalid at this position (did you forget to close the preceeding element or block?)', '{:...} block is invalid at this position (did you forget to close the preceeding element or block?)',
position: [6, 6] position: [6, 6]

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'invalid_continuing_block_placement', code: 'block_invalid_continuation_placement',
message: message:
'{:...} block is invalid at this position (did you forget to close the preceeding element or block?)', '{:...} block is invalid at this position (did you forget to close the preceeding element or block?)',
position: [18, 18] position: [18, 18]

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'invalid_continuing_block_placement', code: 'block_invalid_continuation_placement',
message: message:
'{:...} block is invalid at this position (did you forget to close the preceeding element or block?)', '{:...} block is invalid at this position (did you forget to close the preceeding element or block?)',
position: [17, 17] position: [17, 17]

@ -2,8 +2,8 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'empty_directive_name', code: 'directive_missing_name',
message: 'ClassDirective name cannot be empty', message: '`class:` name cannot be empty',
position: [10, 10] position: [4, 10]
} }
}); });

@ -2,8 +2,8 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'empty_directive_name', code: 'directive_missing_name',
message: 'UseDirective name cannot be empty', message: '`use:` name cannot be empty',
position: [8, 8] position: [4, 8]
} }
}); });

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'missing_whitespace', code: 'expected_whitespace',
message: 'Expected whitespace', message: 'Expected whitespace',
position: [6, 6] position: [6, 6]
} }

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'unclosed_element', code: 'element_unclosed',
message: '`<script>` was left open', message: '`<script>` was left open',
position: [32, 32] position: [32, 32]
} }

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'conflicting_children_snippet', code: 'snippet_conflict',
message: message:
'Cannot use explicit children snippet at the same time as implicit children content. Remove either the non-whitespace content or the children snippet block', 'Cannot use explicit children snippet at the same time as implicit children content. Remove either the non-whitespace content or the children snippet block',
position: [320, 353] position: [320, 353]

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'invalid_continuing_block_placement', code: 'block_invalid_continuation_placement',
message: message:
'{:...} block is invalid at this position (did you forget to close the preceeding element or block?)', '{:...} block is invalid at this position (did you forget to close the preceeding element or block?)',
position: [21, 21] position: [21, 21]

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'invalid_continuing_block_placement', code: 'block_invalid_continuation_placement',
message: message:
'{:...} block is invalid at this position (did you forget to close the preceeding element or block?)', '{:...} block is invalid at this position (did you forget to close the preceeding element or block?)',
position: [1, 1] position: [1, 1]

@ -2,8 +2,8 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'unclosed_attribute_value', code: 'expected_token',
message: 'Expected closing } character', message: 'Expected token }',
position: [19, 19] position: [19, 19]
} }
}); });

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'unclosed_block', code: 'block_unclosed',
message: 'Block was left open', message: 'Block was left open',
position: [0, 1] position: [0, 1]
} }

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({ export default test({
error: { error: {
code: 'unclosed_element', code: 'element_unclosed',
message: '`<div>` was left open', message: '`<div>` was left open',
position: [0, 1] position: [0, 1]
} }

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_slot_name_default", "code": "slot_element_invalid_name_default",
"message": "`default` is a reserved word — it cannot be used as a slot name", "message": "`default` is a reserved word — it cannot be used as a slot name",
"start": { "start": {
"line": 1, "line": 1,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_slot_attribute", "code": "slot_attribute_invalid",
"message": "slot attribute must be a static value", "message": "slot attribute must be a static value",
"start": { "start": {
"line": 6, "line": 6,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_slot_name", "code": "slot_element_invalid_name",
"message": "slot attribute must be a static value", "message": "slot attribute must be a static value",
"start": { "start": {
"line": 1, "line": 1,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_slot_placement", "code": "slot_attribute_invalid_placement",
"message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element", "message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element",
"start": { "start": {
"line": 10, "line": 10,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_slot_placement", "code": "slot_attribute_invalid_placement",
"message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element", "message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element",
"start": { "start": {
"line": 7, "line": 7,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_slot_placement", "code": "slot_attribute_invalid_placement",
"message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element", "message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element",
"start": { "start": {
"line": 7, "line": 7,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_debug", "code": "debug_tag_invalid_arguments",
"message": "{@debug ...} arguments must be identifiers, not arbitrary expressions", "message": "{@debug ...} arguments must be identifiers, not arbitrary expressions",
"start": { "start": {
"line": 2, "line": 2,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_directive_value", "code": "directive_invalid_value",
"message": "Directive value must be a JavaScript expression enclosed in curly braces", "message": "Directive value must be a JavaScript expression enclosed in curly braces",
"start": { "start": {
"line": 1, "line": 1,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_tag_placement", "code": "tag_invalid_placement",
"message": "{@html ...} tag cannot be in attribute value", "message": "{@html ...} tag cannot be in attribute value",
"start": { "start": {
"line": 1, "line": 1,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_tag_placement", "code": "tag_invalid_placement",
"message": "{@html ...} tag cannot be inside <textarea>", "message": "{@html ...} tag cannot be inside <textarea>",
"start": { "start": {
"line": 2, "line": 2,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_block_placement", "code": "block_invalid_placement",
"message": "{#if ...} block cannot be in attribute value", "message": "{#if ...} block cannot be in attribute value",
"start": { "start": {
"line": 1, "line": 1,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_block_placement", "code": "block_invalid_placement",
"message": "{#each ...} block cannot be inside <textarea>", "message": "{#each ...} block cannot be inside <textarea>",
"start": { "start": {
"line": 2, "line": 2,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_script_context", "code": "script_invalid_context",
"message": "If the context attribute is supplied, its value must be \"module\"", "message": "If the context attribute is supplied, its value must be \"module\"",
"start": { "start": {
"line": 1, "line": 1,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_slot_placement", "code": "slot_attribute_invalid_placement",
"message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element", "message": "Element with a slot='...' attribute must be a child of a component or a descendant of a custom element",
"start": { "start": {
"line": 1, "line": 1,

Loading…
Cancel
Save