Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Next route files may import shared server i18n from `#/lib/i18n.server.ts` (or `

Keep URL parsing and builders in a feature's `*-params.ts`. A shared URL belongs in a `*-params.ts` under `src/lib`.

Parse page search parameters on the server and pass the values to client components. When a persistent layout needs the current query after client navigation, import Next.js `useSearchParams` from within `src/lib/next-route-params.ts` and expose a hook from that module.

Keep HTTP work in the API or a Server Action. Next permits `src/app/health/route.ts` exporting only `GET`, and `src/app/mcp/route.ts` for MCP. A streaming handler under `src/app/api/**/route.ts` must contain `text/event-stream`, call a `.to*StreamResponse()` helper, or have a static value import from a module named `<feature>-stream.server.ts` (the `.ts` extension may be omitted). Type-only imports do not mark a route as streaming. Forward the stream from that module; a cancellable JSON response alone does not qualify.

API tests, test utilities and fixtures may use `fetch` when the same file starts a local server with `.listen(<numeric port>)`, including `.listen(0)`. MSW's `.listen({ ... })` still requires `onUnhandledRequest: "error"` (or `onUnhandledFrame: "error"` in MSW 3). Use `testClient()` for `/api` paths; direct `app.request(...)` or `createApp().request(...)` is allowed for literal paths outside `/api`, including static template literals.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mapringg/standard",
"version": "1.2.4",
"version": "1.2.5",
"description": "One oxlint config and plugin for every repository.",
"license": "MIT",
"repository": "github:mapringg/standard",
Expand Down
3 changes: 2 additions & 1 deletion src/plugin/owners.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ const TABLE = [
{
ban: { module: /^next\/navigation$/, names: ["useSearchParams"] },
kinds: ["web"],
use: "Parse searchParams on the server with <feature>-params.ts and pass props.",
owner: ["src/lib/next-route-params.ts"],
use: "Parse searchParams on the server and pass props, or use src/lib/next-route-params.ts in a persistent layout.",
},
{
ban: { property: ["router", "refresh"] },
Expand Down
18 changes: 18 additions & 0 deletions test/owners.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,21 @@ test("owners accepts shared URL params modules and keeps UI parsers centralized"
"apps/web/src/lib/compare-url.ts",
]);
});

test("owners allows the Next.js query hook only in the shared route params module", (t) => {
const hook = 'import { useSearchParams } from "next/navigation";\nexport const useQuery = () => useSearchParams();\n';
const result = lint(t, {
"apps/web/src/lib/next-route-params.ts": hook,
"apps/web/src/lib/search-params.ts": hook,
"apps/web/src/features/search/search-params.ts": hook,
"apps/web/src/components/search/search-view.tsx":
'import { useSearchParams as useQuery } from "next/navigation";\nexport const useParams = () => useQuery();\n',
"apps/web/src/components/search/search-panel.tsx":
'import { useQuery } from "#/lib/next-route-params.ts";\nexport const useParams = () => useQuery();\n',
});
deepEqual(filesWith(result, "owners"), [
"apps/web/src/components/search/search-view.tsx",
"apps/web/src/features/search/search-params.ts",
"apps/web/src/lib/search-params.ts",
]);
});
Loading