Commit Graph

7032 Commits

Author SHA1 Message Date
Lauren Tan
1d1272a7e1 merge commit for archive created by Sapling 2025-09-18 19:03:41 -04:00
Lauren Tan
9b611e568d Restore lint corrections from #7989
Reverts the revert now that we've fixed the bug. These pages should no longer crash:

https://react-dev-git-pr7997-fbopensource.vercel.app/learn/referencing-values-with-refs
https://react-dev-git-pr7997-fbopensource.vercel.app/learn/synchronizing-with-effects
https://react-dev-git-pr7997-fbopensource.vercel.app/learn/separating-events-from-effects
https://react-dev-git-pr7997-fbopensource.vercel.app/learn/removing-effect-dependencies
https://react-dev-git-pr7997-fbopensource.vercel.app/learn/you-might-not-need-an-effect
2025-09-18 19:03:33 -04:00
Lauren Tan
a53abd2151 Ignore braces when building Sandpack file map
Previously, `createFileMap` split the MDX meta string on spaces and assumed the first token was the filename. Once we prefixed code fences with `{expectedErrors: ...}`, it would incorrectly parse the meta and crash.

This PR updates createFileMap to skip tokens in the meta containing a start and end brace pair (using a stack to ensure we close on the correct brace) while tokenizing the meta string as expected.

Test plan: pages reported in #7994 no longer crash on the next PR

Closes #7994
2025-09-18 19:03:33 -04:00
lauren
087b8d4a83 Merge 2cb3cbcaa5 into sapling-pr-archive-poteto 2025-09-18 18:51:13 -04:00
Lauren Tan
2cb3cbcaa5 Restore lint corrections from #7989
Reverts the revert now that we've fixed the bug. These pages should no longer crash:

/learn/referencing-values-with-refs
/learn/synchronizing-with-effects
/learn/separating-events-from-effects
/learn/removing-effect-dependencies
2025-09-18 18:51:08 -04:00
Lauren Tan
5f46bfb0e6 Ignore braces when building Sandpack file map
Previously, `createFileMap` split the MDX meta string on spaces and assumed the first token was the filename. Once we prefixed code fences with `{expectedErrors: …}`, it would incorrectly parse the meta and crash.

This PR updates createFileMap to skip tokens in the meta containing a start and end brace pair (using a stack to ensure we close on the correct brace) while tokenizing the meta string as expected.

I also added a fallback that was previously not handled if the filepath was undefined.

Test plan: pages reported in #7994 no longer crash on the next PR

Closes #7994
2025-09-18 18:51:08 -04:00
Lauren Tan
21daaa9f88 merge commit for archive created by Sapling 2025-09-18 18:50:14 -04:00
Lauren Tan
048837352a Restore lint corrections from #7989
Reverts the revert now that we've fixed the bug. These pages should no longer crash:

/learn/referencing-values-with-refs
/learn/synchronizing-with-effects
/learn/separating-events-from-effects
/learn/removing-effect-dependencies
2025-09-18 18:50:07 -04:00
Lauren Tan
0c749a8a6e Ignore braces when building Sandpack file map
Previously, `createFileMap` split the MDX meta string on spaces and assumed the first token was the filename. Once we prefixed code fences with `{expectedErrors: …}`, it would incorrectly parse the meta and crash.

This PR updates createFileMap to skip tokens in the meta containing a start and end brace pair (using a stack to ensure we close on the correct brace) while tokenizing the meta string as expected.

Test plan: pages reported in #7994 no longer crash on the next PR

Closes #7994
2025-09-18 18:50:07 -04:00
lauren
83c50b8934 Merge a682a405ca into sapling-pr-archive-poteto 2025-09-18 18:49:21 -04:00
Lauren Tan
a682a405ca Restore lint corrections from #7989
Reverts the revert now that we've fixed the bug. These pages should no longer crash:

/learn/referencing-values-with-refs
/learn/synchronizing-with-effects
/learn/separating-events-from-effects
/learn/removing-effect-dependencies
2025-09-18 18:49:07 -04:00
Lauren Tan
54028c9f3c Ignore braces when building Sandpack file map
Previously, `createFileMap` split the MDX meta string on spaces and assumed the first token was the filename. Once we prefixed code fences with `{expectedErrors: …}`, it would incorrectly parse the meta and crash.

This PR updates createFileMap to skip tokens in the meta containing a start and end brace pair (using a stack to ensure we close on the correct brace) while tokenizing the meta string as expected.

Test plan: pages reported in #7994 no longer crash on the next PR

Closes #7994
2025-09-18 18:48:04 -04:00
lauren
2a9ef2d173 Revert "fix compiler errors (#7989)" (#7995)
This reverts commit 5cc9b7ba31.
2025-09-18 18:06:43 -04:00
lauren
2db3e5062c Merge 774f317236 into sapling-pr-archive-poteto 2025-09-18 18:03:20 -04:00
Lauren Tan
774f317236 Revert "fix compiler errors (#7989)"
This reverts commit 5cc9b7ba31.
2025-09-18 18:03:00 -04:00
lauren
dc236baf29 Merge c2b891da68 into sapling-pr-archive-poteto 2025-09-18 15:59:06 -04:00
Lauren Tan
c2b891da68 Install eslint-local-rules as postinstall
For local dev and CI we want to have the eslint-local-rules running, so let's make sure both have their dependencies installed. We don't use a monorepo setup here, which is why they're currently setup as a two completely independent yarn workspaces.
2025-09-18 15:59:01 -04:00
lauren
5cc9b7ba31 fix compiler errors (#7989)
* Add local eslint rule to validate markdown codeblocks with React Compiler

In https://github.com/facebook/react/pull/34462 for example, we found an issue where the compiler was incorrectly validating an example straight from the docs.

In order to find more issues like this + also provide more feedback to doc authors on valid/invalid patterns, this PR adds a new local eslint rule which validates all markdown codeblocks containing components/hooks with React Compiler. An autofixer is also provided.

To express that a codeblock has an expected error, we can use the following metadata:

```ts
// pseudo type def
type MarkdownCodeBlockMetadata = {
    expectedErrors?: {
      'react-compiler'?: number[];
    };
  };
```

and can be used like so:

````
```js {expectedErrors: {'react-compiler': [4]}}
//  setState directly in render
function Component({value}) {
  const [count, setCount] = useState(0);
  setCount(value); // error on L4
  return <div>{count}</div>;
}
```
````

Because this is defined as a local rule, we don't have the same granular reporting that `eslint-plugin-react-hooks` yet. I can look into that later but for now this first PR just sets us up with something basic.

* fix compiler errors

I went through the list of existing errors and tried to separate the expected errors from those that seem to be flagging unexpected issues.  In particular, our effects validations are flagging patterns that our own docs examples use. I added todos for these and will follow up later.
2025-09-18 15:32:27 -04:00
lauren
b6a32d1e0e Add local eslint rule to validate markdown codeblocks with React Compiler (#7988)
In https://github.com/facebook/react/pull/34462 for example, we found an issue where the compiler was incorrectly validating an example straight from the docs.

In order to find more issues like this + also provide more feedback to doc authors on valid/invalid patterns, this PR adds a new local eslint rule which validates all markdown codeblocks containing components/hooks with React Compiler. An autofixer is also provided.

To express that a codeblock has an expected error, we can use the following metadata:

```ts
// pseudo type def
type MarkdownCodeBlockMetadata = {
    expectedErrors?: {
      'react-compiler'?: number[];
    };
  };
```

and can be used like so:

````
```js {expectedErrors: {'react-compiler': [4]}}
//  setState directly in render
function Component({value}) {
  const [count, setCount] = useState(0);
  setCount(value); // error on L4
  return <div>{count}</div>;
}
```
````

Because this is defined as a local rule, we don't have the same granular reporting that `eslint-plugin-react-hooks` yet. I can look into that later but for now this first PR just sets us up with something basic.
2025-09-18 15:32:18 -04:00
lauren
98dc4a78f1 Merge bb4d30a556 into sapling-pr-archive-poteto 2025-09-18 15:22:17 -04:00
Lauren Tan
bb4d30a556 Add new eslint rule reference docs
Adds new docs for our new eslint rules.
2025-09-18 15:22:09 -04:00
Lauren Tan
454dfce662 fix compiler errors
I went through the list of existing errors and tried to separate the expected errors from those that seem to be flagging unexpected issues.  In particular, our effects validations are flagging patterns that our own docs examples use. I added todos for these and will follow up later.
2025-09-18 15:22:08 -04:00
Lauren Tan
7cd991fce4 Add local eslint rule to validate markdown codeblocks with React Compiler
In https://github.com/facebook/react/pull/34462 for example, we found an issue where the compiler was incorrectly validating an example straight from the docs.

In order to find more issues like this + also provide more feedback to doc authors on valid/invalid patterns, this PR adds a new local eslint rule which validates all markdown codeblocks containing components/hooks with React Compiler. An autofixer is also provided.

To express that a codeblock has an expected error, we can use the following metadata:

```ts
// pseudo type def
type MarkdownCodeBlockMetadata = {
    expectedErrors?: {
      'react-compiler'?: number[];
    };
  };
```

and can be used like so:

````
```js {expectedErrors: {'react-compiler': [4]}}
//  setState directly in render
function Component({value}) {
  const [count, setCount] = useState(0);
  setCount(value); // error on L4
  return <div>{count}</div>;
}
```
````

Because this is defined as a local rule, we don't have the same granular reporting that `eslint-plugin-react-hooks` yet. I can look into that later but for now this first PR just sets us up with something basic.
2025-09-18 15:22:08 -04:00
lauren
bd03b86c02 Update copyright on all files (#7992)
* Add copyright script

Copied over our copyright script from the react repo. I made a small fix to handle shebangs.

* Update copyright on all files

Run the script.
2025-09-18 14:42:36 -04:00
lauren
a566d87b2b Add copyright script (#7991)
Copied over our copyright script from the react repo. I made a small fix to handle shebangs.
2025-09-18 14:42:27 -04:00
Lauren Tan
e87ac94e12 merge commit for archive created by Sapling 2025-09-18 13:14:38 -04:00
Lauren Tan
d71abeef64 Add new eslint rule reference docs
Adds new docs for our new eslint rules.
2025-09-18 13:14:30 -04:00
Lauren Tan
c0956c37ad fix compiler errors
I went through the list of existing errors and tried to separate the expected errors from those that seem to be flagging unexpected issues.  In particular, our effects validations are flagging patterns that our own docs examples use. I added todos for these and will follow up later.
2025-09-18 13:14:29 -04:00
Lauren Tan
01e40bb590 Add local eslint rule to validate markdown codeblocks with React Compiler
In https://github.com/facebook/react/pull/34462 for example, we found an issue where the compiler was incorrectly validating an example straight from the docs.

In order to find more issues like this + also provide more feedback to doc authors on valid/invalid patterns, this PR adds a new local eslint rule which validates all markdown codeblocks containing components/hooks with React Compiler. An autofixer is also provided.

To express that a codeblock has an expected error, we can use the following metadata:

```ts
// pseudo type def
type MarkdownCodeBlockMetadata = {
    expectedErrors?: {
      'react-compiler'?: number[];
    };
  };
```

and can be used like so:

````
```js {expectedErrors: {'react-compiler': [4]}}
//  setState directly in render
function Component({value}) {
  const [count, setCount] = useState(0);
  setCount(value); // error on L4
  return <div>{count}</div>;
}
```
````

Because this is defined as a local rule, we don't have the same granular reporting that `eslint-plugin-react-hooks` yet. I can look into that later but for now this first PR just sets us up with something basic.
2025-09-18 13:04:13 -04:00
Lauren Tan
c9c7a50b7a Update copyright on all files
Run the script.
2025-09-18 13:04:13 -04:00
Lauren Tan
813a3fdf60 Add copyright script
Copied over our copyright script from the react repo. I made a small fix to handle shebangs.
2025-09-18 13:04:13 -04:00
Lauren Tan
780bfba863 merge commit for archive created by Sapling 2025-09-18 12:40:26 -04:00
Lauren Tan
d95973d6c2 Add new eslint rule reference docs
Adds new docs for our new eslint rules.
2025-09-18 12:40:04 -04:00
Lauren Tan
1195dccb7a fix compiler errors
I went through the list of existing errors and tried to separate the expected errors from those that seem to be flagging unexpected issues.  In particular, our effects validations are flagging patterns that our own docs examples use. I added todos for these and will follow up later.
2025-09-18 12:40:04 -04:00
Lauren Tan
20da2770e6 Add local eslint rule to validate markdown codeblocks with React Compiler
In https://github.com/facebook/react/pull/34462 for example, we found an issue where the compiler was incorrectly validating an example straight from the docs.

In order to find more issues like this + also provide more feedback to doc authors on valid/invalid patterns, this PR adds a new local eslint rule which validates all markdown codeblocks containing components/hooks with React Compiler. An autofixer is also provided.

To express that a codeblock has an expected error, we can use the following metadata:

```ts
// pseudo type def
type MarkdownCodeBlockMetadata = {
    expectedErrors?: {
      'react-compiler'?: number[];
    };
  };
```

and can be used like so:

````
```js {expectedErrors: {'react-compiler': [4]}}
//  setState directly in render
function Component({value}) {
  const [count, setCount] = useState(0);
  setCount(value); // error on L4
  return <div>{count}</div>;
}
```
````

Because this is defined as a local rule, we don't have the same granular reporting that `eslint-plugin-react-hooks` yet. I can look into that later but for now this first PR just sets us up with something basic.
2025-09-18 12:40:03 -04:00
Lauren Tan
68fece54b3 Update copyright on all files
Run the script.
2025-09-18 12:39:04 -04:00
Lauren Tan
805d629ac0 Add copyright script
Copied over our copyright script from the react repo.
2025-09-18 12:38:40 -04:00
lauren
925f9d8b4c Merge f6ed6c5427 into sapling-pr-archive-poteto 2025-09-17 14:09:31 -04:00
Lauren Tan
f6ed6c5427 Add new eslint rule reference docs
Adds new docs for our new eslint rules.
2025-09-17 14:09:25 -04:00
Lauren Tan
e565ef3392 fix compiler errors
I went through the list of existing errors and tried to separate the expected errors from those that seem to be flagging unexpected issues.  In particular, our effects validations are flagging patterns that our own docs examples use. I added todos for these and will follow up later.
2025-09-17 14:09:25 -04:00
Lauren Tan
bc05be3aa8 Add local eslint rule to validate markdown codeblocks with React Compiler
In https://github.com/facebook/react/pull/34462 for example, we found an issue where the compiler was incorrectly validating an example straight from the docs.

In order to find more issues like this + also provide more feedback to doc authors on valid/invalid patterns, this PR adds a new local eslint rule which validates all markdown codeblocks containing components/hooks with React Compiler. An autofixer is also provided.

To express that a codeblock has an expected error, we can use the following metadata:

```ts
// pseudo type def
type MarkdownCodeBlockMetadata = {
    expectedErrors?: {
      'react-compiler'?: number[];
    };
  };
```

and can be used like so:

````
```js {expectedErrors: {'react-compiler': [4]}}
//  setState directly in render
function Component({value}) {
  const [count, setCount] = useState(0);
  setCount(value); // error on L4
  return <div>{count}</div>;
}
```
````

Because this is defined as a local rule, we don't have the same granular reporting that `eslint-plugin-react-hooks` yet. I can look into that later but for now this first PR just sets us up with something basic.
2025-09-17 14:09:24 -04:00
Lauren Tan
0b7ee53fe1 merge commit for archive created by Sapling 2025-09-17 14:03:18 -04:00
Lauren Tan
628bb54fe9 Add new eslint rule reference docs
Adds new docs for our new eslint rules.
2025-09-17 14:03:10 -04:00
Lauren Tan
de8de8993f fix compiler errors
I went through the list of existing errors and tried to separate the expected errors from those that seem to be flagging unexpected issues.  In particular, our effects validations are flagging patterns that our own docs examples use. I added todos for these and will follow up later.
2025-09-17 14:03:10 -04:00
Lauren Tan
56be564bb6 Add local eslint rule to validate markdown codeblocks with React Compiler
In https://github.com/facebook/react/pull/34462 for example, we found an issue where the compiler was incorrectly validating an example straight from the docs.

In order to find more issues like this + also provide more feedback to doc authors on valid/invalid patterns, this PR adds a new local eslint rule which validates all markdown codeblocks containing components/hooks with React Compiler. An autofixer is also provided.

To express that a codeblock has an expected error, we can use the following metadata:

```ts
// pseudo type def
type MarkdownCodeBlockMetadata = {
    expectedErrors?: {
      'react-compiler'?: number[];
    };
  };
```

and can be used like so:

````
```js {expectedErrors: {'react-compiler': [4]}}
//  setState directly in render
function Component({value}) {
  const [count, setCount] = useState(0);
  setCount(value); // error on L4
  return <div>{count}</div>;
}
```
````

Because this is defined as a local rule, we don't have the same granular reporting that `eslint-plugin-react-hooks` yet. I can look into that later but for now this first PR just sets us up with something basic.
2025-09-17 14:03:09 -04:00
lauren
742186b566 Merge 731ecd139d into sapling-pr-archive-poteto 2025-09-17 13:18:29 -04:00
Lauren Tan
731ecd139d Add new eslint rule reference docs
Adds new docs for our new eslint rules.
2025-09-17 13:18:20 -04:00
Lauren Tan
02993b7ffb fix compiler errors
I went through the list of existing errors and tried to separate the expected errors from those that seem to be flagging unexpected issues.  In particular, our effects validations are flagging patterns that our own docs examples use. I added todos for these and will follow up later.
2025-09-17 13:18:19 -04:00
Lauren Tan
d0c75e6c81 merge commit for archive created by Sapling 2025-09-17 13:11:07 -04:00
Lauren Tan
757666abf0 Add new eslint rule reference docs
Adds new docs for our new eslint rules.
2025-09-17 13:10:58 -04:00