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
5 changes: 5 additions & 0 deletions .changeset/calm-timers-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"oxlint-plugin-react-doctor": patch
---

Avoid `effect-needs-cleanup` diagnostics for owned chained timers, guarded post-await timers, and listeners released through an abort handler.
5 changes: 5 additions & 0 deletions .changeset/curly-hounds-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"oxlint-plugin-react-doctor": patch
---

Fix an `async-defer-await` false positive on exact `live` and `isLive` liveness guards without exempting unrelated names that only contain the same text.
5 changes: 5 additions & 0 deletions .changeset/detect-sentry-wrapped-compiler-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@react-doctor/core": patch
---

Detect React Compiler configuration passed through `withSentryConfig`.
9 changes: 9 additions & 0 deletions .changeset/fix-1757-headers-helper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"oxlint-plugin-react-doctor": patch
---

Fix false positive in `nextjs-no-side-effect-in-get-handler` when locally-built `Headers` object is passed to a same-file helper that mutates it.

The rule now transfers locally-created response object safety through the exact same-file helper call. Calls that pass external state to the same helper remain reportable.

Fixes #1757
9 changes: 9 additions & 0 deletions .changeset/respect-use-no-memo-directive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"oxlint-plugin-react-doctor": patch
---

fix: respect "use no memo" directive in react-compiler-no-manual-memoization rule

When a function or module has a React Compiler opt-out directive, the compiler skips optimization, so manual memoization can still be necessary. The rule now respects `"use no memo"`, its `"use no forget"` alias, and local components passed to `memo`.

Fixes #1749
9 changes: 9 additions & 0 deletions .changeset/sanity-blueprint-convention.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@react-doctor/core": patch
---

Treat Sanity blueprint files as convention entries

`sanity.blueprint.ts` is a Sanity Studio convention file loaded by filename by the Sanity CLI (`sanity blueprints deploy`), similar to `sanity.config.ts` and `sanity.cli.ts`. It was incorrectly reported as unused by `react-doctor/unused-file`.

Fixes #1747
5 changes: 5 additions & 0 deletions .changeset/send-resend-notify-email-exemption.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"oxlint-plugin-react-doctor": patch
---

Exempt magic-link delivery mutations from `query-mutation-missing-invalidation` while keeping generic send, notification, and email mutations reportable.
5 changes: 5 additions & 0 deletions .changeset/trace-timeout-increase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-doctor": patch
---

Increase runtime trace finalization timeout from 10 to 60 seconds to handle large traces from longer recording sessions
2 changes: 1 addition & 1 deletion packages/core/src/project-analysis/collect/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,7 @@ const FRAMEWORK_PATTERNS: ToolingPluginDefinition[] = [
enablers: ["sanity", "@sanity/cli"],
enablerPrefixes: ["@sanity/"],
entryPatterns: [],
alwaysUsed: ["sanity.config.{ts,js}", "sanity.cli.{ts,js}"],
alwaysUsed: ["sanity.config.{ts,js}", "sanity.cli.{ts,js}", "sanity.blueprint.{ts,js}"],
},
{
enablers: ["astro"],
Expand Down
41 changes: 41 additions & 0 deletions packages/core/src/project-info/react-compiler-config-evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,17 @@ const analyzeConfigIdentifier = (
);
};

const hasReactCompilerConfigInSentryWrapperArgument = (
callExpression: ts.CallExpression,
analysis: ConfigExpressionAnalysis,
moduleSpecifier: string,
exportName: string,
): boolean => {
if (moduleSpecifier !== "@sentry/nextjs" || exportName !== "withSentryConfig") return false;
const [configArgument] = callExpression.arguments;
return Boolean(configArgument && analyzeConfigNode(configArgument, analysis, false));
};

const analyzeConfigCallTarget = (
callExpression: ts.CallExpression,
analysis: ConfigExpressionAnalysis,
Expand Down Expand Up @@ -1543,6 +1554,16 @@ const analyzeConfigCallTarget = (
) {
return true;
}
if (
hasReactCompilerConfigInSentryWrapperArgument(
callExpression,
analysis,
requiredModuleSpecifier,
propertyName,
)
) {
return true;
}
const hasCompilerTransform = analyzeImportedConfig({
analysis,
moduleSpecifier: requiredModuleSpecifier,
Expand Down Expand Up @@ -1570,6 +1591,16 @@ const analyzeConfigCallTarget = (
) {
return true;
}
if (
hasReactCompilerConfigInSentryWrapperArgument(
callExpression,
analysis,
importBinding.moduleSpecifier,
propertyName,
)
) {
return true;
}
const hasCompilerTransform = analyzeImportedConfig({
analysis,
moduleSpecifier: importBinding.moduleSpecifier,
Expand Down Expand Up @@ -1864,6 +1895,16 @@ const analyzeConfigNode = (
) {
return true;
}
if (
hasReactCompilerConfigInSentryWrapperArgument(
node,
analysis,
importBinding.moduleSpecifier,
importBinding.exportName,
)
) {
return true;
}
if (
allowCompilerTransform &&
importBinding.moduleSpecifier === "@rolldown/plugin-babel" &&
Expand Down
69 changes: 69 additions & 0 deletions packages/core/tests/discover-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,75 @@ describe("discoverProject", () => {
},
);

it.each([
{
name: "named-import",
config:
"import { withSentryConfig } from '@sentry/nextjs'; const nextConfig = { reactCompiler: true }; export default withSentryConfig(nextConfig, { org: 'x' });",
helper: null,
expected: true,
},
{
name: "namespace-import",
config:
"import * as Sentry from '@sentry/nextjs'; const nextConfig = { reactCompiler: true }; export default Sentry.withSentryConfig(nextConfig, { org: 'x' });",
helper: null,
expected: true,
},
{
name: "commonjs-require",
config:
"const Sentry = require('@sentry/nextjs'); const nextConfig = { reactCompiler: true }; module.exports = Sentry.withSentryConfig(nextConfig, { org: 'x' });",
helper: null,
expected: true,
},
{
name: "local-wrapper",
config:
"import { wrap } from './wrapper'; const nextConfig = { reactCompiler: true }; export default wrap(nextConfig);",
helper:
"import { withSentryConfig } from '@sentry/nextjs'; export const wrap = (config) => withSentryConfig(config, { org: 'x' });",
expected: true,
},
{
name: "compiler-only-in-options",
config:
"import { withSentryConfig } from '@sentry/nextjs'; export default withSentryConfig({ reactCompiler: false }, { reactCompiler: true });",
helper: null,
expected: false,
},
])(
"detects React Compiler through Sentry config wrappers: $name",
({ name, config, helper, expected }) => {
const projectDirectory = path.join(tempDirectory, `nextjs-sentry-wrapper-${name}`);
const wrapperDirectory = path.join(projectDirectory, "node_modules", "@sentry", "nextjs");
fs.mkdirSync(wrapperDirectory, { recursive: true });
fs.writeFileSync(
path.join(projectDirectory, "package.json"),
JSON.stringify({
name: `nextjs-sentry-wrapper-${name}`,
dependencies: { next: "^16.0.0", react: "^19.0.0", "@sentry/nextjs": "^10.0.0" },
}),
);
fs.writeFileSync(
path.join(wrapperDirectory, "package.json"),
JSON.stringify({
name: "@sentry/nextjs",
type: "module",
exports: "./index.js",
}),
);
fs.writeFileSync(
path.join(wrapperDirectory, "index.js"),
"export const withSentryConfig = (_config, _options) => ({ sentry: true });\n",
);
fs.writeFileSync(path.join(projectDirectory, "next.config.ts"), config);
if (helper) fs.writeFileSync(path.join(projectDirectory, "wrapper.ts"), helper);

expect(discoverProject(projectDirectory).hasReactCompiler).toBe(expected);
},
);

it("detects the Rsbuild React Compiler transform", () => {
const projectDirectory = path.join(tempDirectory, "rsbuild-react-compiler");
fs.mkdirSync(projectDirectory, { recursive: true });
Expand Down
22 changes: 22 additions & 0 deletions packages/core/tests/project-analysis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,28 @@ describe("analyzeProject", () => {
expect(relativePaths(rootDirectory, result.unusedFiles)).toEqual(["src/orphan.jsx"]);
});

it("treats Sanity blueprint configuration as a convention entry", async () => {
const rootDirectory = createProject(
{
"sanity.config.ts": `export default { name: "studio", title: "Studio" };`,
"sanity.blueprint.ts": `
import { defineBlueprint } from "@sanity/blueprints";
import { blueprintHelper } from "./lib/blueprint-helper";
export default defineBlueprint({
resources: blueprintHelper,
});
`,
"lib/blueprint-helper.ts": "export const blueprintHelper = [];",
"src/orphan.ts": "export const orphan = true;",
},
{ dependencies: { sanity: "1.0.0", "@sanity/blueprints": "1.0.0" } },
);

const result = await analyzeProject({ rootDirectory });

expect(relativePaths(rootDirectory, result.unusedFiles)).toEqual(["src/orphan.ts"]);
});

it("discovers static entries from CoffeeScript interpolated require factories", async () => {
const rootDirectory = createProject(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// rule: async-defer-await
// verdict: pass
// weakness: name-heuristic
// source: issue #1758

declare const refreshSession: () => Promise<boolean>;
declare const setOk: (value: boolean) => void;

const run = { live: true };

export const effect = async () => {
const refreshed = await refreshSession();
if (!run.live) return;
setOk(refreshed);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// rule: effect-needs-cleanup
// weakness: cleanup-provenance
// source: issue #1756
// verdict: pass
import { useEffect } from "react";

export const AbortHandlerCleanup = () => {
useEffect(() => {
const controller = new AbortController();
const onChange = () => {};
document.addEventListener("visibilitychange", onChange);
controller.signal.addEventListener("abort", () => {
document.removeEventListener("visibilitychange", onChange);
});
return () => controller.abort();
}, []);
return null;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// rule: effect-needs-cleanup
// weakness: cleanup-provenance
// source: issue #1756
// verdict: pass
import { useEffect } from "react";

export const ChainedTimer = () => {
useEffect(() => {
let timer: ReturnType<typeof setTimeout> | null = null;
const clearTimer = () => {
if (timer !== null) {
clearTimeout(timer);
timer = null;
}
};
const schedule = (callback: () => void) => {
timer = setTimeout(callback, 1000);
};
const advance = () => {
timer = null;
schedule(advance);
};
schedule(advance);
return () => clearTimer();
}, []);
return null;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// rule: effect-needs-cleanup
// weakness: async-lifecycle-provenance
// source: issue #1756
// verdict: pass
import { useEffect } from "react";

declare const refresh: () => Promise<void>;

export const GuardedAsyncTimer = () => {
useEffect(() => {
const run = { live: true };
let timer: ReturnType<typeof setTimeout> | null = null;
const schedule = () => {
timer = setTimeout(() => {}, 1000);
};
void (async () => {
await refresh();
if (!run.live) return;
schedule();
})();
return () => {
run.live = false;
if (timer !== null) clearTimeout(timer);
};
}, []);
return null;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// verdict: pass
// rule: nextjs-no-side-effect-in-get-handler
// weakness: copy-tracking
// source: GitHub issue #1757
// file-path: src/app/api/proxy/route.ts

const applyCachePolicy = (responseHeaders: Headers) => {
responseHeaders.set("Cache-Control", "max-age=60");
};

export const GET = () => {
const responseHeaders = new Headers();
applyCachePolicy(responseHeaders);
return new Response(null, { headers: responseHeaders });
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// verdict: pass
// rule: query-mutation-missing-invalidation
// weakness: name-heuristic
// source: GitHub issue #1759

import { useMutation } from "@tanstack/react-query";

declare const sendMagicLink: (email: string) => Promise<void>;

export const useSendMagicLink = () =>
useMutation({
mutationFn: sendMagicLink,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// verdict: pass
// rule: react-compiler-no-manual-memoization
// weakness: framework-gating
// source: GitHub issue #1749

import { useMemo } from "react";

export const LegacyComponent = () => {
"use no memo";
const cachedValue = useMemo(() => getValue(), []);
return <span>{cachedValue}</span>;
};
Loading
Loading