useQwikValidLexicalScope
このコンテンツはまだ日本語訳がありません。
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/useQwikValidLexicalScope
- This rule doesn’t have a fix.
- The default severity of this rule is error.
- This rule belongs to the following domains:
- Sources:
- Same as
qwik/valid-lexical-scope
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useQwikValidLexicalScope": "error" } } }}
Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”// 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");});
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.