跳转到内容

useQwikMethodUsage

此内容尚不支持你的语言。

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

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.

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.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

import { component$, useSignal } from "@builder.io/qwik";
export const Counter = component$(() => {
const count = useSignal(0);
});
export const useCounter = () => {
const count = useSignal(0);
return count;
};