diff --git a/.prettierignore b/.prettierignore index 0e08fae5e9..0567f05cd8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,7 +7,9 @@ packages/svelte/src/compiler/errors.js packages/svelte/src/compiler/warnings.js packages/svelte/src/internal/client/errors.js packages/svelte/src/internal/client/warnings.js +packages/svelte/src/internal/shared/errors.js packages/svelte/src/internal/shared/warnings.js +packages/svelte/src/internal/server/errors.js packages/svelte/tests/**/*.svelte packages/svelte/tests/**/_expected* packages/svelte/tests/**/_actual* diff --git a/packages/svelte/messages/client-errors/effects.md b/packages/svelte/messages/client-errors/effects.md deleted file mode 100644 index 88847ea0d5..0000000000 --- a/packages/svelte/messages/client-errors/effects.md +++ /dev/null @@ -1,3 +0,0 @@ -## effect_update_depth_exceeded - -> Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops \ No newline at end of file diff --git a/packages/svelte/messages/client-errors/errors.md b/packages/svelte/messages/client-errors/errors.md new file mode 100644 index 0000000000..aeeb133226 --- /dev/null +++ b/packages/svelte/messages/client-errors/errors.md @@ -0,0 +1,67 @@ +## bind_invalid_checkbox_value + +> Using `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead + +## bind_invalid_export + +> Component %component% has an export named `%key%` that a consumer component is trying to access using `bind:%key%`, which is disallowed. Instead, use `bind:this` (e.g. `<%name% bind:this={component} />`) and then access the property on the bound component instance (e.g. `component.%key%`) + +## bind_not_bindable + +> A component is attempting to bind to a non-bindable property `%key%` belonging to %component% (i.e. `<%name% bind:%key%={...}>`). To mark a property as bindable: `let { %key% = $bindable() } = $props()` + +## each_key_duplicate + +> Keyed each block has duplicate key at indexes %a% and %b% + +> Keyed each block has duplicate key `%value%` at indexes %a% and %b% + +## effect_in_teardown + +> `%rune%` cannot be used inside an effect cleanup function + +## effect_orphan + +> `%rune%` can only be used inside an effect (e.g. during component initialisation) + +## effect_update_depth_exceeded + +> Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops + +## hydration_missing_marker_close + +> Missing hydration closing marker + +## hydration_missing_marker_open + +> Missing hydration opening marker + +## lifecycle_legacy_only + +> `%name%(...)` cannot be used in runes mode + +## props_invalid_value + +> Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value + +## props_rest_readonly + +> Rest element properties of `$props()` such as `%property%` are readonly + +## rune_outside_svelte + +> The `%rune%` rune is only available inside `.svelte` and `.svelte.js/ts` files + +## state_prototype_fixed + +> Cannot set prototype of `$state` object + +## state_unsafe_mutation + +> Unsafe mutations during Svelte's render or derived phase are not permitted in runes mode. This can lead to unexpected errors and possibly cause infinite loops. +> +> If the object is not meant to be reactive, declare it without `$state` + +## svelte_component_invalid_this_value + +> The `this={...}` property of a `` must be a Svelte component, if defined diff --git a/packages/svelte/messages/client-errors/lifecycle.md b/packages/svelte/messages/client-errors/lifecycle.md deleted file mode 100644 index 98b644d8ec..0000000000 --- a/packages/svelte/messages/client-errors/lifecycle.md +++ /dev/null @@ -1,7 +0,0 @@ -## lifecycle_outside_component - -> `%name%(...)` can only be used during component initialisation - -## lifecycle_legacy_only - -> `%name%(...)` cannot be used in runes mode \ No newline at end of file diff --git a/packages/svelte/messages/client-warnings/warnings.md b/packages/svelte/messages/client-warnings/warnings.md index 865d968144..1f77457f94 100644 --- a/packages/svelte/messages/client-warnings/warnings.md +++ b/packages/svelte/messages/client-warnings/warnings.md @@ -1,3 +1,11 @@ +## hydration_attribute_changed + +> The `%attribute%` attribute on `%html%` changed its value between server and client renders. The client value, `%value%`, will be ignored in favour of the server value + +## hydration_mismatch + +> Hydration failed because the initial UI does not match what was rendered on the server + ## lifecycle_double_unmount > Tried to unmount a component that was not mounted diff --git a/packages/svelte/messages/compile-errors/attributes.md b/packages/svelte/messages/compile-errors/attributes.md deleted file mode 100644 index 8e27e74076..0000000000 --- a/packages/svelte/messages/compile-errors/attributes.md +++ /dev/null @@ -1,59 +0,0 @@ -## empty_attribute_shorthand - -> Attribute shorthand cannot be empty - -## duplicate_attribute - -> Attributes need to be unique - -## invalid_event_attribute_value - -> Event attribute must be a JavaScript expression, not a string - -## invalid_attribute_name - -> '%name%' is not a valid attribute name - -## animation_invalid_placement - -> An element that uses the `animate:` directive must be the only child of a keyed `{#each ...}` block - -## animation_missing_key - -> An element that uses the `animate:` directive must be the only child of a keyed `{#each ...}` block. Did you forget to add a key to your each block? - -## animation_duplicate - -> An element can only have one 'animate' directive - -## invalid_event_modifier - -> Valid event modifiers are %list% - -## invalid_component_event_modifier - -> Event modifiers other than 'once' can only be used on DOM elements - -## invalid_event_modifier_combination - -> The '%modifier1%' and '%modifier2%' modifiers cannot be used together - -## transition_duplicate - -> Cannot use multiple `%type%:` directives on a single element - -## transition_conflict - -> Cannot use `%type%:` alongside existing `%existing%:` directive - -## invalid_let_directive_placement - -> `let:` directive at invalid position - -## invalid_style_directive_modifier - -> Invalid 'style:' modifier. Valid modifiers are: 'important' - -## invalid_sequence_expression - -> Sequence expressions are not allowed as attribute/directive values in runes mode, unless wrapped in parentheses \ No newline at end of file diff --git a/packages/svelte/messages/compile-errors/bindings.md b/packages/svelte/messages/compile-errors/bindings.md deleted file mode 100644 index 1a7ef806ac..0000000000 --- a/packages/svelte/messages/compile-errors/bindings.md +++ /dev/null @@ -1,33 +0,0 @@ -## invalid_binding_expression - -> Can only bind to an Identifier or MemberExpression - -## invalid_binding_value - -> Can only bind to state or props - -## bind_invalid_target - -> `bind:%name%` can only be used with %elements% - -## bind_invalid - -> `bind:%name%` is not a valid binding - -> `bind:%name%` is not a valid binding. %explanation% - -## invalid_type_attribute - -> 'type' attribute must be a static text value if input uses two-way binding - -## invalid_multiple_attribute - -> 'multiple' attribute must be static if select uses two-way binding - -## missing_contenteditable_attribute - -> 'contenteditable' attribute is required for textContent, innerHTML and innerText two-way bindings - -## dynamic_contenteditable_attribute - -> 'contenteditable' attribute cannot be dynamic if element uses two-way binding diff --git a/packages/svelte/messages/compile-errors/compiler_options.md b/packages/svelte/messages/compile-errors/compiler_options.md deleted file mode 100644 index b2702a1a7e..0000000000 --- a/packages/svelte/messages/compile-errors/compiler_options.md +++ /dev/null @@ -1,7 +0,0 @@ -## invalid_compiler_option - -> Invalid compiler option: %msg% - -## removed_compiler_option - -> Invalid compiler option: %msg% \ No newline at end of file diff --git a/packages/svelte/messages/compile-errors/components.md b/packages/svelte/messages/compile-errors/components.md deleted file mode 100644 index 651c80d733..0000000000 --- a/packages/svelte/messages/compile-errors/components.md +++ /dev/null @@ -1,3 +0,0 @@ -## invalid_component_directive - -> This type of directive is not valid on components \ No newline at end of file diff --git a/packages/svelte/messages/compile-errors/const_tag.md b/packages/svelte/messages/compile-errors/const_tag.md deleted file mode 100644 index 720aba9860..0000000000 --- a/packages/svelte/messages/compile-errors/const_tag.md +++ /dev/null @@ -1,3 +0,0 @@ -## invalid_const_placement - -> {@const} must be the immediate child of {#snippet}, {#if}, {:else if}, {:else}, {#each}, {:then}, {:catch}, or \ No newline at end of file diff --git a/packages/svelte/messages/compile-errors/elements.md b/packages/svelte/messages/compile-errors/elements.md deleted file mode 100644 index 2686f2370d..0000000000 --- a/packages/svelte/messages/compile-errors/elements.md +++ /dev/null @@ -1,27 +0,0 @@ -## invalid_textarea_content - -> A `