From bf64a826a4881d9ee25500e7cdab416797e12aab Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Wed, 13 Mar 2024 14:54:35 -0700 Subject: [PATCH] Repro for fbt with unexpected child count --- ...with-additional-whitespace-child.expect.md | 31 +++++++++++++++++++ ...do-fbt-with-additional-whitespace-child.js | 10 ++++++ 2 files changed, 41 insertions(+) create mode 100644 compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-fbt-with-additional-whitespace-child.expect.md create mode 100644 compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-fbt-with-additional-whitespace-child.js diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-fbt-with-additional-whitespace-child.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-fbt-with-additional-whitespace-child.expect.md new file mode 100644 index 0000000000..4bfe9a4fea --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-fbt-with-additional-whitespace-child.expect.md @@ -0,0 +1,31 @@ + +## Input + +```javascript +function Component(props) { + return ( + + + vote + {" "} + for {props.option} + + ); +} + +``` + + +## Error + +``` + 5 | vote + 6 | {" "} +> 7 | for {props.option} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ReactForget] Invariant: Expected fbt element to have 3 children (whitespace, content, whitespace) or 1 (content) (7:7) + 8 | + 9 | ); + 10 | } +``` + + \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-fbt-with-additional-whitespace-child.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-fbt-with-additional-whitespace-child.js new file mode 100644 index 0000000000..2624d1dae4 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-fbt-with-additional-whitespace-child.js @@ -0,0 +1,10 @@ +function Component(props) { + return ( + + + vote + {" "} + for {props.option} + + ); +}