pull/11327/head
Rich Harris 2 years ago
parent a642609592
commit 1fe66eb304

@ -30,54 +30,54 @@
> `<svelte:options>` unknown attribute '%name%'
## illegal_svelte_head_attribute
## svelte_head_illegal_attribute
> `<svelte:head>` cannot have attributes nor directives
## invalid_svelte_fragment_attribute
## svelte_fragment_invalid_attribute
> `<svelte:fragment>` can only have a slot attribute and (optionally) a let: directive
## invalid_svelte_fragment_slot
## svelte_fragment_invalid_slot
> `<svelte:fragment>` slot attribute must have a static value
## invalid_svelte_fragment_placement
## svelte_fragment_invalid_placement
> `<svelte:fragment>` must be the direct child of a component
## invalid_svelte_element_placement
## svelte_meta_invalid_placement
> <%name%> tags cannot be inside elements or blocks
## duplicate_svelte_element
## svelte_meta_duplicate
> A component can only have one <%name%> element
## invalid_self_placement
## svelte_self_invalid_placement
> `<svelte:self>` components can only exist inside {#if} blocks, {#each} blocks, {#snippet} blocks or slots passed to components
## missing_svelte_element_definition
## svelte_element_missing_this
> `<svelte:element>` must have a 'this' attribute
## missing_svelte_component_definition
## svelte_component_missing_this
> `<svelte:component>` must have a 'this' attribute
## invalid_svelte_element_definition
## svelte_element_invalid_this
> Invalid element definition — must be an {expression}
## invalid_svelte_component_definition
## svelte_component_invalid_this
> Invalid component definition — must be an {expression}
## invalid_svelte_tag
## svelte_meta_invalid_tag
> Valid `<svelte:...>` tag names are %list%
## conflicting_slot_usage
## slot_snippet_conflict
> Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely.

@ -1154,8 +1154,8 @@ export function svelte_options_unknown_attribute(node, name) {
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function illegal_svelte_head_attribute(node) {
e(node, "illegal_svelte_head_attribute", "`<svelte:head>` cannot have attributes nor directives");
export function svelte_head_illegal_attribute(node) {
e(node, "svelte_head_illegal_attribute", "`<svelte:head>` cannot have attributes nor directives");
}
/**
@ -1163,8 +1163,8 @@ export function illegal_svelte_head_attribute(node) {
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_svelte_fragment_attribute(node) {
e(node, "invalid_svelte_fragment_attribute", "`<svelte:fragment>` can only have a slot attribute and (optionally) a let: directive");
export function svelte_fragment_invalid_attribute(node) {
e(node, "svelte_fragment_invalid_attribute", "`<svelte:fragment>` can only have a slot attribute and (optionally) a let: directive");
}
/**
@ -1172,8 +1172,8 @@ export function invalid_svelte_fragment_attribute(node) {
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_svelte_fragment_slot(node) {
e(node, "invalid_svelte_fragment_slot", "`<svelte:fragment>` slot attribute must have a static value");
export function svelte_fragment_invalid_slot(node) {
e(node, "svelte_fragment_invalid_slot", "`<svelte:fragment>` slot attribute must have a static value");
}
/**
@ -1181,8 +1181,8 @@ export function invalid_svelte_fragment_slot(node) {
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_svelte_fragment_placement(node) {
e(node, "invalid_svelte_fragment_placement", "`<svelte:fragment>` must be the direct child of a component");
export function svelte_fragment_invalid_placement(node) {
e(node, "svelte_fragment_invalid_placement", "`<svelte:fragment>` must be the direct child of a component");
}
/**
@ -1191,8 +1191,8 @@ export function invalid_svelte_fragment_placement(node) {
* @param {string} name
* @returns {never}
*/
export function invalid_svelte_element_placement(node, name) {
e(node, "invalid_svelte_element_placement", `<${name}> tags cannot be inside elements or blocks`);
export function svelte_meta_invalid_placement(node, name) {
e(node, "svelte_meta_invalid_placement", `<${name}> tags cannot be inside elements or blocks`);
}
/**
@ -1201,8 +1201,8 @@ export function invalid_svelte_element_placement(node, name) {
* @param {string} name
* @returns {never}
*/
export function duplicate_svelte_element(node, name) {
e(node, "duplicate_svelte_element", `A component can only have one <${name}> element`);
export function svelte_meta_duplicate(node, name) {
e(node, "svelte_meta_duplicate", `A component can only have one <${name}> element`);
}
/**
@ -1210,8 +1210,8 @@ export function duplicate_svelte_element(node, name) {
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_self_placement(node) {
e(node, "invalid_self_placement", "`<svelte:self>` components can only exist inside {#if} blocks, {#each} blocks, {#snippet} blocks or slots passed to components");
export function svelte_self_invalid_placement(node) {
e(node, "svelte_self_invalid_placement", "`<svelte:self>` components can only exist inside {#if} blocks, {#each} blocks, {#snippet} blocks or slots passed to components");
}
/**
@ -1219,8 +1219,8 @@ export function invalid_self_placement(node) {
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function missing_svelte_element_definition(node) {
e(node, "missing_svelte_element_definition", "`<svelte:element>` must have a 'this' attribute");
export function svelte_element_missing_this(node) {
e(node, "svelte_element_missing_this", "`<svelte:element>` must have a 'this' attribute");
}
/**
@ -1228,8 +1228,8 @@ export function missing_svelte_element_definition(node) {
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function missing_svelte_component_definition(node) {
e(node, "missing_svelte_component_definition", "`<svelte:component>` must have a 'this' attribute");
export function svelte_component_missing_this(node) {
e(node, "svelte_component_missing_this", "`<svelte:component>` must have a 'this' attribute");
}
/**
@ -1237,8 +1237,8 @@ export function missing_svelte_component_definition(node) {
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_svelte_element_definition(node) {
e(node, "invalid_svelte_element_definition", "Invalid element definition — must be an {expression}");
export function svelte_element_invalid_this(node) {
e(node, "svelte_element_invalid_this", "Invalid element definition — must be an {expression}");
}
/**
@ -1246,8 +1246,8 @@ export function invalid_svelte_element_definition(node) {
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function invalid_svelte_component_definition(node) {
e(node, "invalid_svelte_component_definition", "Invalid component definition — must be an {expression}");
export function svelte_component_invalid_this(node) {
e(node, "svelte_component_invalid_this", "Invalid component definition — must be an {expression}");
}
/**
@ -1256,8 +1256,8 @@ export function invalid_svelte_component_definition(node) {
* @param {string} list
* @returns {never}
*/
export function invalid_svelte_tag(node, list) {
e(node, "invalid_svelte_tag", `Valid \`<svelte:...>\` tag names are ${list}`);
export function svelte_meta_invalid_tag(node, list) {
e(node, "svelte_meta_invalid_tag", `Valid \`<svelte:...>\` tag names are ${list}`);
}
/**
@ -1265,8 +1265,8 @@ export function invalid_svelte_tag(node, list) {
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function conflicting_slot_usage(node) {
e(node, "conflicting_slot_usage", "Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely.");
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.");
}
/**

@ -108,11 +108,11 @@ export default function tag(parser) {
}
} else {
if (name in parser.meta_tags) {
e.duplicate_svelte_element(start, name);
e.svelte_meta_duplicate(start, name);
}
if (parent.type !== 'Root') {
e.invalid_svelte_element_placement(start, name);
e.svelte_meta_invalid_placement(start, name);
}
parser.meta_tags[name] = true;
@ -233,7 +233,7 @@ export default function tag(parser) {
(attr) => attr.type === 'Attribute' && attr.name === 'this'
);
if (index === -1) {
e.missing_svelte_component_definition(start);
e.svelte_component_missing_this(start);
}
const definition = /** @type {import('#compiler').Attribute} */ (
@ -244,7 +244,7 @@ export default function tag(parser) {
definition.value.length !== 1 ||
definition.value[0].type === 'Text'
) {
e.invalid_svelte_component_definition(definition.start);
e.svelte_component_invalid_this(definition.start);
}
element.expression = definition.value[0].expression;
@ -256,14 +256,14 @@ export default function tag(parser) {
(attr) => attr.type === 'Attribute' && attr.name === 'this'
);
if (index === -1) {
e.missing_svelte_element_definition(start);
e.svelte_element_missing_this(start);
}
const definition = /** @type {import('#compiler').Attribute} */ (
element.attributes.splice(index, 1)[0]
);
if (definition.value === true || definition.value.length !== 1) {
e.invalid_svelte_element_definition(definition.start);
e.svelte_element_invalid_this(definition.start);
}
const chunk = definition.value[0];
element.tag =
@ -387,7 +387,7 @@ function read_tag_name(parser) {
}
if (!legal) {
e.invalid_self_placement(start);
e.svelte_self_invalid_placement(start);
}
return 'svelte:self';
@ -404,7 +404,7 @@ function read_tag_name(parser) {
if (name.startsWith('svelte:')) {
const list = `${valid_meta_tags.slice(0, -1).join(', ')} or ${valid_meta_tags[valid_meta_tags.length - 1]}`;
e.invalid_svelte_tag(start, list);
e.svelte_meta_invalid_tag(start, list);
}
if (!valid_tag_name.test(name)) {

@ -507,7 +507,7 @@ export function analyze_component(root, source, options) {
}
if (analysis.uses_render_tags && (analysis.uses_slots || analysis.slot_names.size > 0)) {
e.conflicting_slot_usage(analysis.slot_names.values().next().value);
e.slot_snippet_conflict(analysis.slot_names.values().next().value);
}
// warn on any nonstate declarations that are a) reassigned and b) referenced in the template

@ -646,7 +646,7 @@ const validation = {
SvelteHead(node) {
const attribute = node.attributes[0];
if (attribute) {
e.illegal_svelte_head_attribute(attribute);
e.svelte_head_illegal_attribute(attribute);
}
},
SvelteElement(node, context) {
@ -659,7 +659,7 @@ const validation = {
SvelteFragment(node, context) {
const parent = context.path.at(-2);
if (parent?.type !== 'Component' && parent?.type !== 'SvelteComponent') {
e.invalid_svelte_fragment_placement(node);
e.svelte_fragment_invalid_placement(node);
}
for (const attribute of node.attributes) {
@ -668,7 +668,7 @@ const validation = {
validate_slot_attribute(context, attribute);
}
} else if (attribute.type !== 'LetDirective') {
e.invalid_svelte_fragment_attribute(attribute);
e.svelte_fragment_invalid_attribute(attribute);
}
}
},

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid_self_placement',
code: 'svelte_self_invalid_placement',
message:
'`<svelte:self>` components can only exist inside {#if} blocks, {#each} blocks, {#snippet} blocks or slots passed to components',
position: [1, 1]

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'conflicting_slot_usage',
code: 'slot_snippet_conflict',
message:
'Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely.',
position: [71, 84]

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid_svelte_tag',
code: 'svelte_meta_invalid_tag',
message:
'Valid `<svelte:...>` tag names are svelte:head, svelte:options, svelte:window, svelte:document, svelte:body, svelte:element, svelte:component, svelte:self or svelte:fragment',
position: [10, 10]

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'duplicate_svelte_element',
code: 'svelte_meta_duplicate',
message: 'A component can only have one <svelte:window> element',
position: [17, 17]
}

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid_svelte_element_placement',
code: 'svelte_meta_invalid_placement',
message: '<svelte:window> tags cannot be inside elements or blocks',
position: [11, 11]
}

@ -2,7 +2,7 @@ import { test } from '../../test';
export default test({
error: {
code: 'invalid_svelte_element_placement',
code: 'svelte_meta_invalid_placement',
message: '<svelte:window> tags cannot be inside elements or blocks',
position: [7, 7]
}

@ -1,6 +1,6 @@
[
{
"code": "invalid_svelte_element_definition",
"code": "svelte_element_invalid_this",
"message": "Invalid element definition — must be an {expression}",
"start": {
"line": 2,

@ -1,6 +1,6 @@
[
{
"code": "missing_svelte_element_definition",
"code": "svelte_element_missing_this",
"message": "`<svelte:element>` must have a 'this' attribute",
"start": {
"line": 2,

@ -1,6 +1,6 @@
[
{
"code": "invalid_svelte_fragment_placement",
"code": "svelte_fragment_invalid_placement",
"message": "`<svelte:fragment>` must be the direct child of a component",
"start": {
"line": 5,

@ -1,6 +1,6 @@
[
{
"code": "invalid_svelte_fragment_placement",
"code": "svelte_fragment_invalid_placement",
"message": "`<svelte:fragment>` must be the direct child of a component",
"start": {
"line": 7,

@ -1,6 +1,6 @@
[
{
"code": "illegal_svelte_head_attribute",
"code": "svelte_head_illegal_attribute",
"message": "`<svelte:head>` cannot have attributes nor directives",
"start": {
"line": 1,

Loading…
Cancel
Save