Skip to content

Commit a682a40

Browse files
committed
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
1 parent 54028c9 commit a682a40

26 files changed

+109
-99
lines changed

src/content/learn/describing-the-ui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ By strictly only writing your components as pure functions, you can avoid an ent
474474

475475
<Sandpack>
476476

477-
```js
477+
```js {expectedErrors: {'react-compiler': [5]}}
478478
let guest = 0;
479479

480480
function Cup() {

src/content/learn/escape-hatches.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ There are two common cases in which you don't need Effects:
201201

202202
For example, you don't need an Effect to adjust some state based on other state:
203203

204-
```js {5-9}
204+
```js {expectedErrors: {'react-compiler': [8]}} {5-9}
205205
function Form() {
206206
const [firstName, setFirstName] = useState('Taylor');
207207
const [lastName, setLastName] = useState('Swift');

src/content/learn/keeping-components-pure.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Here is a component that breaks this rule:
9393

9494
<Sandpack>
9595

96-
```js
96+
```js {expectedErrors: {'react-compiler': [5]}}
9797
let guest = 0;
9898

9999
function Cup() {
@@ -380,7 +380,7 @@ The buggy code is in `Profile.js`. Make sure you read it all from top to bottom!
380380

381381
<Sandpack>
382382

383-
```js src/Profile.js
383+
```js {expectedErrors: {'react-compiler': [7]}} src/Profile.js
384384
import Panel from './Panel.js';
385385
import { getImageUrl } from './utils.js';
386386

@@ -602,7 +602,7 @@ export default function StoryTray({ stories }) {
602602
}
603603
```
604604

605-
```js src/App.js hidden
605+
```js {expectedErrors: {'react-compiler': [16]}} src/App.js hidden
606606
import { useState, useEffect } from 'react';
607607
import StoryTray from './StoryTray.js';
608608

@@ -698,7 +698,7 @@ export default function StoryTray({ stories }) {
698698
}
699699
```
700700

701-
```js src/App.js hidden
701+
```js {expectedErrors: {'react-compiler': [16]}} src/App.js hidden
702702
import { useState, useEffect } from 'react';
703703
import StoryTray from './StoryTray.js';
704704

@@ -790,7 +790,7 @@ export default function StoryTray({ stories }) {
790790
}
791791
```
792792

793-
```js src/App.js hidden
793+
```js {expectedErrors: {'react-compiler': [16]}} src/App.js hidden
794794
import { useState, useEffect } from 'react';
795795
import StoryTray from './StoryTray.js';
796796

src/content/learn/lifecycle-of-reactive-effects.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ If you see a linter rule being suppressed, remove the suppression! That's where
11311131
11321132
<Sandpack>
11331133
1134-
```js
1134+
```js {expectedErrors: {'react-compiler': [16]}}
11351135
import { useState, useEffect } from 'react';
11361136

11371137
export default function App() {
@@ -1374,7 +1374,7 @@ export default function App() {
13741374
}
13751375
```
13761376
1377-
```js src/ChatRoom.js active
1377+
```js {expectedErrors: {'react-compiler': [8]}} src/ChatRoom.js active
13781378
import { useState, useEffect } from 'react';
13791379

13801380
export default function ChatRoom({ roomId, createConnection }) {

src/content/learn/preserving-and-resetting-state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ Here, the `MyTextField` component function is defined *inside* `MyComponent`:
704704

705705
<Sandpack>
706706

707-
```js
707+
```js {expectedErrors: {'react-compiler': [7]}}
708708
import { useState } from 'react';
709709

710710
export default function MyComponent() {

src/content/learn/react-compiler/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ React Compiler automatically optimizes your React application at build time. Rea
2828

2929
Without the compiler, you need to manually memoize components and values to optimize re-renders:
3030

31-
```js
31+
```js {expectedErrors: {'react-compiler': [4]}}
3232
import { useMemo, useCallback, memo } from 'react';
3333

3434
const ExpensiveComponent = memo(function ExpensiveComponent({ data, onClick }) {

src/content/learn/referencing-values-with-refs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ If you tried to implement this with a ref, React would never re-render the compo
211211

212212
<Sandpack>
213213

214-
```js
214+
```js {expectedErrors: {'react-compiler': [13]}}
215215
import { useRef } from 'react';
216216

217217
export default function Counter() {
@@ -313,7 +313,7 @@ Regular variables like `let timeoutID` don't "survive" between re-renders becaus
313313

314314
<Sandpack>
315315

316-
```js
316+
```js {expectedErrors: {'react-compiler': [10]}}
317317
import { useState } from 'react';
318318

319319
export default function Chat() {
@@ -418,7 +418,7 @@ This button is supposed to toggle between showing "On" and "Off". However, it al
418418

419419
<Sandpack>
420420

421-
```js
421+
```js {expectedErrors: {'react-compiler': [10]}}
422422
import { useRef } from 'react';
423423

424424
export default function Toggle() {

src/content/learn/removing-effect-dependencies.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Suppressing the linter leads to very unintuitive bugs that are hard to find and
303303
304304
<Sandpack>
305305
306-
```js
306+
```js {expectedErrors: {'react-compiler': [14]}}
307307
import { useState, useEffect } from 'react';
308308

309309
export default function Timer() {
@@ -794,7 +794,7 @@ It is important to declare it as a dependency! This ensures, for example, that i
794794
795795
<Sandpack>
796796
797-
```js
797+
```js {expectedErrors: {'react-compiler': [10]}}
798798
import { useState, useEffect } from 'react';
799799
import { createConnection } from './chat.js';
800800

src/content/learn/responding-to-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ Clicking this button is supposed to switch the page background between white and
546546
547547
<Sandpack>
548548
549-
```js
549+
```js {expectedErrors: {'react-compiler': [5, 7]}}
550550
export default function LightSwitch() {
551551
function handleClick() {
552552
let bodyStyle = document.body.style;

src/content/learn/separating-events-from-effects.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ Here, `url` inside `onVisit` corresponds to the *latest* `url` (which could have
711711
712712
In the existing codebases, you may sometimes see the lint rule suppressed like this:
713713
714-
```js {7-9}
714+
```js {expectedErrors: {'react-compiler': [8]}} {7-9}
715715
function Page({ url }) {
716716
const { items } = useContext(ShoppingCartContext);
717717
const numberOfItems = items.length;
@@ -735,7 +735,7 @@ Can you see why?
735735
736736
<Sandpack>
737737
738-
```js
738+
```js {expectedErrors: {'react-compiler': [16]}}
739739
import { useState, useEffect } from 'react';
740740

741741
export default function App() {
@@ -990,7 +990,7 @@ To fix this code, it's enough to follow the rules.
990990
```
991991
992992
993-
```js
993+
```js {expectedErrors: {'react-compiler': [14]}}
994994
import { useState, useEffect } from 'react';
995995

996996
export default function Timer() {

0 commit comments

Comments
 (0)