From 603ad42a50db2fda7c1a60a6cd23cd8d0bfa227d Mon Sep 17 00:00:00 2001 From: Brijesh Prasad Date: Sat, 15 Aug 2020 19:21:37 +0200 Subject: [PATCH 1/2] fix : grammatical typo for test description --- .../ReactHooksWithNoopRenderer-test.js | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js index 7ff61126f648a..3456dc1b74ad1 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js +++ b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js @@ -129,7 +129,7 @@ describe('ReactHooksWithNoopRenderer', () => { // Schedule some updates ReactNoop.batchedUpdates(() => { counter.current.updateCount(1); - counter.current.updateCount(count => count + 10); + counter.current.updateCount((count) => count + 10); }); // Partially flush without committing @@ -240,7 +240,7 @@ describe('ReactHooksWithNoopRenderer', () => { expect(Scheduler).toHaveYielded(['Count: 1']); expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]); - act(() => counter.current.updateCount(count => count + 10)); + act(() => counter.current.updateCount((count) => count + 10)); expect(Scheduler).toHaveYielded(['Count: 11']); expect(ReactNoop.getChildren()).toEqual([span('Count: 11')]); }); @@ -304,7 +304,7 @@ describe('ReactHooksWithNoopRenderer', () => { const secondUpdater = updater; - act(() => firstUpdater(count => count + 10)); + act(() => firstUpdater((count) => count + 10)); expect(Scheduler).toHaveYielded(['Count: 11']); expect(ReactNoop.getChildren()).toEqual([span('Count: 11')]); @@ -441,7 +441,7 @@ describe('ReactHooksWithNoopRenderer', () => { function Bar({triggerUpdate}) { if (triggerUpdate) { - setStep(x => x + 1); + setStep((x) => x + 1); } return ; } @@ -519,9 +519,9 @@ describe('ReactHooksWithNoopRenderer', () => { function Counter({row: newRow}) { const [count, setCount] = useState(0); if (count < 12) { - setCount(c => c + 1); - setCount(c => c + 1); - setCount(c => c + 1); + setCount((c) => c + 1); + setCount((c) => c + 1); + setCount((c) => c + 1); } Scheduler.unstable_yieldValue('Render: ' + count); return ; @@ -662,7 +662,7 @@ describe('ReactHooksWithNoopRenderer', () => { // Increment a counter every time the signal changes if (signal !== newSignal) { - setCounter(c => c + 1); + setCounter((c) => c + 1); setSignal(newSignal); if (counter === 0) { // We're suspending during a render that includes render phase @@ -715,7 +715,7 @@ describe('ReactHooksWithNoopRenderer', () => { // Increment a counter every time the signal changes if (signal !== newSignal) { - setCounter(c => c + 1); + setCounter((c) => c + 1); setSignal(newSignal); } @@ -796,7 +796,7 @@ describe('ReactHooksWithNoopRenderer', () => { if (counter === 0) { startTransition(() => { - setCounter(c => c + 1); + setCounter((c) => c + 1); }); } @@ -866,7 +866,7 @@ describe('ReactHooksWithNoopRenderer', () => { } function Counter(props, ref) { - const [count, dispatch] = useReducer(reducer, props, p => { + const [count, dispatch] = useReducer(reducer, props, (p) => { Scheduler.unstable_yieldValue('Init'); return p.initialCount; }); @@ -1156,7 +1156,7 @@ describe('ReactHooksWithNoopRenderer', () => { ]); }); - // This update is exists to test an internal implementation detail: + // This update exists to test an internal implementation detail: // Effects without updating dependencies lose their layout/passive tag during an update. act(() => { ReactNoop.render(, () => @@ -1297,7 +1297,7 @@ describe('ReactHooksWithNoopRenderer', () => { ]); // Update children. - setChildStates.forEach(setChildState => setChildState(1)); + setChildStates.forEach((setChildState) => setChildState(1)); expect(Scheduler).toFlushAndYieldThrough([ 'Child one render', 'Child two render', @@ -1306,7 +1306,7 @@ describe('ReactHooksWithNoopRenderer', () => { ]); // Schedule another update for children, and partially process it. - setChildStates.forEach(setChildState => setChildState(2)); + setChildStates.forEach((setChildState) => setChildState(2)); expect(Scheduler).toFlushAndYieldThrough(['Child one render']); // Schedule unmount for the parent that unmounts children with pending update. @@ -1320,7 +1320,7 @@ describe('ReactHooksWithNoopRenderer', () => { ]); // Schedule updates for children too (which should be ignored) - setChildStates.forEach(setChildState => setChildState(2)); + setChildStates.forEach((setChildState) => setChildState(2)); expect(Scheduler).toFlushAndYield([ 'Child one passive destroy', 'Child two passive destroy', @@ -2324,7 +2324,7 @@ describe('ReactHooksWithNoopRenderer', () => { let LogOnlyErrorBoundary; beforeEach(() => { - BrokenUseEffectCleanup = function() { + BrokenUseEffectCleanup = function () { useEffect(() => { Scheduler.unstable_yieldValue('BrokenUseEffectCleanup useEffect'); return () => { @@ -2812,9 +2812,10 @@ describe('ReactHooksWithNoopRenderer', () => { function Counter({incrementBy}) { const [count, updateCount] = useState(0); - const increment = useCallback(() => updateCount(c => c + incrementBy), [ - incrementBy, - ]); + const increment = useCallback( + () => updateCount((c) => c + incrementBy), + [incrementBy], + ); return ( <> @@ -2973,7 +2974,7 @@ describe('ReactHooksWithNoopRenderer', () => { let ping; function App() { ping = useDebouncedCallback( - value => { + (value) => { Scheduler.unstable_yieldValue('ping: ' + value); }, 100, From 0ce02817bf66ee18880b31df3cb1a95f0fcfdf58 Mon Sep 17 00:00:00 2001 From: Brijesh Prasad Date: Sat, 15 Aug 2020 19:31:14 +0200 Subject: [PATCH 2/2] fix linting issues --- .../ReactHooksWithNoopRenderer-test.js | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js index 3456dc1b74ad1..39ef7a2f412d7 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js +++ b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js @@ -129,7 +129,7 @@ describe('ReactHooksWithNoopRenderer', () => { // Schedule some updates ReactNoop.batchedUpdates(() => { counter.current.updateCount(1); - counter.current.updateCount((count) => count + 10); + counter.current.updateCount(count => count + 10); }); // Partially flush without committing @@ -240,7 +240,7 @@ describe('ReactHooksWithNoopRenderer', () => { expect(Scheduler).toHaveYielded(['Count: 1']); expect(ReactNoop.getChildren()).toEqual([span('Count: 1')]); - act(() => counter.current.updateCount((count) => count + 10)); + act(() => counter.current.updateCount(count => count + 10)); expect(Scheduler).toHaveYielded(['Count: 11']); expect(ReactNoop.getChildren()).toEqual([span('Count: 11')]); }); @@ -304,7 +304,7 @@ describe('ReactHooksWithNoopRenderer', () => { const secondUpdater = updater; - act(() => firstUpdater((count) => count + 10)); + act(() => firstUpdater(count => count + 10)); expect(Scheduler).toHaveYielded(['Count: 11']); expect(ReactNoop.getChildren()).toEqual([span('Count: 11')]); @@ -441,7 +441,7 @@ describe('ReactHooksWithNoopRenderer', () => { function Bar({triggerUpdate}) { if (triggerUpdate) { - setStep((x) => x + 1); + setStep(x => x + 1); } return ; } @@ -519,9 +519,9 @@ describe('ReactHooksWithNoopRenderer', () => { function Counter({row: newRow}) { const [count, setCount] = useState(0); if (count < 12) { - setCount((c) => c + 1); - setCount((c) => c + 1); - setCount((c) => c + 1); + setCount(c => c + 1); + setCount(c => c + 1); + setCount(c => c + 1); } Scheduler.unstable_yieldValue('Render: ' + count); return ; @@ -662,7 +662,7 @@ describe('ReactHooksWithNoopRenderer', () => { // Increment a counter every time the signal changes if (signal !== newSignal) { - setCounter((c) => c + 1); + setCounter(c => c + 1); setSignal(newSignal); if (counter === 0) { // We're suspending during a render that includes render phase @@ -715,7 +715,7 @@ describe('ReactHooksWithNoopRenderer', () => { // Increment a counter every time the signal changes if (signal !== newSignal) { - setCounter((c) => c + 1); + setCounter(c => c + 1); setSignal(newSignal); } @@ -796,7 +796,7 @@ describe('ReactHooksWithNoopRenderer', () => { if (counter === 0) { startTransition(() => { - setCounter((c) => c + 1); + setCounter(c => c + 1); }); } @@ -866,7 +866,7 @@ describe('ReactHooksWithNoopRenderer', () => { } function Counter(props, ref) { - const [count, dispatch] = useReducer(reducer, props, (p) => { + const [count, dispatch] = useReducer(reducer, props, p => { Scheduler.unstable_yieldValue('Init'); return p.initialCount; }); @@ -1297,7 +1297,7 @@ describe('ReactHooksWithNoopRenderer', () => { ]); // Update children. - setChildStates.forEach((setChildState) => setChildState(1)); + setChildStates.forEach(setChildState => setChildState(1)); expect(Scheduler).toFlushAndYieldThrough([ 'Child one render', 'Child two render', @@ -1306,7 +1306,7 @@ describe('ReactHooksWithNoopRenderer', () => { ]); // Schedule another update for children, and partially process it. - setChildStates.forEach((setChildState) => setChildState(2)); + setChildStates.forEach(setChildState => setChildState(2)); expect(Scheduler).toFlushAndYieldThrough(['Child one render']); // Schedule unmount for the parent that unmounts children with pending update. @@ -1320,7 +1320,7 @@ describe('ReactHooksWithNoopRenderer', () => { ]); // Schedule updates for children too (which should be ignored) - setChildStates.forEach((setChildState) => setChildState(2)); + setChildStates.forEach(setChildState => setChildState(2)); expect(Scheduler).toFlushAndYield([ 'Child one passive destroy', 'Child two passive destroy', @@ -2324,7 +2324,7 @@ describe('ReactHooksWithNoopRenderer', () => { let LogOnlyErrorBoundary; beforeEach(() => { - BrokenUseEffectCleanup = function () { + BrokenUseEffectCleanup = function() { useEffect(() => { Scheduler.unstable_yieldValue('BrokenUseEffectCleanup useEffect'); return () => { @@ -2812,10 +2812,9 @@ describe('ReactHooksWithNoopRenderer', () => { function Counter({incrementBy}) { const [count, updateCount] = useState(0); - const increment = useCallback( - () => updateCount((c) => c + incrementBy), - [incrementBy], - ); + const increment = useCallback(() => updateCount(c => c + incrementBy), [ + incrementBy, + ]); return ( <> @@ -2974,7 +2973,7 @@ describe('ReactHooksWithNoopRenderer', () => { let ping; function App() { ping = useDebouncedCallback( - (value) => { + value => { Scheduler.unstable_yieldValue('ping: ' + value); }, 100,