pull/14290/head
Dominic Gannaway 2 years ago
parent 4d1bd54117
commit f8eee243dd

@ -958,6 +958,24 @@ A `<textarea>` can have either a value attribute or (equivalently) child content
`<title>` can only contain text and {tags}
```
### trace_rune_duplicate
```
`$track` must only be used once within the same block statement
```
### trace_rune_invalid_argument
```
`$track` requires a string argument for the trace name
```
### trace_rune_invalid_location
```
`$track` must be placed directly inside a block statement
```
### transition_conflict
```

@ -186,6 +186,18 @@ It's possible to export a snippet from a `<script module>` block, but only if it
Using a `$` prefix to refer to the value of a store is only possible inside `.svelte` files, where Svelte can automatically create subscriptions when a component is mounted and unsubscribe when the component is unmounted. Consider migrating to runes instead.
## trace_rune_duplicate
> `$track` must only be used once within the same block statement
## trace_rune_invalid_argument
> `$track` requires a string argument for the trace name
## trace_rune_invalid_location
> `$track` must be placed directly inside a block statement
## typescript_invalid_feature
> TypeScript language features like %feature% are not natively supported, and their use is generally discouraged. Outside of `<script>` tags, these features are not supported. For use within `<script>` tags, you will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler. If you are using `vitePreprocess`, make sure to specifically enable preprocessing script tags (`vitePreprocess({ script: true })`)

@ -469,6 +469,33 @@ export function store_invalid_subscription_module(node) {
e(node, "store_invalid_subscription_module", "Cannot reference store value outside a `.svelte` file");
}
/**
* `$track` requires a string argument for the trace name
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function trace_rune_invalid_argument(node) {
e(node, "trace_rune_invalid_argument", "`$track` requires a string argument for the trace name");
}
/**
* `$track` must be placed directly inside a block statement
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function trace_rune_invalid_location(node) {
e(node, "trace_rune_invalid_location", "`$track` must be placed directly inside a block statement");
}
/**
* `$track` must only be used once within the same block statement
* @param {null | number | NodeLike} node
* @returns {never}
*/
export function trace_rune_duplicate(node) {
e(node, "trace_rune_duplicate", "`$track` must only be used once within the same block statement");
}
/**
* TypeScript language features like %feature% are not natively supported, and their use is generally discouraged. Outside of `<script>` tags, these features are not supported. For use within `<script>` tags, you will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler. If you are using `vitePreprocess`, make sure to specifically enable preprocessing script tags (`vitePreprocess({ script: true })`)
* @param {null | number | NodeLike} node

@ -141,18 +141,16 @@ export function CallExpression(node, context) {
e.rune_invalid_arguments_length(node, rune, 'exactly one argument');
}
if (node.arguments[0].type !== 'Literal' || typeof node.arguments[0].value !== 'string') {
throw new Error('TODO: $track requires a string argument');
e.trace_rune_invalid_argument(node);
}
if (parent.type !== 'ExpressionStatement' || context.path.at(-2)?.type !== 'BlockStatement') {
throw new Error('TODO: $track must be inside a block statement');
e.trace_rune_invalid_location(node);
}
if (context.state.scope.tracing) {
throw new Error('TODO: $track must only be used once within the same block statement');
e.trace_rune_duplicate(node);
}
if (dev) {
// TODO should we validate if tracing is already enabled in this or a parent scope?
context.state.scope.tracing = node.arguments[0].value;
}

Loading…
Cancel
Save