From 4cf2a1e7b9625033c5cf138f0785294025f7849b Mon Sep 17 00:00:00 2001 From: Sorawit Kongnurat Date: Thu, 19 Nov 2026 14:56:58 +0700 Subject: [PATCH] Allow native markup in shared web primitives --- README.md | 2 ++ oxlint.json | 12 ++++++++++++ package.json | 2 +- test/builtin-options.test.mjs | 19 +++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a4f444..d026de2 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,8 @@ Keep URL parsing and builders in a feature's `*-params.ts`. A shared URL belongs 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. +Use Next Image for page images. The shared `src/components/ui/image.tsx` and `src/components/ui/icon.tsx` primitives may use a native image for intrinsic sizing, load or error state, or a CSS mask. In `src/lib/navigation-link.tsx`, a disabled link may use a span with `role="link"` and `aria-disabled="true"` so it keeps its accessible role without a navigable URL. + 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 `-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()`, 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. diff --git a/oxlint.json b/oxlint.json index c6f85bd..c931593 100644 --- a/oxlint.json +++ b/oxlint.json @@ -203,6 +203,18 @@ "unicorn/prefer-code-point": "off" }, "overrides": [ + { + "files": ["apps/web/src/components/ui/image.tsx", "apps/web/src/components/ui/icon.tsx"], + "rules": { + "nextjs/no-img-element": "off" + } + }, + { + "files": ["apps/web/src/lib/navigation-link.tsx"], + "rules": { + "jsx-a11y/prefer-tag-over-role": "off" + } + }, { "files": ["**/src/app/**", "**/src/pages/**", "**/*.config.*"], "rules": { diff --git a/package.json b/package.json index 0218f2c..2c72a0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mapringg/standard", - "version": "1.2.5", + "version": "1.2.6", "description": "One oxlint config and plugin for every repository.", "license": "MIT", "repository": "github:mapringg/standard", diff --git a/test/builtin-options.test.mjs b/test/builtin-options.test.mjs index 7f4af9b..db96882 100644 --- a/test/builtin-options.test.mjs +++ b/test/builtin-options.test.mjs @@ -4,6 +4,25 @@ import { test } from "node:test"; import { lint } from "./lint.mjs"; +test("native image and disabled link exceptions are scoped to their shared primitives", (t) => { + const image = 'export function Picture() { return ; }\n'; + const disabled = 'export function Link() { return ; }\n'; + const diagnostics = lint(t, { + "apps/web/src/components/ui/image.tsx": image, + "apps/web/src/components/ui/icon.tsx": image, + "apps/web/src/features/search/search-card.tsx": image, + "apps/web/src/lib/navigation-link.tsx": disabled, + "apps/web/src/features/search/search-link.tsx": disabled, + }); + deepEqual( + diagnostics + .filter(({ rule }) => rule === "next(no-img-element)" || rule === "jsx-a11y(prefer-tag-over-role)") + .map(({ file }) => file) + .sort(), + ["apps/web/src/features/search/search-card.tsx", "apps/web/src/features/search/search-link.tsx"], + ); +}); + const RULES = new Set([ "typescript(promise-function-async)", "eslint(class-methods-use-this)",