useQwikValidLexicalScope
¥Summary
-
规则生效日期:
v2.2.6¥Rule available since:
v2.2.6 -
诊断类别:
lint/nursery/useQwikValidLexicalScope¥Diagnostic Category:
lint/nursery/useQwikValidLexicalScope -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 error。
¥The default severity of this rule is error.
-
此规则属于以下域:
¥This rule belongs to the following domains:
-
来源:
¥Sources:
-
¥Same as
qwik/valid-lexical-scope
-
¥How to configure
{ "linter": { "rules": { "nursery": { "useQwikValidLexicalScope": "error" } } }}¥Description
禁止在 Qwik 美元 ($) 作用域中使用不可序列化的表达式。
¥Disallow unserializable expressions in Qwik dollar ($) scopes.
确保 Qwik 组件中捕获的所有值都可以正确序列化以实现可恢复性。请参阅 Qwik 优化器词法范围 获取正确的使用模式。
¥Ensures all captured values in Qwik components can be properly serialized for resumability. See Qwik Optimizer: Lexical Scope for proper usage patterns.
¥Examples
¥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.
¥Valid
const handleClick = $(() => { // Valid: only using serializable variables or props console.log("clicked");});¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号