update/delete various validation tests

pull/1866/head
Rich Harris 7 years ago
parent 6bb5c79ad7
commit 75bb357e98

@ -604,7 +604,7 @@ function process_meta(component, nodes) {
case 'namespace': case 'namespace':
if (!data) { if (!data) {
component.error(attribute, { component.error(attribute, {
code: `invalid-meta-attribute`, code: `invalid-${name}-attribute`,
message: `<svelte:meta> ${name} attribute must have a string value` message: `<svelte:meta> ${name} attribute must have a string value`
}); });
} }
@ -615,7 +615,7 @@ function process_meta(component, nodes) {
case 'immutable': case 'immutable':
if (data && (data !== 'true' && data !== 'false')) { if (data && (data !== 'true' && data !== 'false')) {
component.error(attribute, { component.error(attribute, {
code: `invalid-meta-attribute`, code: `invalid-immutable-attribute`,
message: `<svelte:meta> immutable attribute must be true or false` message: `<svelte:meta> immutable attribute must be true or false`
}); });
} }
@ -633,7 +633,7 @@ function process_meta(component, nodes) {
else if (attribute.type === 'Binding') { else if (attribute.type === 'Binding') {
if (attribute.name !== 'props') { if (attribute.name !== 'props') {
component.error(attribute, { component.error(attribute, {
code: `invalid-meta-attribute`, code: `invalid-meta-binding`,
message: `<svelte:meta> only supports bind:props` message: `<svelte:meta> only supports bind:props`
}); });
} }

@ -1,15 +1,15 @@
[{ [{
"code": "invalid-action", "code": "invalid-action",
"message": "Actions can only be applied to DOM elements, not components", "message": "Actions can only be applied to DOM elements, not components",
"pos": 8, "pos": 84,
"start": { "start": {
"line": 1, "line": 7,
"column": 8, "column": 8,
"character": 8 "character": 84
}, },
"end": { "end": {
"line": 1, "line": 7,
"column": 15, "column": 15,
"character": 15 "character": 91
} }
}] }]

@ -1,15 +1,7 @@
<Widget use:foo/>
<script> <script>
import Widget from './Widget.html'; import Widget from './Widget.html';
export default { function foo(){}
components: {
Widget
},
actions: {
foo() {}
}
};
</script> </script>
<Widget use:foo/>

@ -2,14 +2,14 @@
"code": "duplicate-animation", "code": "duplicate-animation",
"message": "An element can only have one 'animate' directive", "message": "An element can only have one 'animate' directive",
"start": { "start": {
"line": 2, "line": 7,
"column": 18, "column": 18,
"character": 50 "character": 108
}, },
"end": { "end": {
"line": 2, "line": 7,
"column": 29, "column": 29,
"character": 61 "character": 119
}, },
"pos": 50 "pos": 108
}] }]

@ -1,17 +1,8 @@
<script>
function foo() {}
function bar() {}
</script>
{#each things as thing (thing)} {#each things as thing (thing)}
<div animate:foo animate:bar></div> <div animate:foo animate:bar></div>
{/each} {/each}
<script>
export default {
animations: {
foo(node, animation, params) {
// ...
},
bar(node, animation, params) {
// ...
}
}
};
</script>

@ -2,14 +2,14 @@
"code": "invalid-animation", "code": "invalid-animation",
"message": "An element that use the animate directive must be the immediate child of a keyed each block", "message": "An element that use the animate directive must be the immediate child of a keyed each block",
"start": { "start": {
"line": 1, "line": 5,
"column": 5, "column": 5,
"character": 5 "character": 44
}, },
"end": { "end": {
"line": 1, "line": 5,
"column": 16, "column": 16,
"character": 16 "character": 55
}, },
"pos": 5 "pos": 44
}] }]

@ -1,11 +1,5 @@
<div animate:foo></div>
<script> <script>
export default { function foo() {}
animations: {
foo(node, animation, params) {
// ...
}
}
};
</script> </script>
<div animate:foo></div>

@ -2,14 +2,14 @@
"code": "invalid-animation", "code": "invalid-animation",
"message": "An element that use the animate directive must be the immediate child of a keyed each block", "message": "An element that use the animate directive must be the immediate child of a keyed each block",
"start": { "start": {
"line": 2, "line": 6,
"column": 6, "column": 6,
"character": 30 "character": 69
}, },
"end": { "end": {
"line": 2, "line": 6,
"column": 17, "column": 17,
"character": 41 "character": 80
}, },
"pos": 30 "pos": 69
}] }]

@ -1,14 +1,8 @@
<script>
function foo() {}
</script>
{#each things as thing} {#each things as thing}
<div animate:foo></div> <div animate:foo></div>
<div animate:foo></div> <div animate:foo></div>
{/each} {/each}
<script>
export default {
animations: {
foo(node, animation, params) {
// ...
}
}
};
</script>

@ -2,14 +2,14 @@
"code": "invalid-animation", "code": "invalid-animation",
"message": "An element that use the animate directive must be the sole child of a keyed each block", "message": "An element that use the animate directive must be the sole child of a keyed each block",
"start": { "start": {
"line": 2, "line": 6,
"column": 6, "column": 6,
"character": 38 "character": 77
}, },
"end": { "end": {
"line": 2, "line": 6,
"column": 17, "column": 17,
"character": 49 "character": 88
}, },
"pos": 38 "pos": 77
}] }]

@ -1,14 +1,8 @@
<script>
function foo() {}
</script>
{#each things as thing (thing)} {#each things as thing (thing)}
<div animate:foo></div> <div animate:foo></div>
<div animate:foo></div> <div animate:foo></div>
{/each} {/each}
<script>
export default {
animations: {
foo(node, animation, params) {
// ...
}
}
};
</script>

@ -1,15 +0,0 @@
[{
"code": "invalid-name",
"message": "Component constructors cannot be called 'state' due to technical limitations",
"pos": 73,
"start": {
"line": 6,
"column": 3,
"character": 73
},
"end": {
"line": 6,
"column": 8,
"character": 78
}
}]

@ -1,9 +0,0 @@
<script>
import state from 'foo';
export default {
components: {
state
}
};
</script>

@ -2,14 +2,14 @@
"code": "invalid-slot-attribute", "code": "invalid-slot-attribute",
"message": "slot attribute cannot have a dynamic value", "message": "slot attribute cannot have a dynamic value",
"start": { "start": {
"line": 2, "line": 6,
"column": 9, "column": 9,
"character": 18 "character": 75
}, },
"end": { "end": {
"line": 2, "line": 6,
"column": 21, "column": 19,
"character": 30 "character": 85
}, },
"pos": 18 "pos": 75
}] }]

@ -1,11 +1,7 @@
<Nested>
<button slot='{foo}'>click me</button>
</Nested>
<script> <script>
import Nested from './Nested.html'; import Nested from './Nested.html';
export default {
components: { Nested }
};
</script> </script>
<Nested>
<button slot={foo}>click me</button>
</Nested>

@ -2,14 +2,14 @@
"code": "invalid-slotted-content", "code": "invalid-slotted-content",
"message": "Cannot place slotted elements inside an each-block", "message": "Cannot place slotted elements inside an each-block",
"start": { "start": {
"line": 3, "line": 7,
"column": 7, "column": 7,
"character": 41 "character": 98
}, },
"end": { "end": {
"line": 3, "line": 7,
"column": 17, "column": 17,
"character": 51 "character": 108
}, },
"pos": 41 "pos": 98
}] }]

@ -1,15 +1,9 @@
<script>
import Nested from './Nested.html';
</script>
<Nested> <Nested>
{#each things as thing} {#each things as thing}
<div slot='foo'>{thing}</div> <div slot='foo'>{thing}</div>
{/each} {/each}
</Nested> </Nested>
<script>
import Nested from './Nested.html';
export default {
components: {
Nested
}
};
</script>

@ -2,14 +2,14 @@
"code": "invalid-slotted-content", "code": "invalid-slotted-content",
"message": "Cannot place slotted elements inside an if-block", "message": "Cannot place slotted elements inside an if-block",
"start": { "start": {
"line": 3, "line": 7,
"column": 7, "column": 7,
"character": 29 "character": 86
}, },
"end": { "end": {
"line": 3, "line": 7,
"column": 17, "column": 17,
"character": 39 "character": 96
}, },
"pos": 29 "pos": 86
}] }]

@ -1,15 +1,9 @@
<script>
import Nested from './Nested.html';
</script>
<Nested> <Nested>
{#if thing} {#if thing}
<div slot='foo'>{thing}</div> <div slot='foo'>{thing}</div>
{/if} {/if}
</Nested> </Nested>
<script>
import Nested from './Nested.html';
export default {
components: {
Nested
}
};
</script>

@ -0,0 +1,15 @@
[{
"code": "default-export",
"message": "A component cannot have a default export",
"pos": 10,
"start": {
"line": 2,
"column": 1,
"character": 10
},
"end": {
"line": 2,
"column": 19,
"character": 28
}
}]

@ -0,0 +1,3 @@
<script>
export default 42;
</script>

@ -1,15 +0,0 @@
[{
"code": "missing-ref",
"message": "'refs.inputx' does not exist (did you mean 'refs.input'?)",
"pos": 36,
"start": {
"line": 2,
"column": 18,
"character": 36
},
"end": {
"line": 2,
"column": 35,
"character": 53
}
}]

@ -1,2 +0,0 @@
<input ref:input>
<button on:click='refs.inputx.focus()'>focus input</button>

@ -1,2 +0,0 @@
<input ref:input>
<button on:click='{() => refs.input.focus()}'>focus input</button>

@ -1,11 +0,0 @@
<script>
export let things = [ 'a', 'b', 'c' ];
function thing(x) {
return x;
}
</script>
{#each things as thing}
{thing}
{/each}

@ -1,15 +0,0 @@
[{
"code": "each-context-clash",
"message": "Context clashes with a helper. Rename one or the other to eliminate any ambiguity",
"start": {
"line": 1,
"column": 17,
"character": 17
},
"end": {
"line": 1,
"column": 22,
"character": 22
},
"pos": 17
}]

@ -1,15 +0,0 @@
[{
"code": "named-export",
"message": "A component can only have a default export",
"pos": 10,
"start": {
"line": 2,
"column": 1,
"character": 10
},
"end": {
"line": 2,
"column": 21,
"character": 30
}
}]

@ -1,3 +0,0 @@
<script>
export var foo = 42;
</script>

@ -1,5 +1 @@
<script> <svelte:meta namespace="lol"/>
export default {
namespace: 'lol'
};
</script>

@ -1,5 +1 @@
<script> <svelte:meta namespace="http://www.w3.org/1999/svg"/>
export default {
namespace: 'http://www.w3.org/1999/svg'
};
</script>

@ -1,6 +1,6 @@
[{ [{
"code": "invalid-namespace-property", "code": "invalid-namespace-attribute",
"message": "The 'namespace' property must be a string literal representing a valid namespace", "message": "The 'namespace' attribute must be a string literal representing a valid namespace",
"pos": 79, "pos": 79,
"start": { "start": {
"line": 5, "line": 5,

@ -1,7 +1 @@
<script> <svelte:meta namespace={ns}/>
const namespace = 'http://www.w3.org/1999/svg';
export default {
namespace
};
</script>

@ -1,5 +1 @@
<script> <svelte:meta tag="invalid"/>
export default {
tag: 'invalid'
};
</script>

@ -1,5 +1,5 @@
[{ [{
"code": "invalid-tag-property", "code": "invalid-tag-attribute",
"message": "'tag' must be a string literal", "message": "'tag' must be a string literal",
"start": { "start": {
"line": 3, "line": 3,

@ -1,5 +1 @@
<script> <svelte:meta tag={42}/>
export default {
tag: 42
};
</script>

@ -2,14 +2,14 @@
"code": "duplicate-transition", "code": "duplicate-transition",
"message": "An element cannot have both an 'in' directive and a 'transition' directive", "message": "An element cannot have both an 'in' directive and a 'transition' directive",
"start": { "start": {
"line": 1, "line": 6,
"column": 12, "column": 12,
"character": 12 "character": 70
}, },
"end": { "end": {
"line": 1, "line": 6,
"column": 26, "column": 26,
"character": 26 "character": 84
}, },
"pos": 12 "pos": 70
}] }]

@ -1,10 +1,6 @@
<div in:foo transition:bar>...</div>
<script> <script>
export default { function foo() {}
transitions: { function bar() {}
foo,
bar
}
};
</script> </script>
<div in:foo transition:bar>...</div>

@ -2,14 +2,14 @@
"code": "duplicate-transition", "code": "duplicate-transition",
"message": "An element can only have one 'in' directive", "message": "An element can only have one 'in' directive",
"start": { "start": {
"line": 1, "line": 6,
"column": 12, "column": 12,
"character": 12 "character": 70
}, },
"end": { "end": {
"line": 1, "line": 6,
"column": 18, "column": 18,
"character": 18 "character": 76
}, },
"pos": 12 "pos": 70
}] }]

@ -1,10 +1,6 @@
<div in:foo in:bar>...</div>
<script> <script>
export default { function foo() {}
transitions: { function bar() {}
foo,
bar
}
};
</script> </script>
<div in:foo in:bar>...</div>

@ -2,14 +2,14 @@
"code": "duplicate-transition", "code": "duplicate-transition",
"message": "An element cannot have both an 'out' directive and a 'transition' directive", "message": "An element cannot have both an 'out' directive and a 'transition' directive",
"start": { "start": {
"line": 1, "line": 6,
"column": 13, "column": 13,
"character": 13 "character": 71
}, },
"end": { "end": {
"line": 1, "line": 6,
"column": 27, "column": 27,
"character": 27 "character": 85
}, },
"pos": 13 "pos": 71
}] }]

@ -1,10 +1,6 @@
<div out:foo transition:bar>...</div>
<script> <script>
export default { function foo() {}
transitions: { function bar() {}
foo,
bar
}
};
</script> </script>
<div out:foo transition:bar>...</div>

@ -2,14 +2,14 @@
"code": "duplicate-transition", "code": "duplicate-transition",
"message": "An element can only have one 'out' directive", "message": "An element can only have one 'out' directive",
"start": { "start": {
"line": 1, "line": 6,
"column": 13, "column": 13,
"character": 13 "character": 71
}, },
"end": { "end": {
"line": 1, "line": 6,
"column": 20, "column": 20,
"character": 20 "character": 78
}, },
"pos": 13 "pos": 71
}] }]

@ -1,10 +1,6 @@
<div out:foo out:bar>...</div>
<script> <script>
export default { function foo() {}
transitions: { function bar() {}
foo,
bar
}
};
</script> </script>
<div out:foo out:bar>...</div>

@ -2,14 +2,14 @@
"code": "duplicate-transition", "code": "duplicate-transition",
"message": "An element cannot have both a 'transition' directive and an 'in' directive", "message": "An element cannot have both a 'transition' directive and an 'in' directive",
"start": { "start": {
"line": 1, "line": 6,
"column": 20, "column": 20,
"character": 20 "character": 78
}, },
"end": { "end": {
"line": 1, "line": 6,
"column": 26, "column": 26,
"character": 26 "character": 84
}, },
"pos": 20 "pos": 78
}] }]

@ -1,10 +1,6 @@
<div transition:foo in:bar>...</div>
<script> <script>
export default { function foo() {}
transitions: { function bar() {}
foo,
bar
}
};
</script> </script>
<div transition:foo in:bar>...</div>

@ -2,14 +2,14 @@
"code": "duplicate-transition", "code": "duplicate-transition",
"message": "An element cannot have both a 'transition' directive and an 'out' directive", "message": "An element cannot have both a 'transition' directive and an 'out' directive",
"start": { "start": {
"line": 1, "line": 6,
"column": 20, "column": 20,
"character": 20 "character": 78
}, },
"end": { "end": {
"line": 1, "line": 6,
"column": 27, "column": 27,
"character": 27 "character": 85
}, },
"pos": 20 "pos": 78
}] }]

@ -1,10 +1,6 @@
<div transition:foo out:bar>...</div>
<script> <script>
export default { function foo() {}
transitions: { function bar() {}
foo,
bar
}
};
</script> </script>
<div transition:foo out:bar>...</div>

@ -2,14 +2,14 @@
"code": "duplicate-transition", "code": "duplicate-transition",
"message": "An element can only have one 'transition' directive", "message": "An element can only have one 'transition' directive",
"start": { "start": {
"line": 1, "line": 6,
"column": 20, "column": 20,
"character": 20 "character": 78
}, },
"end": { "end": {
"line": 1, "line": 6,
"column": 34, "column": 34,
"character": 34 "character": 92
}, },
"pos": 20 "pos": 78
}] }]

@ -1,10 +1,6 @@
<div transition:foo transition:bar>...</div>
<script> <script>
export default { function foo() {}
transitions: { function bar() {}
foo,
bar
}
};
</script> </script>
<div transition:foo transition:bar>...</div>

@ -2,14 +2,14 @@
"code": "invalid-transition", "code": "invalid-transition",
"message": "Transitions can only be applied to DOM elements, not components", "message": "Transitions can only be applied to DOM elements, not components",
"start": { "start": {
"line": 1, "line": 7,
"column": 8, "column": 8,
"character": 8 "character": 85
}, },
"end": { "end": {
"line": 1, "line": 7,
"column": 14, "column": 14,
"character": 14 "character": 91
}, },
"pos": 8 "pos": 85
}] }]

@ -1,15 +1,7 @@
<Widget in:foo/>
<script> <script>
import Widget from './Widget.html'; import Widget from './Widget.html';
export default { function foo() {}
components: {
Widget
},
transitions: {
foo() {}
}
};
</script> </script>
<Widget in:foo/>
Loading…
Cancel
Save