pull/11327/head
Rich Harris 2 years ago
parent 125fb804d0
commit f8546458fb

@ -26,6 +26,10 @@
> All dependencies of the reactive declaration are declared in a module script and will not be reactive
## state_referenced_locally
> State referenced in its own scope will never update. Did you mean to reference it inside a closure?
## store_rune_conflict
> It looks like you're using the `$%name%` rune, but there is a local binding called `%name%`. Referencing a local variable with a `$` prefix will create a store subscription. Please rename `%name%` to avoid the ambiguity

@ -1,7 +0,0 @@
## invalid_rest_eachblock_binding
> The rest operator (...) will create a new object and binding '%name%' with the original object will not work
## static_state_reference
> State referenced in its own scope will never update. Did you mean to reference it inside a closure?

@ -14,6 +14,10 @@
> '%wrong%' is not a valid HTML attribute. Did you mean '%right%'?
## bind_invalid_each_rest
> The rest operator (...) will create a new object and binding '%name%' with the original object will not work
## block_empty
> Empty block

@ -1196,7 +1196,7 @@ const common_visitors = {
binding.kind === 'derived') &&
context.state.function_depth === binding.scope.function_depth
) {
w.static_state_reference(node);
w.state_referenced_locally(node);
}
}
},

@ -366,7 +366,7 @@ const validation = {
}
if (binding?.kind === 'each' && binding.metadata?.inside_rest) {
w.invalid_rest_eachblock_binding(binding.node, binding.node.name);
w.bind_invalid_each_rest(binding.node, binding.node.name);
}
const parent = context.path.at(-1);
@ -1063,7 +1063,8 @@ export const validation_runes = merge(validation, a11y_validators, {
if (
Runes.includes(/** @type {Runes[number]} */ (node.name)) &&
is_reference(node, parent) &&
!state.scope.get(node.name.slice(1))
state.scope.get(node.name) === null &&
state.scope.get(node.name.slice(1)) === null
) {
/** @type {import('estree').Expression} */
let current = node;
@ -1082,7 +1083,7 @@ export const validation_runes = merge(validation, a11y_validators, {
}
if (parent.type !== 'CallExpression') {
e.rune_missing_parentheses(current, name);
e.rune_missing_parentheses(current);
}
}
},

@ -537,21 +537,12 @@ export function store_rune_conflict(node, name) {
w(node, "store_rune_conflict", `It looks like you're using the \`$${name}\` rune, but there is a local binding called \`${name}\`. Referencing a local variable with a \`$\` prefix will create a store subscription. Please rename \`${name}\` to avoid the ambiguity`);
}
/**
* The rest operator (...) will create a new object and binding '%name%' with the original object will not work
* @param {null | NodeLike} node
* @param {string} name
*/
export function invalid_rest_eachblock_binding(node, name) {
w(node, "invalid_rest_eachblock_binding", `The rest operator (...) will create a new object and binding '${name}' with the original object will not work`);
}
/**
* State referenced in its own scope will never update. Did you mean to reference it inside a closure?
* @param {null | NodeLike} node
*/
export function static_state_reference(node) {
w(node, "static_state_reference", "State referenced in its own scope will never update. Did you mean to reference it inside a closure?");
export function state_referenced_locally(node) {
w(node, "state_referenced_locally", "State referenced in its own scope will never update. Did you mean to reference it inside a closure?");
}
/**
@ -639,4 +630,13 @@ export function event_directive_deprecated(node, name) {
*/
export function slot_element_deprecated(node) {
w(node, "slot_element_deprecated", "Using `<slot>` to render parent content is deprecated. Use `{@render ...}` tags instead.");
}
/**
* The rest operator (...) will create a new object and binding '%name%' with the original object will not work
* @param {null | NodeLike} node
* @param {string} name
*/
export function bind_invalid_each_rest(node, name) {
w(node, "bind_invalid_each_rest", `The rest operator (...) will create a new object and binding '${name}' with the original object will not work`);
}

@ -1,6 +1,6 @@
[
{
"code": "invalid_rest_eachblock_binding",
"code": "bind_invalid_each_rest",
"message": "The rest operator (...) will create a new object and binding 'rest' with the original object will not work",
"start": {
"line": 8,

@ -1,6 +1,6 @@
[
{
"code": "invalid_rest_eachblock_binding",
"code": "bind_invalid_each_rest",
"message": "The rest operator (...) will create a new object and binding 'rest' with the original object will not work",
"start": {
"line": 5,

@ -1,6 +1,6 @@
[
{
"code": "invalid_rest_eachblock_binding",
"code": "bind_invalid_each_rest",
"end": {
"column": 37,
"line": 5
@ -12,7 +12,7 @@
}
},
{
"code": "invalid_rest_eachblock_binding",
"code": "bind_invalid_each_rest",
"end": {
"column": 50,
"line": 5

@ -1,6 +1,6 @@
[
{
"code": "invalid_rest_eachblock_binding",
"code": "bind_invalid_each_rest",
"message": "The rest operator (...) will create a new object and binding 'rest' with the original object will not work",
"start": {
"line": 5,

@ -1,6 +1,6 @@
[
{
"code": "static_state_reference",
"code": "state_referenced_locally",
"message": "State referenced in its own scope will never update. Did you mean to reference it inside a closure?",
"start": {
"column": 13,
@ -12,7 +12,7 @@
}
},
{
"code": "static_state_reference",
"code": "state_referenced_locally",
"message": "State referenced in its own scope will never update. Did you mean to reference it inside a closure?",
"start": {
"column": 13,

Loading…
Cancel
Save