diff --git a/.prettierignore b/.prettierignore index 48d37dc02fc8..77bdd29cf38c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,6 +2,8 @@ packages/**/dist/*.js packages/**/build/*.js packages/**/npm/**/* packages/**/config/*.js +packages/svelte/messages/**/*.md +packages/svelte/src/compiler/errors.js packages/svelte/tests/**/*.svelte packages/svelte/tests/**/_expected* packages/svelte/tests/**/_actual* diff --git a/eslint.config.js b/eslint.config.js index 75fcc7fa06e7..a86f724d34e3 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -33,13 +33,16 @@ export default [ ignores: [ '**/*.d.ts', '**/tests', + 'packages/svelte/scripts/process-messages/templates/*.js', + 'packages/svelte/src/compiler/errors.js', 'packages/svelte/compiler/index.js', // documentation can contain invalid examples 'documentation', // contains a fork of the REPL which doesn't adhere to eslint rules 'sites/svelte-5-preview/**', // wasn't checked previously, reenable at some point - 'sites/svelte.dev/**' + 'sites/svelte.dev/**', + 'tmp/**' ] } ]; diff --git a/packages/svelte/messages/compile-errors/attributes.md b/packages/svelte/messages/compile-errors/attributes.md new file mode 100644 index 000000000000..9501080ee084 --- /dev/null +++ b/packages/svelte/messages/compile-errors/attributes.md @@ -0,0 +1,59 @@ +## 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 diff --git a/packages/svelte/messages/compile-errors/bindings.md b/packages/svelte/messages/compile-errors/bindings.md new file mode 100644 index 000000000000..5e88c5890ac1 --- /dev/null +++ b/packages/svelte/messages/compile-errors/bindings.md @@ -0,0 +1,35 @@ +## 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_invalid_detailed + +`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 new file mode 100644 index 000000000000..761d74c72a39 --- /dev/null +++ b/packages/svelte/messages/compile-errors/compiler_options.md @@ -0,0 +1,7 @@ +## 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 new file mode 100644 index 000000000000..88a31a81c6ca --- /dev/null +++ b/packages/svelte/messages/compile-errors/components.md @@ -0,0 +1,3 @@ +## 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 new file mode 100644 index 000000000000..de8a8ca90965 --- /dev/null +++ b/packages/svelte/messages/compile-errors/const_tag.md @@ -0,0 +1,3 @@ +## 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/css.md b/packages/svelte/messages/compile-errors/css.md new file mode 100644 index 000000000000..33331cfac6ee --- /dev/null +++ b/packages/svelte/messages/compile-errors/css.md @@ -0,0 +1,51 @@ +## invalid_css_empty_declaration + +Declaration cannot be empty + +## invalid_css_global_block_list + +A :global {...} block cannot be part of a selector list with more than one item + +## invalid_css_global_block_modifier + +A :global {...} block cannot modify an existing selector + +## invalid_css_global_block_combinator + +A :global {...} block cannot follow a %name% combinator + +## invalid_css_global_block_declaration + +A :global {...} block can only contain rules, not declarations + +## invalid_css_global_placement + +:global(...) can be at the start or end of a selector sequence, but not in the middle + +## invalid_css_global_selector + +:global(...) must contain exactly one selector + +## invalid_css_global_selector_list + +:global(...) must not contain type or universal selectors when used in a compound selector + +## invalid_css_type_selector_placement + +:global(...) must not be followed with a type selector + +## invalid_css_selector + +Invalid selector + +## invalid_css_identifier + +Expected a valid CSS identifier + +## invalid_nesting_selector + +Nesting selectors can only be used inside a rule + +## invalid_css_declaration + +Declaration cannot be empty diff --git a/packages/svelte/messages/compile-errors/elements.md b/packages/svelte/messages/compile-errors/elements.md new file mode 100644 index 000000000000..466a26a7ac6a --- /dev/null +++ b/packages/svelte/messages/compile-errors/elements.md @@ -0,0 +1,27 @@ +## invalid_textarea_content + +A `