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

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

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

@ -2,14 +2,14 @@
"code": "duplicate-animation",
"message": "An element can only have one 'animate' directive",
"start": {
"line": 2,
"line": 7,
"column": 18,
"character": 50
"character": 108
},
"end": {
"line": 2,
"line": 7,
"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)}
<div animate:foo animate:bar></div>
{/each}
<script>
export default {
animations: {
foo(node, animation, params) {
// ...
},
bar(node, animation, params) {
// ...
}
}
};
</script>

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

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

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

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

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

@ -1,14 +1,8 @@
<script>
function foo() {}
</script>
{#each things as thing (thing)}
<div animate:foo></div>
<div animate:foo></div>
{/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",
"message": "slot attribute cannot have a dynamic value",
"start": {
"line": 2,
"line": 6,
"column": 9,
"character": 18
"character": 75
},
"end": {
"line": 2,
"column": 21,
"character": 30
"line": 6,
"column": 19,
"character": 85
},
"pos": 18
"pos": 75
}]

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

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

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

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

@ -1,15 +1,9 @@
<script>
import Nested from './Nested.html';
</script>
<Nested>
{#if thing}
<div slot='foo'>{thing}</div>
{/if}
</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>
export default {
namespace: 'lol'
};
</script>
<svelte:meta namespace="lol"/>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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