Aller au contenu

useQwikValidLexicalScope

Ce contenu n’est pas encore disponible dans votre langue.

biome.json
{
"linter": {
"rules": {
"nursery": {
"useQwikValidLexicalScope": "error"
}
}
}
}

Disallow unserializable expressions in Qwik dollar ($) scopes.

Ensures all captured values in Qwik components can be properly serialized for resumability. See Qwik Optimizer: Lexical Scope for proper usage patterns.

// Arrow function assigned without wrapping it in $(...)
const handleClick = () => {
console.log("clicked");
};
code-block.js:2:21 lint/nursery/useQwikValidLexicalScope ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Non-serializable expression must be wrapped with $(…)

1 │ // Arrow function assigned without wrapping it in $(…)
> 2 │ const handleClick = () => {
^^^^^^^
> 3 │ console.log(“clicked”);
> 4 │ };
^
5 │

Qwik requires serializable closures for:
- Resumability (pausing/resuming execution)
- Code splitting (lazy loading components)
- Optimized rehydration (client-side continuation)

Wrap the expression with $(…) to make it serializable. Learn more: Qwik documentation.

const handleClick = $(() => {
// Valid: only using serializable variables or props
console.log("clicked");
});