Skip to content

useQwikLoaderLocation

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

Enforce that Qwik loader functions are declared in the correct location.

Route functions like routeLoader$, routeAction$ must be declared in route boundary files (index, layout, or plugin files inside the configured routes directory). All loader/action functions must also be exported from the module and follow the use* naming convention.

See the Qwik documentation for more details.

src/components/product.jsx
// src/components/product.jsx
import { routeLoader$ } from '@builder.io/qwik-city';
export const useProducts = routeLoader$(async () => {});
/src/components/product.jsx:3:28 lint/nursery/useQwikLoaderLocation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The route function routeLoader$() has been declared outside of the route boundaries.

1 │ // src/components/product.jsx
2 │ import { routeLoader$ } from ‘@builder.io/qwik-city’;
> 3 │ export const useProducts = routeLoader$(async () => {});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 │

Route functions are typically declared within the route boundaries as they are tied to a specific route, if not, Qwik can’t associate them with a route.

Route boundary files are index, layout, and plugin files inside the “src/routes” directory.

Move the file within the route boundaries or if you want to create reusable logic, you must re-export from within the router boundary.
See the Qwik docs on re-exporting loaders for details.

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.

src/routes/index.jsx
// src/routes/index.jsx
import { routeLoader$ } from '@builder.io/qwik-city';
export const getProducts = routeLoader$(async () => {});
/src/routes/index.jsx:3:14 lint/nursery/useQwikLoaderLocation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The exported name of routeLoader$() must follow the use* naming convention.

1 │ // src/routes/index.jsx
2 │ import { routeLoader$ } from ‘@builder.io/qwik-city’;
> 3 │ export const getProducts = routeLoader$(async () => {});
^^^^^^^^^^^
4 │

Rename the declaration to start with “use”.

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.

src/routes/index.jsx
// src/routes/index.jsx
import { routeLoader$ } from '@builder.io/qwik-city';
const useProducts = routeLoader$(async () => {});
/src/routes/index.jsx:3:7 lint/nursery/useQwikLoaderLocation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The loader function routeLoader$() is not being exported.

1 │ // src/routes/index.jsx
2 │ import { routeLoader$ } from ‘@builder.io/qwik-city’;
> 3 │ const useProducts = routeLoader$(async () => {});
^^^^^^^^^^^
4 │

A loader function must be exported, if not, the loader will not run. Make sure to export the loader.

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.

src/routes/index.jsx
// src/routes/index.jsx
import { routeLoader$ } from '@builder.io/qwik-city';
async function fetcher() {}
const useProducts = routeLoader$(fetcher);
/src/routes/index.jsx:4:7 lint/nursery/useQwikLoaderLocation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The loader function routeLoader$() is not being exported.

2 │ import { routeLoader$ } from ‘@builder.io/qwik-city’;
3 │ async function fetcher() {}
> 4 │ const useProducts = routeLoader$(fetcher);
^^^^^^^^^^^
5 │

A loader function must be exported, if not, the loader will not run. Make sure to export the loader.

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.

src/routes/index.jsx
// src/routes/index.jsx
import { routeLoader$ } from '@builder.io/qwik-city';
export const useProducts = routeLoader$(async () => {});