useQwikMethodUsage
Este conteúdo não está disponível em sua língua ainda.
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/useQwikMethodUsage
- 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/use-method-usage
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useQwikMethodUsage": "error" } } }}
Description
Section titled “Description”Disallow use*
hooks outside of component$
or other use*
hooks in Qwik applications.
Ensures Qwik’s lifecycle hooks are only used in valid reactive contexts. See Qwik Component Lifecycle for proper hook usage.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”import { useSignal } from "@builder.io/qwik";
export const Counter = () => { const count = useSignal(0);};
code-block.js:4:17 lint/nursery/useQwikMethodUsage ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Qwik hook detected outside of an allowed scope.
3 │ export const Counter = () => {
> 4 │ const count = useSignal(0);
│ ^^^^^^^^^^^^
5 │ };
6 │
ℹ Qwik’s reactive hooks (functions starting with use* followed by uppercase letter) must be:
- Used exclusively within component$
functions
- Or encapsulated within other valid Qwik hooks
ℹ Check the Qwik documentation.
import { component$, useSignal } from "@builder.io/qwik";
export const Counter = component$(() => { const count = useSignal(0);});
export const useCounter = () => { const count = useSignal(0); return count;};
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.