diff --git a/packages/svelte/messages/compile-errors/special_elements.md b/packages/svelte/messages/compile-errors/special_elements.md index 67d179448f..7693dc17cc 100644 --- a/packages/svelte/messages/compile-errors/special_elements.md +++ b/packages/svelte/messages/compile-errors/special_elements.md @@ -6,27 +6,27 @@ > Valid values are %list% -## tag_option_deprecated +## svelte_options_deprecated_tag > "tag" option is deprecated — use "customElement" instead -## invalid_tag_property +## svelte_options_invalid_tagname > Tag name must be two or more words joined by the "-" character -## invalid_svelte_option_customElement +## svelte_options_invalid_customelement > "customElement" must be a string literal defining a valid custom element name or an object of the form { tag: string; shadow?: "open" | "none"; props?: { [key: string]: { attribute?: string; reflect?: boolean; type: .. } } } -## invalid_customElement_props_attribute +## svelte_options_invalid_customelement_props > "props" must be a statically analyzable object literal of the form "{ [key: string]: { attribute?: string; reflect?: boolean; type?: "String" | "Boolean" | "Number" | "Array" | "Object" }" -## invalid_customElement_shadow_attribute +## svelte_options_invalid_customelement_shadow > "shadow" must be either "open" or "none" -## unknown_svelte_option_attribute +## svelte_options_unknown_attribute > `` unknown attribute '%name%' diff --git a/packages/svelte/src/compiler/errors.js b/packages/svelte/src/compiler/errors.js index 7b25e0870e..2675afe306 100644 --- a/packages/svelte/src/compiler/errors.js +++ b/packages/svelte/src/compiler/errors.js @@ -1099,44 +1099,8 @@ export function svelte_options_invalid_attribute_value(node, list) { * @param {null | number | NodeLike} node * @returns {never} */ -export function tag_option_deprecated(node) { - e(node, "tag_option_deprecated", "\"tag\" option is deprecated — use \"customElement\" instead"); -} - -/** - * Unsupported `` value for "runes". Valid values are true or false - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function invalid_svelte_option_runes(node) { - e(node, "invalid_svelte_option_runes", "Unsupported `` value for \"runes\". Valid values are true or false"); -} - -/** - * Unsupported `` value for "accessors". Valid values are true or false - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function invalid_svelte_option_accessors(node) { - e(node, "invalid_svelte_option_accessors", "Unsupported `` value for \"accessors\". Valid values are true or false"); -} - -/** - * Unsupported `` value for "preserveWhitespace". Valid values are true or false - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function invalid_svelte_option_preserveWhitespace(node) { - e(node, "invalid_svelte_option_preserveWhitespace", "Unsupported `` value for \"preserveWhitespace\". Valid values are true or false"); -} - -/** - * Unsupported `` value for "immutable". Valid values are true or false - * @param {null | number | NodeLike} node - * @returns {never} - */ -export function invalid_svelte_option_immutable(node) { - e(node, "invalid_svelte_option_immutable", "Unsupported `` value for \"immutable\". Valid values are true or false"); +export function svelte_options_deprecated_tag(node) { + e(node, "svelte_options_deprecated_tag", "\"tag\" option is deprecated — use \"customElement\" instead"); } /** @@ -1144,8 +1108,8 @@ export function invalid_svelte_option_immutable(node) { * @param {null | number | NodeLike} node * @returns {never} */ -export function invalid_tag_property(node) { - e(node, "invalid_tag_property", "Tag name must be two or more words joined by the \"-\" character"); +export function svelte_options_invalid_tagname(node) { + e(node, "svelte_options_invalid_tagname", "Tag name must be two or more words joined by the \"-\" character"); } /** @@ -1153,8 +1117,8 @@ export function invalid_tag_property(node) { * @param {null | number | NodeLike} node * @returns {never} */ -export function invalid_svelte_option_customElement(node) { - e(node, "invalid_svelte_option_customElement", "\"customElement\" must be a string literal defining a valid custom element name or an object of the form { tag: string; shadow?: \"open\" | \"none\"; props?: { [key: string]: { attribute?: string; reflect?: boolean; type: .. } } }"); +export function svelte_options_invalid_customelement(node) { + e(node, "svelte_options_invalid_customelement", "\"customElement\" must be a string literal defining a valid custom element name or an object of the form { tag: string; shadow?: \"open\" | \"none\"; props?: { [key: string]: { attribute?: string; reflect?: boolean; type: .. } } }"); } /** @@ -1162,8 +1126,8 @@ export function invalid_svelte_option_customElement(node) { * @param {null | number | NodeLike} node * @returns {never} */ -export function invalid_customElement_props_attribute(node) { - e(node, "invalid_customElement_props_attribute", "\"props\" must be a statically analyzable object literal of the form \"{ [key: string]: { attribute?: string; reflect?: boolean; type?: \"String\" | \"Boolean\" | \"Number\" | \"Array\" | \"Object\" }\""); +export function svelte_options_invalid_customelement_props(node) { + e(node, "svelte_options_invalid_customelement_props", "\"props\" must be a statically analyzable object literal of the form \"{ [key: string]: { attribute?: string; reflect?: boolean; type?: \"String\" | \"Boolean\" | \"Number\" | \"Array\" | \"Object\" }\""); } /** @@ -1171,8 +1135,8 @@ export function invalid_customElement_props_attribute(node) { * @param {null | number | NodeLike} node * @returns {never} */ -export function invalid_customElement_shadow_attribute(node) { - e(node, "invalid_customElement_shadow_attribute", "\"shadow\" must be either \"open\" or \"none\""); +export function svelte_options_invalid_customelement_shadow(node) { + e(node, "svelte_options_invalid_customelement_shadow", "\"shadow\" must be either \"open\" or \"none\""); } /** @@ -1181,8 +1145,8 @@ export function invalid_customElement_shadow_attribute(node) { * @param {string} name * @returns {never} */ -export function unknown_svelte_option_attribute(node, name) { - e(node, "unknown_svelte_option_attribute", `\`\` unknown attribute '${name}'`); +export function svelte_options_unknown_attribute(node, name) { + e(node, "svelte_options_unknown_attribute", `\`\` unknown attribute '${name}'`); } /** diff --git a/packages/svelte/src/compiler/phases/1-parse/read/options.js b/packages/svelte/src/compiler/phases/1-parse/read/options.js index b8d701a8b5..9879d774ef 100644 --- a/packages/svelte/src/compiler/phases/1-parse/read/options.js +++ b/packages/svelte/src/compiler/phases/1-parse/read/options.js @@ -33,7 +33,7 @@ export default function read_options(node) { break; } case 'tag': { - e.tag_option_deprecated(attribute); + e.svelte_options_deprecated_tag(attribute); break; // eslint doesn't know this is unnecessary } case 'customElement': { @@ -42,7 +42,7 @@ export default function read_options(node) { const { value } = attribute; if (value === true) { - e.invalid_svelte_option_customElement(attribute); + e.svelte_options_invalid_customelement(attribute); } else if (value[0].type === 'Text') { const tag = get_static_value(attribute); validate_tag(attribute, tag); @@ -55,7 +55,7 @@ export default function read_options(node) { if (value[0].expression.type === 'Literal' && value[0].expression.value === null) { break; } - e.invalid_svelte_option_customElement(attribute); + e.svelte_options_invalid_customelement(attribute); } /** @type {Array<[string, any]>} */ @@ -66,7 +66,7 @@ export default function read_options(node) { property.computed || property.key.type !== 'Identifier' ) { - e.invalid_svelte_option_customElement(attribute); + e.svelte_options_invalid_customelement(attribute); } properties.push([property.key.name, property.value]); } @@ -77,13 +77,13 @@ export default function read_options(node) { validate_tag(tag, tag_value); ce.tag = tag_value; } else { - e.invalid_svelte_option_customElement(attribute); + e.svelte_options_invalid_customelement(attribute); } const props = properties.find(([name]) => name === 'props')?.[1]; if (props) { if (props.type !== 'ObjectExpression') { - e.invalid_customElement_props_attribute(attribute); + e.svelte_options_invalid_customelement_props(attribute); } ce.props = {}; for (const property of /** @type {import('estree').ObjectExpression} */ (props) @@ -94,7 +94,7 @@ export default function read_options(node) { property.key.type !== 'Identifier' || property.value.type !== 'ObjectExpression' ) { - e.invalid_customElement_props_attribute(attribute); + e.svelte_options_invalid_customelement_props(attribute); } ce.props[property.key.name] = {}; for (const prop of property.value.properties) { @@ -104,7 +104,7 @@ export default function read_options(node) { prop.key.type !== 'Identifier' || prop.value.type !== 'Literal' ) { - e.invalid_customElement_props_attribute(attribute); + e.svelte_options_invalid_customelement_props(attribute); } if (prop.key.name === 'type') { @@ -113,21 +113,21 @@ export default function read_options(node) { /** @type {string} */ (prop.value.value) ) === -1 ) { - e.invalid_customElement_props_attribute(attribute); + e.svelte_options_invalid_customelement_props(attribute); } ce.props[property.key.name].type = /** @type {any} */ (prop.value.value); } else if (prop.key.name === 'reflect') { if (typeof prop.value.value !== 'boolean') { - e.invalid_customElement_props_attribute(attribute); + e.svelte_options_invalid_customelement_props(attribute); } ce.props[property.key.name].reflect = prop.value.value; } else if (prop.key.name === 'attribute') { if (typeof prop.value.value !== 'string') { - e.invalid_customElement_props_attribute(attribute); + e.svelte_options_invalid_customelement_props(attribute); } ce.props[property.key.name].attribute = prop.value.value; } else { - e.invalid_customElement_props_attribute(attribute); + e.svelte_options_invalid_customelement_props(attribute); } } } @@ -137,7 +137,7 @@ export default function read_options(node) { if (shadow) { const shadowdom = shadow?.value; if (shadowdom !== 'open' && shadowdom !== 'none') { - e.invalid_customElement_shadow_attribute(shadow); + e.svelte_options_invalid_customelement_shadow(shadow); } ce.shadow = shadowdom; } @@ -176,7 +176,7 @@ export default function read_options(node) { break; } default: - e.unknown_svelte_option_attribute(attribute, name); + e.svelte_options_unknown_attribute(attribute, name); } } @@ -218,10 +218,10 @@ function get_boolean_value(attribute) { */ function validate_tag(attribute, tag) { if (typeof tag !== 'string') { - e.invalid_tag_property(attribute); + e.svelte_options_invalid_tagname(attribute); } if (tag && !regex_valid_tag_name.test(tag)) { - e.invalid_tag_property(attribute); + e.svelte_options_invalid_tagname(attribute); } // TODO do we still need this? // if (tag && !component.compile_options.customElement) { diff --git a/packages/svelte/tests/validator/samples/tag-invalid/errors.json b/packages/svelte/tests/validator/samples/tag-invalid/errors.json index 84d7f49de6..848f51af98 100644 --- a/packages/svelte/tests/validator/samples/tag-invalid/errors.json +++ b/packages/svelte/tests/validator/samples/tag-invalid/errors.json @@ -1,6 +1,6 @@ [ { - "code": "invalid_tag_property", + "code": "svelte_options_invalid_tagname", "message": "Tag name must be two or more words joined by the \"-\" character", "start": { "line": 1, diff --git a/packages/svelte/tests/validator/samples/tag-non-string/errors.json b/packages/svelte/tests/validator/samples/tag-non-string/errors.json index 0a41e50b9d..b74358966c 100644 --- a/packages/svelte/tests/validator/samples/tag-non-string/errors.json +++ b/packages/svelte/tests/validator/samples/tag-non-string/errors.json @@ -1,6 +1,6 @@ [ { - "code": "invalid_svelte_option_customElement", + "code": "svelte_options_invalid_customelement", "message": "\"customElement\" must be a string literal defining a valid custom element name or an object of the form { tag: string; shadow?: \"open\" | \"none\"; props?: { [key: string]: { attribute?: string; reflect?: boolean; type: .. } } }", "start": { "line": 1,