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
TODO
`let:` directive at invalid position
## invalid_style_directive_modifier

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

@ -173,7 +173,7 @@ export function transition_conflict(node, type, existing) {
* @returns {never}
*/
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}
*/
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;
parser.eat('#');
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('@')) {
const index = parser.index - 1;
parser.eat('@');
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);

@ -187,14 +187,17 @@ function validate_element(node, context) {
}
} else if (attribute.type === 'TransitionDirective') {
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 (attribute.name === existing.name) {
e.transition_duplicate(attribute, attribute.name);
if (existing) {
const a = existing.intro ? (existing.outro ? 'transition' : 'in') : 'out';
const b = attribute.intro ? (attribute.outro ? 'transition' : 'in') : 'out';
if (a === b) {
e.transition_duplicate(attribute, a);
} 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 = '';
for (const modifier of attribute.modifiers) {
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);
}
if (modifier === 'passive') {
@ -451,7 +454,7 @@ const validation = {
if (!contenteditable) {
e.missing_contenteditable_attribute(node);
} else if (!is_text_attribute(contenteditable) && contenteditable.value !== true) {
e.dynamic_contenteditable_attribute(node);
e.dynamic_contenteditable_attribute(contenteditable);
}
}
} else {
@ -459,7 +462,7 @@ const validation = {
if (match) {
const property = binding_properties[match];
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);
@ -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}`
const thing = 'constant';
console.log(binding);
if (is_binding) {
e.invalid_binding(node, thing);
} else {

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

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

@ -1,7 +1,7 @@
[
{
"code": "invalid_animation",
"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?",
"code": "animation_missing_key",
"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": {
"line": 6,
"column": 6

@ -1,7 +1,7 @@
[
{
"code": "invalid_animation",
"message": "An element that uses the animate directive must be the sole child of a keyed each block",
"code": "animation_invalid_placement",
"message": "An element that uses the `animate:` directive must be the only child of a keyed `{#each ...}` block",
"start": {
"line": 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)",
"start": {
"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)",
"start": {
"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)",
"start": {
"line": 5,

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

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

@ -1,7 +1,7 @@
[
{
"code": "bind_invalid_target",
"message": "'whatever' is not a valid binding",
"code": "bind_invalid",
"message": "`bind:whatever` is not a valid binding",
"start": {
"line": 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)",
"start": {
"line": 6,

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

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

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

@ -1,7 +1,7 @@
[
{
"code": "duplicate_declaration",
"message": "'item' has already been declared",
"message": "`item` has already been declared",
"start": {
"line": 6,
"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)",
"start": {
"line": 7,

@ -1,7 +1,7 @@
[
{
"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": {
"line": 1,
"column": 1

@ -1,7 +1,7 @@
[
{
"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": {
"line": 2,
"column": 1

@ -1,7 +1,7 @@
[
{
"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": {
"line": 1,
"column": 1

@ -1,7 +1,7 @@
[
{
"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": {
"line": 2,
"column": 1

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

@ -1,7 +1,7 @@
[
{
"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": {
"line": 12,
"column": 5

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

@ -1,7 +1,7 @@
[
{
"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": {
"line": 5,
"column": 0

@ -1,7 +1,7 @@
[
{
"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": {
"line": 5,
"column": 0

@ -1,7 +1,7 @@
[
{
"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": {
"line": 1,
"column": 16

@ -1,7 +1,7 @@
[
{
"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": {
"line": 1,
"column": 16

@ -1,7 +1,7 @@
[
{
"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": {
"line": 5,
"column": 0

@ -1,7 +1,7 @@
[
{
"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": {
"line": 7,
"column": 2

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

@ -1,7 +1,7 @@
[
{
"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": {
"line": 1,
"column": 16

@ -1,7 +1,7 @@
[
{
"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": {
"line": 1,
"column": 0

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

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

@ -1,7 +1,7 @@
[
{
"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": {
"line": 6,
"column": 12

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

@ -1,7 +1,7 @@
[
{
"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": {
"line": 6,
"column": 13

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

@ -1,7 +1,7 @@
[
{
"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": {
"line": 6,
"column": 20

@ -1,7 +1,7 @@
[
{
"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": {
"line": 6,
"column": 20

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

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

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

Loading…
Cancel
Save