diff --git a/documentation/docs/98-reference/30-compiler-warnings.md b/documentation/docs/98-reference/30-compiler-warnings.md index 3d4d0e4a0b..9da02e0d78 100644 --- a/documentation/docs/98-reference/30-compiler-warnings.md +++ b/documentation/docs/98-reference/30-compiler-warnings.md @@ -3,6 +3,22 @@ title: 'Compiler warnings' generated: 'generated by process-messages/index.js' --- +Svelte warns you at compile time if it catches potential mistakes, such as writing inaccessible markup. + +Some warnings may be incorrect in your concrete use case. You can disable such false positives by placing a `` comment above the line that causes the warning. Example: + +```svelte + + +``` + +You can list multiple rules in a single comment, and add an explanatory note alongside them: + +```svelte + +
...
+``` + ## `a11y_accesskey` > [!NOTE] Avoid using accesskey diff --git a/packages/svelte/scripts/process-messages/index.js b/packages/svelte/scripts/process-messages/index.js index fc58a7d3d4..d005f73dd2 100644 --- a/packages/svelte/scripts/process-messages/index.js +++ b/packages/svelte/scripts/process-messages/index.js @@ -97,6 +97,28 @@ for (const [category, codes] of Object.entries(consolidated_messages)) { '---\n' ]; + // TODO If we we want preceeding stuff for each category find a better way to do it + if (category === 'Compiler warnings') { + lines.push( + 'Svelte warns you at compile time if it catches potential mistakes, such as writing inaccessible markup.', + '', + 'Some warnings may be incorrect in your concrete use case. You can disable such false positives by placing a `` comment above the line that causes the warning. Example:', + '', + '```svelte', + '', + '', + '```', + '', + 'You can list multiple rules in a single comment, and add an explanatory note alongside them:', + '', + '```svelte', + '', + '
...
', + '```', + '' + ); + } + const sorted_codes = Object.entries(codes).sort(([a], [b]) => (a < b ? -1 : 1)); for (const [code, { messages, details }] of sorted_codes) {