Skip to content

Commit 3bf68b4

Browse files
authored
fix: make messages more consistent (#11643)
1 parent 053159b commit 3bf68b4

File tree

17 files changed

+79
-74
lines changed

17 files changed

+79
-74
lines changed

.changeset/cyan-ducks-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: make messages more consistent

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
175175
## mixed_event_handler_syntaxes
176176

177-
> Mixing old (on:%name%) and new syntaxes for event handling is not allowed. Use only the on%name% syntax.
177+
> Mixing old (on:%name%) and new syntaxes for event handling is not allowed. Use only the on%name% syntax
178178
179179
## node_invalid_placement
180180

@@ -230,7 +230,7 @@
230230
231231
## slot_snippet_conflict
232232

233-
> Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely.
233+
> Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely
234234
235235
## snippet_conflict
236236

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
## a11y_click_events_have_key_events
2222

23-
> Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type="button">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.
23+
> Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type="button">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details
2424
2525
## a11y_distracting_elements
2626

@@ -40,7 +40,7 @@
4040
4141
## a11y_img_redundant_alt
4242

43-
> Screenreaders already announce `<img>` elements as an image.
43+
> Screenreaders already announce `<img>` elements as an image
4444
4545
## a11y_incorrect_aria_attribute_type
4646

@@ -76,15 +76,15 @@
7676
7777
## a11y_interactive_supports_focus
7878

79-
> Elements with the '%role%' interactive role must have a tabindex value.
79+
> Elements with the '%role%' interactive role must have a tabindex value
8080
8181
## a11y_invalid_attribute
8282

8383
> '%href_value%' is not a valid %href_attribute% attribute
8484
8585
## a11y_label_has_associated_control
8686

87-
> A form label must be associated with a control.
87+
> A form label must be associated with a control
8888
8989
## a11y_media_has_caption
9090

@@ -120,7 +120,7 @@
120120
121121
## a11y_no_noninteractive_element_interactions
122122

123-
> Non-interactive element `<%element%>` should not be assigned mouse or keyboard event listeners.
123+
> Non-interactive element `<%element%>` should not be assigned mouse or keyboard event listeners
124124
125125
## a11y_no_noninteractive_element_to_interactive_role
126126

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
3333
## event_directive_deprecated
3434

35-
> Using `on:%name%` to listen to the %name% event is deprecated. Use the event attribute `on%name%` instead.
35+
> Using `on:%name%` to listen to the %name% event is deprecated. Use the event attribute `on%name%` instead
3636
3737
## slot_element_deprecated
3838

39-
> Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead.
39+
> Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead

packages/svelte/src/compiler/errors.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,13 +928,13 @@ export function let_directive_invalid_placement(node) {
928928
}
929929

930930
/**
931-
* Mixing old (on:%name%) and new syntaxes for event handling is not allowed. Use only the on%name% syntax.
931+
* Mixing old (on:%name%) and new syntaxes for event handling is not allowed. Use only the on%name% syntax
932932
* @param {null | number | NodeLike} node
933933
* @param {string} name
934934
* @returns {never}
935935
*/
936936
export function mixed_event_handler_syntaxes(node, name) {
937-
e(node, "mixed_event_handler_syntaxes", `Mixing old (on:${name}) and new syntaxes for event handling is not allowed. Use only the on${name} syntax.`);
937+
e(node, "mixed_event_handler_syntaxes", `Mixing old (on:${name}) and new syntaxes for event handling is not allowed. Use only the on${name} syntax`);
938938
}
939939

940940
/**
@@ -1059,12 +1059,12 @@ export function slot_element_invalid_name_default(node) {
10591059
}
10601060

10611061
/**
1062-
* Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely.
1062+
* Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely
10631063
* @param {null | number | NodeLike} node
10641064
* @returns {never}
10651065
*/
10661066
export function slot_snippet_conflict(node) {
1067-
e(node, "slot_snippet_conflict", "Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely.");
1067+
e(node, "slot_snippet_conflict", "Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely");
10681068
}
10691069

10701070
/**

packages/svelte/src/compiler/warnings.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ export function a11y_autofocus(node) {
137137
}
138138

139139
/**
140-
* Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type="button">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.
140+
* Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type="button">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details
141141
* @param {null | NodeLike} node
142142
*/
143143
export function a11y_click_events_have_key_events(node) {
144-
w(node, "a11y_click_events_have_key_events", "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.");
144+
w(node, "a11y_click_events_have_key_events", "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details");
145145
}
146146

147147
/**
@@ -179,11 +179,11 @@ export function a11y_hidden(node, name) {
179179
}
180180

181181
/**
182-
* Screenreaders already announce `<img>` elements as an image.
182+
* Screenreaders already announce `<img>` elements as an image
183183
* @param {null | NodeLike} node
184184
*/
185185
export function a11y_img_redundant_alt(node) {
186-
w(node, "a11y_img_redundant_alt", "Screenreaders already announce `<img>` elements as an image.");
186+
w(node, "a11y_img_redundant_alt", "Screenreaders already announce `<img>` elements as an image");
187187
}
188188

189189
/**
@@ -262,12 +262,12 @@ export function a11y_incorrect_aria_attribute_type_tristate(node, attribute) {
262262
}
263263

264264
/**
265-
* Elements with the '%role%' interactive role must have a tabindex value.
265+
* Elements with the '%role%' interactive role must have a tabindex value
266266
* @param {null | NodeLike} node
267267
* @param {string} role
268268
*/
269269
export function a11y_interactive_supports_focus(node, role) {
270-
w(node, "a11y_interactive_supports_focus", `Elements with the '${role}' interactive role must have a tabindex value.`);
270+
w(node, "a11y_interactive_supports_focus", `Elements with the '${role}' interactive role must have a tabindex value`);
271271
}
272272

273273
/**
@@ -281,11 +281,11 @@ export function a11y_invalid_attribute(node, href_value, href_attribute) {
281281
}
282282

283283
/**
284-
* A form label must be associated with a control.
284+
* A form label must be associated with a control
285285
* @param {null | NodeLike} node
286286
*/
287287
export function a11y_label_has_associated_control(node) {
288-
w(node, "a11y_label_has_associated_control", "A form label must be associated with a control.");
288+
w(node, "a11y_label_has_associated_control", "A form label must be associated with a control");
289289
}
290290

291291
/**
@@ -363,12 +363,12 @@ export function a11y_no_interactive_element_to_noninteractive_role(node, element
363363
}
364364

365365
/**
366-
* Non-interactive element `<%element%>` should not be assigned mouse or keyboard event listeners.
366+
* Non-interactive element `<%element%>` should not be assigned mouse or keyboard event listeners
367367
* @param {null | NodeLike} node
368368
* @param {string} element
369369
*/
370370
export function a11y_no_noninteractive_element_interactions(node, element) {
371-
w(node, "a11y_no_noninteractive_element_interactions", `Non-interactive element \`<${element}>\` should not be assigned mouse or keyboard event listeners.`);
371+
w(node, "a11y_no_noninteractive_element_interactions", `Non-interactive element \`<${element}>\` should not be assigned mouse or keyboard event listeners`);
372372
}
373373

374374
/**
@@ -698,18 +698,18 @@ export function element_invalid_self_closing_tag(node, name) {
698698
}
699699

700700
/**
701-
* Using `on:%name%` to listen to the %name% event is deprecated. Use the event attribute `on%name%` instead.
701+
* Using `on:%name%` to listen to the %name% event is deprecated. Use the event attribute `on%name%` instead
702702
* @param {null | NodeLike} node
703703
* @param {string} name
704704
*/
705705
export function event_directive_deprecated(node, name) {
706-
w(node, "event_directive_deprecated", `Using \`on:${name}\` to listen to the ${name} event is deprecated. Use the event attribute \`on${name}\` instead.`);
706+
w(node, "event_directive_deprecated", `Using \`on:${name}\` to listen to the ${name} event is deprecated. Use the event attribute \`on${name}\` instead`);
707707
}
708708

709709
/**
710-
* Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead.
710+
* Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead
711711
* @param {null | NodeLike} node
712712
*/
713713
export function slot_element_deprecated(node) {
714-
w(node, "slot_element_deprecated", "Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead.");
714+
w(node, "slot_element_deprecated", "Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead");
715715
}

packages/svelte/tests/compiler-errors/samples/slot-conflicting-with-render-tag/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default test({
44
error: {
55
code: 'slot_snippet_conflict',
66
message:
7-
'Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely.',
7+
'Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely',
88
position: [71, 84]
99
}
1010
});

packages/svelte/tests/validator/samples/a11y-click-events-have-key-events/warnings.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"code": "a11y_click_events_have_key_events",
4-
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.",
4+
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details",
55
"start": {
66
"line": 13,
77
"column": 0
@@ -13,7 +13,7 @@
1313
},
1414
{
1515
"code": "a11y_click_events_have_key_events",
16-
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.",
16+
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details",
1717
"start": {
1818
"line": 15,
1919
"column": 0
@@ -25,7 +25,7 @@
2525
},
2626
{
2727
"code": "a11y_click_events_have_key_events",
28-
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.",
28+
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details",
2929
"start": {
3030
"line": 18,
3131
"column": 0
@@ -37,7 +37,7 @@
3737
},
3838
{
3939
"code": "a11y_click_events_have_key_events",
40-
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.",
40+
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details",
4141
"start": {
4242
"line": 20,
4343
"column": 0
@@ -49,7 +49,7 @@
4949
},
5050
{
5151
"code": "a11y_click_events_have_key_events",
52-
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.",
52+
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details",
5353
"start": {
5454
"line": 22,
5555
"column": 0
@@ -61,7 +61,7 @@
6161
},
6262
{
6363
"code": "a11y_click_events_have_key_events",
64-
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.",
64+
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details",
6565
"start": {
6666
"line": 24,
6767
"column": 0
@@ -73,7 +73,7 @@
7373
},
7474
{
7575
"code": "a11y_click_events_have_key_events",
76-
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.",
76+
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details",
7777
"start": {
7878
"line": 26,
7979
"column": 0
@@ -85,7 +85,7 @@
8585
},
8686
{
8787
"code": "a11y_click_events_have_key_events",
88-
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details.",
88+
"message": "Visible, non-interactive elements with a click event must be accompanied by a keyboard event handler. Consider whether an interactive element such as `<button type=\"button\">` or `<a>` might be more appropriate. See https://svelte.dev/docs/accessibility-warnings#a11y-click-events-have-key-events for more details",
8989
"start": {
9090
"line": 28,
9191
"column": 0

packages/svelte/tests/validator/samples/a11y-img-redundant-alt/warnings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"code": "a11y_img_redundant_alt",
4-
"message": "Screenreaders already announce `<img>` elements as an image.",
4+
"message": "Screenreaders already announce `<img>` elements as an image",
55
"end": {
66
"column": 49,
77
"line": 3
@@ -13,7 +13,7 @@
1313
},
1414
{
1515
"code": "a11y_img_redundant_alt",
16-
"message": "Screenreaders already announce `<img>` elements as an image.",
16+
"message": "Screenreaders already announce `<img>` elements as an image",
1717
"end": {
1818
"column": 45,
1919
"line": 4
@@ -25,7 +25,7 @@
2525
},
2626
{
2727
"code": "a11y_img_redundant_alt",
28-
"message": "Screenreaders already announce `<img>` elements as an image.",
28+
"message": "Screenreaders already announce `<img>` elements as an image",
2929
"end": {
3030
"column": 52,
3131
"line": 5

0 commit comments

Comments
 (0)