diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-jsx-memberexpr-tag-in-lambda.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-jsx-memberexpr-tag-in-lambda.expect.md new file mode 100644 index 0000000000..5030bbb431 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-jsx-memberexpr-tag-in-lambda.expect.md @@ -0,0 +1,52 @@ + +## Input + +```javascript +import * as SharedRuntime from "shared-runtime"; +function useFoo() { + const MyLocal = SharedRuntime; + const callback = () => { + return ; + }; + return callback(); +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [], +}; + +``` + +## Code + +```javascript +import { unstable_useMemoCache as useMemoCache } from "react"; +import * as SharedRuntime from "shared-runtime"; +function useFoo() { + const $ = useMemoCache(2); + let t0; + if ($[0] === Symbol.for("react.memo_cache_sentinel")) { + t0 = () => ; + $[0] = t0; + } else { + t0 = $[0]; + } + const callback = t0; + let t1; + if ($[1] === Symbol.for("react.memo_cache_sentinel")) { + t1 = callback(); + $[1] = t1; + } else { + t1 = $[1]; + } + return t1; +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [], +}; + +``` + \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-jsx-memberexpr-tag-in-lambda.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-jsx-memberexpr-tag-in-lambda.js new file mode 100644 index 0000000000..806b684745 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-jsx-memberexpr-tag-in-lambda.js @@ -0,0 +1,13 @@ +import * as SharedRuntime from "shared-runtime"; +function useFoo() { + const MyLocal = SharedRuntime; + const callback = () => { + return ; + }; + return callback(); +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [], +}; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag-conditional.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag-conditional.expect.md new file mode 100644 index 0000000000..f55090eb48 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag-conditional.expect.md @@ -0,0 +1,53 @@ + +## Input + +```javascript +import * as SharedRuntime from "shared-runtime"; +function useFoo({ cond }) { + const MyLocal = SharedRuntime; + if (cond) { + return ; + } else { + return null; + } +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [{ cond: true }], +}; + +``` + +## Code + +```javascript +import { unstable_useMemoCache as useMemoCache } from "react"; +import * as SharedRuntime from "shared-runtime"; +function useFoo(t12) { + const $ = useMemoCache(1); + const { cond } = t12; + const MyLocal = SharedRuntime; + if (cond) { + let t0; + if ($[0] === Symbol.for("react.memo_cache_sentinel")) { + t0 = ; + $[0] = t0; + } else { + t0 = $[0]; + } + return t0; + } else { + return null; + } +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [{ cond: true }], +}; + +``` + +### Eval output +(kind: ok)
4
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag-conditional.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag-conditional.js new file mode 100644 index 0000000000..bf74af2bec --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag-conditional.js @@ -0,0 +1,14 @@ +import * as SharedRuntime from "shared-runtime"; +function useFoo({ cond }) { + const MyLocal = SharedRuntime; + if (cond) { + return ; + } else { + return null; + } +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [{ cond: true }], +}; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag.expect.md new file mode 100644 index 0000000000..1a9c5e96c1 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag.expect.md @@ -0,0 +1,44 @@ + +## Input + +```javascript +import * as SharedRuntime from "shared-runtime"; +function useFoo() { + const MyLocal = SharedRuntime; + return ; +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [], +}; + +``` + +## Code + +```javascript +import { unstable_useMemoCache as useMemoCache } from "react"; +import * as SharedRuntime from "shared-runtime"; +function useFoo() { + const $ = useMemoCache(1); + const MyLocal = SharedRuntime; + let t0; + if ($[0] === Symbol.for("react.memo_cache_sentinel")) { + t0 = ; + $[0] = t0; + } else { + t0 = $[0]; + } + return t0; +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [], +}; + +``` + +### Eval output +(kind: ok)
4
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag.js new file mode 100644 index 0000000000..98a62e29e7 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-memberexpr-tag.js @@ -0,0 +1,10 @@ +import * as SharedRuntime from "shared-runtime"; +function useFoo() { + const MyLocal = SharedRuntime; + return ; +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [], +}; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-tag-in-lambda.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-tag-in-lambda.expect.md new file mode 100644 index 0000000000..665334275f --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-tag-in-lambda.expect.md @@ -0,0 +1,54 @@ + +## Input + +```javascript +import { Stringify } from "shared-runtime"; +function useFoo() { + const MyLocal = Stringify; + const callback = () => { + return ; + }; + return callback(); +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [], +}; + +``` + +## Code + +```javascript +import { unstable_useMemoCache as useMemoCache } from "react"; +import { Stringify } from "shared-runtime"; +function useFoo() { + const $ = useMemoCache(2); + let t0; + if ($[0] === Symbol.for("react.memo_cache_sentinel")) { + t0 = () => ; + $[0] = t0; + } else { + t0 = $[0]; + } + const callback = t0; + let t1; + if ($[1] === Symbol.for("react.memo_cache_sentinel")) { + t1 = callback(); + $[1] = t1; + } else { + t1 = $[1]; + } + return t1; +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [], +}; + +``` + +### Eval output +(kind: ok)
{"value":4}
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-tag-in-lambda.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-tag-in-lambda.js new file mode 100644 index 0000000000..504b4f6cea --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-local-tag-in-lambda.js @@ -0,0 +1,13 @@ +import { Stringify } from "shared-runtime"; +function useFoo() { + const MyLocal = Stringify; + const callback = () => { + return ; + }; + return callback(); +} + +export const FIXTURE_ENTRYPOINT = { + fn: useFoo, + params: [], +}; diff --git a/compiler/packages/sprout/src/SproutTodoFilter.ts b/compiler/packages/sprout/src/SproutTodoFilter.ts index ecaec958b4..14c79e8a96 100644 --- a/compiler/packages/sprout/src/SproutTodoFilter.ts +++ b/compiler/packages/sprout/src/SproutTodoFilter.ts @@ -510,6 +510,9 @@ const skipFilter = new Set([ "todo.unnecessary-lambda-memoization", "rules-of-hooks/rules-of-hooks-93dc5d5e538a", "rules-of-hooks/rules-of-hooks-69521d94fa03", + + // bug + "bug-jsx-memberexpr-tag-in-lambda", ]); export default skipFilter;