fix some tests

pull/11294/head
Rich Harris 2 years ago
parent 21eaa08017
commit b394b16f19

@ -48,7 +48,7 @@ Cannot use `%type%:` alongside existing `%existing%:` directive
## invalid_let_directive_placement ## invalid_let_directive_placement
TODO `let:` directive at invalid position
## invalid_style_directive_modifier ## invalid_style_directive_modifier

@ -52,4 +52,4 @@ Nesting selectors can only be used inside a rule
## invalid_css_declaration ## invalid_css_declaration
TODO Declaration cannot be empty

@ -173,7 +173,7 @@ export function transition_conflict(node, type, existing) {
* @returns {never} * @returns {never}
*/ */
export function invalid_let_directive_placement(node) { export function invalid_let_directive_placement(node) {
e(node, "invalid_let_directive_placement", "TODO"); e(node, "invalid_let_directive_placement", "`let:` directive at invalid position");
} }
/** /**
@ -436,7 +436,7 @@ export function invalid_nesting_selector(node) {
* @returns {never} * @returns {never}
*/ */
export function invalid_css_declaration(node) { export function invalid_css_declaration(node) {
e(node, "invalid_css_declaration", "TODO"); e(node, "invalid_css_declaration", "Declaration cannot be empty");
} }
/** /**

@ -738,12 +738,12 @@ function read_sequence(parser, done, location) {
const index = parser.index - 1; const index = parser.index - 1;
parser.eat('#'); parser.eat('#');
const name = parser.read_until(/[^a-z]/); const name = parser.read_until(/[^a-z]/);
e.invalid_block_placement(index, location, name); e.invalid_block_placement(index, name, location);
} else if (parser.match('@')) { } else if (parser.match('@')) {
const index = parser.index - 1; const index = parser.index - 1;
parser.eat('@'); parser.eat('@');
const name = parser.read_until(/[^a-z]/); const name = parser.read_until(/[^a-z]/);
e.invalid_tag_placement(index, location, name); e.invalid_tag_placement(index, name, location);
} }
flush(parser.index - 1); flush(parser.index - 1);

@ -187,14 +187,17 @@ function validate_element(node, context) {
} }
} else if (attribute.type === 'TransitionDirective') { } else if (attribute.type === 'TransitionDirective') {
const existing = /** @type {import('#compiler').TransitionDirective | null} */ ( const existing = /** @type {import('#compiler').TransitionDirective | null} */ (
attribute.intro ? in_transition : out_transition (attribute.intro && in_transition) || (attribute.outro && out_transition)
); );
if (existing !== null) { if (existing) {
if (attribute.name === existing.name) { const a = existing.intro ? (existing.outro ? 'transition' : 'in') : 'out';
e.transition_duplicate(attribute, attribute.name); const b = attribute.intro ? (attribute.outro ? 'transition' : 'in') : 'out';
if (a === b) {
e.transition_duplicate(attribute, a);
} else { } else {
e.transition_conflict(attribute, attribute.name, existing.name); e.transition_conflict(attribute, a, b);
} }
} }
@ -205,7 +208,7 @@ function validate_element(node, context) {
let conflicting_passive_modifier = ''; let conflicting_passive_modifier = '';
for (const modifier of attribute.modifiers) { for (const modifier of attribute.modifiers) {
if (!EventModifiers.includes(modifier)) { if (!EventModifiers.includes(modifier)) {
const list = `${EventModifiers.slice(0, 1)} or ${EventModifiers.at(-1)}`; const list = `${EventModifiers.slice(0, -1).join(', ')} or ${EventModifiers.at(-1)}`;
e.invalid_event_modifier(attribute, list); e.invalid_event_modifier(attribute, list);
} }
if (modifier === 'passive') { if (modifier === 'passive') {
@ -451,7 +454,7 @@ const validation = {
if (!contenteditable) { if (!contenteditable) {
e.missing_contenteditable_attribute(node); e.missing_contenteditable_attribute(node);
} else if (!is_text_attribute(contenteditable) && contenteditable.value !== true) { } else if (!is_text_attribute(contenteditable) && contenteditable.value !== true) {
e.dynamic_contenteditable_attribute(node); e.dynamic_contenteditable_attribute(contenteditable);
} }
} }
} else { } else {
@ -459,7 +462,7 @@ const validation = {
if (match) { if (match) {
const property = binding_properties[match]; const property = binding_properties[match];
if (!property.valid_elements || property.valid_elements.includes(parent.name)) { if (!property.valid_elements || property.valid_elements.includes(parent.name)) {
e.bind_invalid_detailed(node, node.name, ` Did you mean '${match}'?`); e.bind_invalid_detailed(node, node.name, `Did you mean '${match}'?`);
} }
} }
e.bind_invalid(node, node.name); e.bind_invalid(node, node.name);
@ -1026,6 +1029,8 @@ function validate_no_const_assignment(node, argument, scope, is_binding) {
// TODO have a more specific error message for assignments to things like `{:then foo}` // TODO have a more specific error message for assignments to things like `{:then foo}`
const thing = 'constant'; const thing = 'constant';
console.log(binding);
if (is_binding) { if (is_binding) {
e.invalid_binding(node, thing); e.invalid_binding(node, thing);
} else { } else {

@ -1,6 +1,6 @@
[ [
{ {
"code": "duplicate_animation", "code": "animation_duplicate",
"message": "An element can only have one 'animate' directive", "message": "An element can only have one 'animate' directive",
"start": { "start": {
"line": 7, "line": 7,

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_animation", "code": "animation_invalid_placement",
"message": "An element that uses the animate directive must be the immediate child of a keyed each block", "message": "An element that uses the `animate:` directive must be the only child of a keyed `{#each ...}` block",
"start": { "start": {
"line": 5, "line": 5,
"column": 5 "column": 5

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_animation", "code": "animation_missing_key",
"message": "An element that uses the animate directive must be used inside a keyed each block. Did you forget to add a key to your each block?", "message": "An element that uses the `animate:` directive must be the only child of a keyed `{#each ...}` block. Did you forget to add a key to your each block?",
"start": { "start": {
"line": 6, "line": 6,
"column": 6 "column": 6

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_animation", "code": "animation_invalid_placement",
"message": "An element that uses the animate directive must be the sole child of a keyed each block", "message": "An element that uses the `animate:` directive must be the only child of a keyed `{#each ...}` block",
"start": { "start": {
"line": 6, "line": 6,
"column": 6 "column": 6

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_assignment", "code": "invalid_binding",
"message": "Invalid binding to const variable ($derived values, let: directives, :then/:catch variables and @const declarations count as const)", "message": "Invalid binding to const variable ($derived values, let: directives, :then/:catch variables and @const declarations count as const)",
"start": { "start": {
"line": 6, "line": 6,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_assignment", "code": "invalid_binding",
"message": "Invalid binding to const variable ($derived values, let: directives, :then/:catch variables and @const declarations count as const)", "message": "Invalid binding to const variable ($derived values, let: directives, :then/:catch variables and @const declarations count as const)",
"start": { "start": {
"line": 6, "line": 6,

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_assignment", "code": "invalid_binding",
"message": "Invalid binding to const variable ($derived values, let: directives, :then/:catch variables and @const declarations count as const)", "message": "Invalid binding to const variable ($derived values, let: directives, :then/:catch variables and @const declarations count as const)",
"start": { "start": {
"line": 5, "line": 5,

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_assignment", "code": "invalid_binding",
"message": "Invalid binding to const variable", "message": "Cannot bind to constant",
"start": { "start": {
"line": 5, "line": 5,
"column": 7 "column": 7

@ -1,7 +1,7 @@
[ [
{ {
"code": "bind_invalid_target", "code": "bind_invalid_detailed",
"message": "'value' is not a valid binding. Foreign elements only support bind:this", "message": "`bind:value` is not a valid binding. Foreign elements only support `bind:this`",
"start": { "start": {
"line": 6, "line": 6,
"column": 7 "column": 7

@ -1,7 +1,7 @@
[ [
{ {
"code": "bind_invalid_target", "code": "bind_invalid",
"message": "'whatever' is not a valid binding", "message": "`bind:whatever` is not a valid binding",
"start": { "start": {
"line": 5, "line": 5,
"column": 5 "column": 5

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_assignment", "code": "invalid_binding",
"message": "Invalid binding to const variable ($derived values, let: directives, :then/:catch variables and @const declarations count as const)", "message": "Invalid binding to const variable ($derived values, let: directives, :then/:catch variables and @const declarations count as const)",
"start": { "start": {
"line": 6, "line": 6,

@ -1,7 +1,7 @@
[ [
{ {
"message": "Event modifiers other than 'once' can only be used on DOM elements", "message": "Event modifiers other than 'once' can only be used on DOM elements",
"code": "invalid_event_modifier", "code": "invalid_component_event_modifier",
"start": { "start": {
"line": 6, "line": 6,
"column": 8 "column": 8

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_slot_name", "code": "invalid_slot_name_default",
"message": "default is a reserved word — it cannot be used as a slot name", "message": "`default` is a reserved word — it cannot be used as a slot name",
"start": { "start": {
"line": 1, "line": 1,
"column": 6 "column": 6

@ -1,7 +1,7 @@
[ [
{ {
"code": "duplicate_declaration", "code": "duplicate_declaration",
"message": "'a' has already been declared", "message": "`a` has already been declared",
"start": { "start": {
"line": 7, "line": 7,
"column": 10 "column": 10

@ -1,7 +1,7 @@
[ [
{ {
"code": "duplicate_declaration", "code": "duplicate_declaration",
"message": "'item' has already been declared", "message": "`item` has already been declared",
"start": { "start": {
"line": 6, "line": 6,
"column": 10 "column": 10

@ -1,6 +1,6 @@
[ [
{ {
"code": "invalid_assignment", "code": "invalid_binding",
"message": "Invalid binding to const variable ($derived values, let: directives, :then/:catch variables and @const declarations count as const)", "message": "Invalid binding to const variable ($derived values, let: directives, :then/:catch variables and @const declarations count as const)",
"start": { "start": {
"line": 7, "line": 7,

@ -1,7 +1,7 @@
[ [
{ {
"code": "illegal_global", "code": "illegal_global",
"message": "$$billsyall is an illegal variable name. To reference a global variable called $$billsyall, use globalThis.$$billsyall", "message": "`$$billsyall` is an illegal variable name. To reference a global variable called `$$billsyall`, use `globalThis.$$billsyall`",
"start": { "start": {
"line": 1, "line": 1,
"column": 1 "column": 1

@ -1,7 +1,7 @@
[ [
{ {
"code": "illegal_global", "code": "illegal_global",
"message": "$$billsyall is an illegal variable name. To reference a global variable called $$billsyall, use globalThis.$$billsyall", "message": "`$$billsyall` is an illegal variable name. To reference a global variable called `$$billsyall`, use `globalThis.$$billsyall`",
"start": { "start": {
"line": 2, "line": 2,
"column": 1 "column": 1

@ -1,7 +1,7 @@
[ [
{ {
"code": "illegal_global", "code": "illegal_global",
"message": "$ is an illegal variable name. To reference a global variable called $, use globalThis.$", "message": "`$` is an illegal variable name. To reference a global variable called `$`, use `globalThis.$`",
"start": { "start": {
"line": 1, "line": 1,
"column": 1 "column": 1

@ -1,7 +1,7 @@
[ [
{ {
"code": "illegal_global", "code": "illegal_global",
"message": "$ is an illegal variable name. To reference a global variable called $, use globalThis.$", "message": "`$` is an illegal variable name. To reference a global variable called `$`, use `globalThis.$`",
"start": { "start": {
"line": 2, "line": 2,
"column": 1 "column": 1

@ -1,7 +1,7 @@
[ [
{ {
"code": "missing_svelte_element_definition", "code": "missing_svelte_element_definition",
"message": "<svelte:element> must have a 'this' attribute", "message": "`<svelte:element>` must have a 'this' attribute",
"start": { "start": {
"line": 2, "line": 2,
"column": 1 "column": 1

@ -1,7 +1,7 @@
[ [
{ {
"code": "illegal_variable_declaration", "code": "illegal_variable_declaration",
"message": "Cannot declare same variable name which is imported inside <script context=\"module\">", "message": "Cannot declare same variable name which is imported inside `<script context=\"module\">`",
"start": { "start": {
"line": 12, "line": 12,
"column": 5 "column": 5

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_let_directive_placement", "code": "invalid_let_directive_placement",
"message": "let directive at invalid position", "message": "`let:` directive at invalid position",
"start": { "start": {
"line": 6, "line": 6,
"column": 15 "column": 15

@ -1,7 +1,7 @@
[ [
{ {
"code": "duplicate_script_element", "code": "duplicate_script_element",
"message": "A component can have a single top-level <script> element and/or a single top-level <script context=\"module\"> element", "message": "A component can have a single top-level `<script>` element and/or a single top-level `<script context=\"module\">` element",
"start": { "start": {
"line": 5, "line": 5,
"column": 0 "column": 0

@ -1,7 +1,7 @@
[ [
{ {
"code": "duplicate_script_element", "code": "duplicate_script_element",
"message": "A component can have a single top-level <script> element and/or a single top-level <script context=\"module\"> element", "message": "A component can have a single top-level `<script>` element and/or a single top-level `<script context=\"module\">` element",
"start": { "start": {
"line": 5, "line": 5,
"column": 0 "column": 0

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_svelte_option_namespace", "code": "invalid_svelte_option_namespace",
"message": "Unsupported <svelte:option> value for \"namespace\". Valid values are \"html\", \"svg\" or \"foreign\".", "message": "Unsupported `<svelte:option>` value for \"namespace\". Valid values are \"html\", \"svg\" or \"foreign\"",
"start": { "start": {
"line": 1, "line": 1,
"column": 16 "column": 16

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_svelte_option_namespace", "code": "invalid_svelte_option_namespace",
"message": "Unsupported <svelte:option> value for \"namespace\". Valid values are \"html\", \"svg\" or \"foreign\".", "message": "Unsupported `<svelte:option>` value for \"namespace\". Valid values are \"html\", \"svg\" or \"foreign\"",
"start": { "start": {
"line": 1, "line": 1,
"column": 16 "column": 16

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_svelte_fragment_placement", "code": "invalid_svelte_fragment_placement",
"message": "<svelte:fragment> must be the direct child of a component", "message": "`<svelte:fragment>` must be the direct child of a component",
"start": { "start": {
"line": 5, "line": 5,
"column": 0 "column": 0

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_svelte_fragment_placement", "code": "invalid_svelte_fragment_placement",
"message": "<svelte:fragment> must be the direct child of a component", "message": "`<svelte:fragment>` must be the direct child of a component",
"start": { "start": {
"line": 7, "line": 7,
"column": 2 "column": 2

@ -1,7 +1,7 @@
[ [
{ {
"code": "illegal_svelte_head_attribute", "code": "illegal_svelte_head_attribute",
"message": "<svelte:head> cannot have attributes nor directives", "message": "`<svelte:head>` cannot have attributes nor directives",
"start": { "start": {
"line": 1, "line": 1,
"column": 13 "column": 13

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_tag_property", "code": "invalid_tag_property",
"message": "tag name must be two or more words joined by the \"-\" character", "message": "Tag name must be two or more words joined by the \"-\" character",
"start": { "start": {
"line": 1, "line": 1,
"column": 16 "column": 16

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_textarea_content", "code": "invalid_textarea_content",
"message": "A <textarea> can have either a value attribute or (equivalently) child content, but not both", "message": "A `<textarea>` can have either a value attribute or (equivalently) child content, but not both",
"start": { "start": {
"line": 1, "line": 1,
"column": 0 "column": 0

@ -1,7 +1,7 @@
[ [
{ {
"code": "illegal_title_attribute", "code": "illegal_title_attribute",
"message": "<title> cannot have attributes nor directives", "message": "`<title>` cannot have attributes nor directives",
"start": { "start": {
"line": 2, "line": 2,
"column": 8 "column": 8

@ -1,7 +1,7 @@
[ [
{ {
"code": "invalid_title_content", "code": "invalid_title_content",
"message": "<title> can only contain text and {tags}", "message": "`<title>` can only contain text and {tags}",
"start": { "start": {
"line": 2, "line": 2,
"column": 11 "column": 11

@ -1,7 +1,7 @@
[ [
{ {
"code": "transition_conflict", "code": "transition_conflict",
"message": "An element cannot have both an 'in' directive and a 'transition' directive", "message": "Cannot use `in:` alongside existing `transition:` directive",
"start": { "start": {
"line": 6, "line": 6,
"column": 12 "column": 12

@ -1,7 +1,7 @@
[ [
{ {
"code": "transition_conflict", "code": "transition_duplicate",
"message": "An element can only have one 'in' directive", "message": "Cannot use multiple `in:` directives on a single element",
"start": { "start": {
"line": 6, "line": 6,
"column": 12 "column": 12

@ -1,7 +1,7 @@
[ [
{ {
"code": "transition_conflict", "code": "transition_conflict",
"message": "An element cannot have both an 'out' directive and a 'transition' directive", "message": "Cannot use `out:` alongside existing `transition:` directive",
"start": { "start": {
"line": 6, "line": 6,
"column": 13 "column": 13

@ -1,7 +1,7 @@
[ [
{ {
"code": "transition_conflict", "code": "transition_duplicate",
"message": "An element can only have one 'out' directive", "message": "Cannot use multiple `out:` directives on a single element",
"start": { "start": {
"line": 6, "line": 6,
"column": 13 "column": 13

@ -1,7 +1,7 @@
[ [
{ {
"code": "transition_conflict", "code": "transition_conflict",
"message": "An element cannot have both a 'transition' directive and an 'in' directive", "message": "Cannot use `transition:` alongside existing `in:` directive",
"start": { "start": {
"line": 6, "line": 6,
"column": 20 "column": 20

@ -1,7 +1,7 @@
[ [
{ {
"code": "transition_conflict", "code": "transition_conflict",
"message": "An element cannot have both a 'transition' directive and an 'out' directive", "message": "Cannot use `transition:` alongside existing `out:` directive",
"start": { "start": {
"line": 6, "line": 6,
"column": 20 "column": 20

@ -1,7 +1,7 @@
[ [
{ {
"code": "transition_conflict", "code": "transition_duplicate",
"message": "An element can only have one 'transition' directive", "message": "Cannot use multiple `transition:` directives on a single element",
"start": { "start": {
"line": 6, "line": 6,
"column": 20 "column": 20

@ -1,7 +1,7 @@
[ [
{ {
"code": "bind_invalid_target", "code": "bind_invalid_detailed",
"message": "'innerwidth' is not a valid binding (did you mean 'innerWidth'?)", "message": "`bind:innerwidth` is not a valid binding. Did you mean 'innerWidth'?",
"start": { "start": {
"line": 5, "line": 5,
"column": 15 "column": 15

@ -1,7 +1,7 @@
[ [
{ {
"code": "bind_invalid_target", "code": "bind_invalid",
"message": "'potato' is not a valid binding", "message": "`bind:potato` is not a valid binding",
"start": { "start": {
"line": 5, "line": 5,
"column": 15 "column": 15

Loading…
Cancel
Save