Skip to content

Commit 99860d5

Browse files
committed
some prose preceeding the list of compiler warnings
1 parent b893e63 commit 99860d5

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

documentation/docs/98-reference/30-compiler-warnings.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ title: 'Compiler warnings'
33
generated: 'generated by process-messages/index.js'
44
---
55

6+
Svelte warns you at compile time if it catches potential mistakes, such as writing inaccessible markup.
7+
8+
Some warnings may be incorrect in your concrete use case. You can disable such false positives by placing a `<!-- svelte-ignore <code> -->` comment above the line that causes the warning. Example:
9+
10+
```svelte
11+
<!-- svelte-ignore a11y_autofocus -->
12+
<input autofocus />
13+
```
14+
15+
You can list multiple rules in a single comment, and add an explanatory note alongside them:
16+
17+
```svelte
18+
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions (because of reasons) -->
19+
<div on:click>...</div>
20+
```
21+
622
## `a11y_accesskey`
723

824
> [!NOTE] Avoid using accesskey

packages/svelte/scripts/process-messages/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,28 @@ for (const [category, codes] of Object.entries(consolidated_messages)) {
9797
'---\n'
9898
];
9999

100+
// TODO If we we want preceeding stuff for each category find a better way to do it
101+
if (category === 'Compiler warnings') {
102+
lines.push(
103+
'Svelte warns you at compile time if it catches potential mistakes, such as writing inaccessible markup.',
104+
'',
105+
'Some warnings may be incorrect in your concrete use case. You can disable such false positives by placing a `<!-- svelte-ignore <code> -->` comment above the line that causes the warning. Example:',
106+
'',
107+
'```svelte',
108+
'<!-- svelte-ignore a11y_autofocus -->',
109+
'<input autofocus />',
110+
'```',
111+
'',
112+
'You can list multiple rules in a single comment, and add an explanatory note alongside them:',
113+
'',
114+
'```svelte',
115+
'<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions (because of reasons) -->',
116+
'<div on:click>...</div>',
117+
'```',
118+
''
119+
);
120+
}
121+
100122
const sorted_codes = Object.entries(codes).sort(([a], [b]) => (a < b ? -1 : 1));
101123

102124
for (const [code, { messages, details }] of sorted_codes) {

0 commit comments

Comments
 (0)