Skip to content

Commit ac01a26

Browse files
committed
chore: swap warning with error
1 parent 7b5f510 commit ac01a26

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

.changeset/warm-cherries-shake.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"svelte": patch
33
---
44

5-
feat: warn when snippet shadow a prop
5+
feat: error when snippet shadow a prop

packages/svelte/messages/compile-errors/template.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@
240240

241241
> snippets do not support rest parameters; use an array instead
242242
243+
## snippet_shadowing_prop
244+
245+
> This snippet is shadowing the prop `%prop%` with the same name
246+
243247
## style_directive_invalid_modifier
244248

245249
> `style:` directive can only use the `important` modifier

packages/svelte/messages/compile-warnings/template.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,3 @@
3737
## slot_element_deprecated
3838

3939
> Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead.
40-
41-
## snippet_shadowing_prop
42-
43-
> This snippet is shadowing the prop `%prop%` with the same name

packages/svelte/src/compiler/errors.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,4 +1374,14 @@ export function unexpected_reserved_word(node, word) {
13741374
*/
13751375
export function void_element_invalid_content(node) {
13761376
e(node, "void_element_invalid_content", "Void elements cannot have children or closing tags");
1377+
}
1378+
1379+
/**
1380+
* This snippet is shadowing the prop `%prop%` with the same name
1381+
* @param {null | number | NodeLike} node
1382+
* @param {string} prop
1383+
* @returns {never}
1384+
*/
1385+
export function snippet_shadowing_prop(node, prop) {
1386+
e(node, "snippet_shadowing_prop", `This snippet is shadowing the prop \`${prop}\` with the same name`);
13771387
}

packages/svelte/src/compiler/phases/2-analyze/validation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ const validation = {
636636
attribute.name === node.expression.name
637637
)
638638
) {
639-
w.snippet_shadowing_prop(node, node.expression.name);
639+
e.snippet_shadowing_prop(node, node.expression.name);
640640
}
641641

642642
if (node.expression.name !== 'children') return;

packages/svelte/src/compiler/warnings.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ export const codes = [
9090
"component_name_lowercase",
9191
"element_invalid_self_closing_tag",
9292
"event_directive_deprecated",
93-
"slot_element_deprecated",
94-
"snippet_shadowing_prop"
93+
"slot_element_deprecated"
9594
];
9695

9796
/**
@@ -713,13 +712,4 @@ export function event_directive_deprecated(node, name) {
713712
*/
714713
export function slot_element_deprecated(node) {
715714
w(node, "slot_element_deprecated", "Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead.");
716-
}
717-
718-
/**
719-
* This snippet is shadowing the prop `%prop%` with the same name
720-
* @param {null | NodeLike} node
721-
* @param {string} prop
722-
*/
723-
export function snippet_shadowing_prop(node, prop) {
724-
w(node, "snippet_shadowing_prop", `This snippet is shadowing the prop \`${prop}\` with the same name`);
725715
}

0 commit comments

Comments
 (0)