From 7b55bd4d89e0642da8e091021d0926493bbad973 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 23 Apr 2024 21:32:28 -0400 Subject: [PATCH] chore: markdown warnings (#11302) * rename warnings.js to warnings-tmp.js * start porting warnings * centralise stuff * finish porting warnings * tidy up * get messages into JSDoc annotations * prettier * lint --- .prettierignore | 1 + .../svelte/messages/compile-warnings/a11y.md | 171 ++++ .../messages/compile-warnings/attributes.md | 15 + .../svelte/messages/compile-warnings/block.md | 3 + .../messages/compile-warnings/components.md | 3 + .../svelte/messages/compile-warnings/css.md | 3 + .../messages/compile-warnings/legacy.md | 19 + .../svelte/messages/compile-warnings/misc.md | 3 + .../messages/compile-warnings/options.md | 3 + .../messages/compile-warnings/performance.md | 7 + .../svelte/messages/compile-warnings/runes.md | 19 + .../svelte/messages/compile-warnings/state.md | 7 + packages/svelte/package.json | 4 +- .../svelte/scripts/process-messages/index.js | 11 +- .../templates/compile-errors.js | 2 +- .../templates/compile-warnings.js | 52 + packages/svelte/src/compiler/errors.js | 257 ++--- packages/svelte/src/compiler/index.js | 8 +- .../src/compiler/phases/2-analyze/a11y.js | 216 +++-- .../compiler/phases/2-analyze/css/css-warn.js | 11 +- .../src/compiler/phases/2-analyze/index.js | 36 +- .../compiler/phases/2-analyze/validation.js | 59 +- .../src/compiler/phases/3-transform/index.js | 43 +- .../svelte/src/compiler/phases/types.d.ts | 10 +- packages/svelte/src/compiler/utils/string.js | 9 + packages/svelte/src/compiler/warnings.js | 910 ++++++++++++------ .../_config.js | 2 +- .../descendant-selector-unmatched/_config.js | 2 +- .../css/samples/dynamic-element/_config.js | 2 +- .../tests/css/samples/empty-class/_config.js | 2 +- .../_config.js | 6 +- .../_config.js | 2 +- .../_config.js | 2 +- .../_config.js | 2 +- .../_config.js | 2 +- .../general-siblings-combinator-if/_config.js | 6 +- .../_config.js | 2 +- .../_config.js | 2 +- .../_config.js | 12 +- .../_config.js | 2 +- .../_config.js | 2 +- .../general-siblings-combinator/_config.js | 8 +- .../tests/css/samples/global-block/_config.js | 2 +- .../global-with-unused-descendant/_config.js | 2 +- .../svelte/tests/css/samples/host/_config.js | 2 +- .../svelte/tests/css/samples/is/_config.js | 2 +- .../tests/css/samples/nested-css/_config.js | 14 +- .../_config.js | 2 +- .../samples/preserve-specificity/input.svelte | 4 +- .../siblings-combinator-await/_config.js | 8 +- .../siblings-combinator-each-2/_config.js | 2 +- .../_config.js | 20 +- .../siblings-combinator-each-else/_config.js | 4 +- .../_config.js | 16 +- .../siblings-combinator-global/_config.js | 4 +- .../_config.js | 2 +- .../_config.js | 2 +- .../samples/siblings-combinator-if/_config.js | 8 +- .../siblings-combinator-slot/_config.js | 6 +- .../siblings-combinator-star/_config.js | 2 +- .../samples/siblings-combinator/_config.js | 8 +- .../_config.js | 6 +- .../_config.js | 2 +- .../unused-selector-leading/_config.js | 4 +- .../unused-selector-string-concat/_config.js | 20 +- .../unused-selector-ternary-concat/_config.js | 2 +- .../unused-selector-ternary-nested/_config.js | 4 +- .../unused-selector-ternary/_config.js | 2 +- .../unused-selector-trailing/_config.js | 2 +- .../css/samples/unused-selector/_config.js | 2 +- .../extended-builtin/_config.js | 2 +- .../samples/a11y-alt-text/warnings.json | 16 +- .../a11y-anchor-has-content/warnings.json | 4 +- .../a11y-anchor-in-svg-is-valid/warnings.json | 12 +- .../a11y-anchor-is-valid/warnings.json | 24 +- .../a11y-aria-activedescendant/warnings.json | 4 +- .../samples/a11y-aria-props/warnings.json | 8 +- .../a11y-aria-proptypes-boolean/warnings.json | 8 +- .../a11y-aria-proptypes-integer/warnings.json | 12 +- .../a11y-aria-proptypes-number/warnings.json | 12 +- .../a11y-aria-proptypes-string/warnings.json | 4 +- .../a11y-aria-proptypes-token/warnings.json | 16 +- .../warnings.json | 20 +- .../warnings.json | 8 +- .../samples/a11y-aria-role/warnings.json | 8 +- .../warnings.json | 8 +- .../a11y-autocomplete-valid/warnings.json | 12 +- .../input.svelte | 42 +- .../warnings.json | 32 +- .../a11y-figcaption-wrong-place/warnings.json | 8 +- .../a11y-heading-has-content/warnings.json | 8 +- .../samples/a11y-html-has-lang/warnings.json | 4 +- .../a11y-iframe-has-title/warnings.json | 4 +- .../a11y-img-redundant-alt/warnings.json | 12 +- .../warnings.json | 92 +- .../warnings.json | 8 +- .../a11y-media-has-caption/warnings.json | 16 +- .../input.svelte | 12 +- .../warnings.json | 16 +- .../a11y-no-abstract-roles/warnings.json | 48 +- .../samples/a11y-no-access-key/warnings.json | 4 +- .../samples/a11y-no-autofocus/warnings.json | 4 +- .../warnings.json | 8 +- .../warnings.json | 236 ++--- .../warnings.json | 20 +- .../warnings.json | 196 ++-- .../warnings.json | 16 +- .../a11y-no-redundant-roles/input.svelte | 2 +- .../a11y-no-redundant-roles/warnings.json | 156 +-- .../input.svelte | 6 +- .../warnings.json | 8 +- .../a11y-not-on-components/warnings.json | 4 +- .../warnings.json | 16 +- .../warnings.json | 716 +++++++------- .../samples/a11y-scope/warnings.json | 4 +- .../a11y-tabindex-no-positive/warnings.json | 4 +- .../samples/component-dynamic/input.svelte | 6 +- .../samples/component-dynamic/warnings.json | 6 +- .../component-name-lowercase/warnings.json | 2 +- .../samples/empty-block/warnings.json | 48 +- .../samples/error-mode-warn/warnings.json | 4 +- .../warnings.json | 2 +- .../global-event-reference/warnings.json | 4 +- .../samples/ignore-warning/input.svelte | 4 +- .../samples/ignore-warning/warnings.json | 8 +- .../ignore-warnings-cumulative/input.svelte | 6 +- .../ignore-warnings-cumulative/warnings.json | 4 +- .../ignore-warnings-newline/input.svelte | 6 +- .../ignore-warnings-newline/warnings.json | 4 +- .../ignore-warnings-stacked/input.svelte | 6 +- .../ignore-warnings-stacked/warnings.json | 4 +- .../samples/ignore-warnings/input.svelte | 4 +- .../samples/ignore-warnings/warnings.json | 4 +- .../illegal-attribute-character/warnings.json | 4 +- .../samples/inline-new-class-2/warnings.json | 2 +- .../samples/inline-new-class-4/warnings.json | 2 +- .../samples/inline-new-class/warnings.json | 2 +- .../invalid-self-closing-tag/warnings.json | 4 +- .../warnings.json | 12 +- .../warnings.json | 12 +- .../reactive-module-variable/warnings.json | 2 +- .../rest-eachblock-binding-2/warnings.json | 12 +- .../rest-eachblock-binding-3/warnings.json | 12 +- .../warnings.json | 4 +- .../rest-eachblock-binding/warnings.json | 12 +- .../runes-bindable-not-called/warnings.json | 4 +- .../warnings.json | 6 +- .../runes-props-not-called/warnings.json | 4 +- .../warnings.json | 4 +- .../runes-referenced-nonstate/warnings.json | 8 +- .../warnings.json | 2 +- .../samples/silence-warnings-2/input.svelte | 2 +- .../samples/silence-warnings/input.svelte | 4 +- .../samples/slot-warning-ignore/input.svelte | 4 +- .../samples/slot-warning/input.svelte | 2 +- .../samples/slot-warning/warnings.json | 4 +- .../samples/slot-warning2/input.svelte | 4 +- .../samples/slot-warning2/warnings.json | 4 +- .../static-state-reference/warnings.json | 4 +- .../store-runes-conflict/warnings.json | 4 +- .../warnings.json | 2 +- .../unreferenced-variables-each/warnings.json | 4 +- .../unreferenced-variables/warnings.json | 10 +- .../samples/use-the-platform/warnings.json | 4 +- 164 files changed, 2475 insertions(+), 1779 deletions(-) create mode 100644 packages/svelte/messages/compile-warnings/a11y.md create mode 100644 packages/svelte/messages/compile-warnings/attributes.md create mode 100644 packages/svelte/messages/compile-warnings/block.md create mode 100644 packages/svelte/messages/compile-warnings/components.md create mode 100644 packages/svelte/messages/compile-warnings/css.md create mode 100644 packages/svelte/messages/compile-warnings/legacy.md create mode 100644 packages/svelte/messages/compile-warnings/misc.md create mode 100644 packages/svelte/messages/compile-warnings/options.md create mode 100644 packages/svelte/messages/compile-warnings/performance.md create mode 100644 packages/svelte/messages/compile-warnings/runes.md create mode 100644 packages/svelte/messages/compile-warnings/state.md create mode 100644 packages/svelte/scripts/process-messages/templates/compile-warnings.js create mode 100644 packages/svelte/src/compiler/utils/string.js diff --git a/.prettierignore b/.prettierignore index 77bdd29cf3..4eea07c2e7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,6 +4,7 @@ packages/**/npm/**/* packages/**/config/*.js packages/svelte/messages/**/*.md packages/svelte/src/compiler/errors.js +packages/svelte/src/compiler/warnings.js packages/svelte/tests/**/*.svelte packages/svelte/tests/**/_expected* packages/svelte/tests/**/_actual* diff --git a/packages/svelte/messages/compile-warnings/a11y.md b/packages/svelte/messages/compile-warnings/a11y.md new file mode 100644 index 0000000000..0e2aaa92b0 --- /dev/null +++ b/packages/svelte/messages/compile-warnings/a11y.md @@ -0,0 +1,171 @@ +## a11y_aria_attributes + +<%name%> should not have aria-* attributes + +## a11y_unknown_aria_attribute + +Unknown aria attribute 'aria-%attribute%' + +## a11y_unknown_aria_attribute_suggestion + +Unknown aria attribute 'aria-%attribute%'. Did you mean '%suggestion%'? + +## a11y_hidden + +<%name%> element should not be hidden + +## a11y_incorrect_aria_attribute_type_boolean + +The value of '%attribute%' must be either 'true' or 'false' + +## a11y_incorrect_aria_attribute_type_integer + +The value of '%attribute%' must be an integer + +## a11y_incorrect_aria_attribute_type_id + +The value of '%attribute%' must be a string that represents a DOM element ID + +## a11y_incorrect_aria_attribute_type_idlist + +The value of '%attribute%' must be a space-separated list of strings that represent DOM element IDs + +## a11y_incorrect_aria_attribute_type_tristate + +The value of '%attribute%' must be exactly one of true, false, or mixed + +## a11y_incorrect_aria_attribute_type_token + +The value of '%attribute%' must be exactly one of %values% + +## a11y_incorrect_aria_attribute_type_tokenlist + +The value of '%attribute%' must be a space-separated list of one or more of %values% + +## a11y_incorrect_aria_attribute_type + +The value of '%attribute%' must be of type %type% + +## a11y_aria_activedescendant_has_tabindex + +Elements with attribute aria-activedescendant should have tabindex value + +## a11y_misplaced_role + +<%name%> should not have role attribute + +## a11y_no_abstract_role + +Abstract role '%role%' is forbidden + +## a11y_unknown_role + +Unknown role '%role%' + +## a11y_unknown_role_suggestion + +Unknown role '%role%'. Did you mean '%suggestion%'? + +## a11y_no_redundant_roles + +Redundant role '%role%' + +## a11y_role_has_required_aria_props + +Elements with the ARIA role "%role%" must have the following attributes defined: %props% + +## a11y_interactive_supports_focus + +Elements with the '%role%' interactive role must have a tabindex value. + +## a11y_no_interactive_element_to_noninteractive_role + +<%element%> cannot have role '%role%' + +## a11y_no_noninteractive_element_to_interactive_role + +Non-interactive element <%element%> cannot have interactive role '%role%' + +## a11y_accesskey + +Avoid using accesskey + +## a11y_autofocus + +Avoid using autofocus + +## a11y_misplaced_scope + +The scope attribute should only be used with elements + +## a11y_positive_tabindex + +Avoid tabindex values above zero + +## 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