Skip to content

Commit f6519b6

Browse files
committed
📝 Normalize code indentation in docs
1 parent 984ee88 commit f6519b6

File tree

3 files changed

+46
-48
lines changed

3 files changed

+46
-48
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import { defineConfig } from "eslint/config";
5757
import reactNoManualMemo from 'eslint-plugin-react-no-manual-memo';
5858

5959
export default defineConfig([
60-
reactNoManualMemo.configs['flat/recommended'],
60+
reactNoManualMemo.configs['flat/recommended'],
6161
]);
6262
```
6363

@@ -94,7 +94,7 @@ Use the recommended config:
9494

9595
```json
9696
{
97-
"extends": ["plugin:react-no-manual-memo/recommended"]
97+
"extends": ["plugin:react-no-manual-memo/recommended"]
9898
}
9999
```
100100

docs/no-component-memo.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@ import * as React from 'react';
4545

4646
// React.memo wildcard import usage (auto-fixable)
4747
const MyComponent = React.memo(function ({ name, age }) {
48-
return (
49-
<div>
50-
<h1>{name}</h1>
51-
<p>Age: {age}</p>
52-
</div>
53-
);
48+
return <div>
49+
<h1>{name}</h1>
50+
<p>Age: {age}</p>
51+
</div>;
5452
});
5553
```
5654

docs/no-custom-memo-hook.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ import { useCallback } from 'react'
3737

3838
// Only uses useCallback
3939
function useCallbacks() {
40-
const handleClick = useCallback(() => {
41-
console.log('clicked')
42-
}, [])
40+
const handleClick = useCallback(() => {
41+
console.log('clicked')
42+
}, [])
4343

44-
const handleSubmit = useCallback(() => {
45-
console.log('submitted')
46-
}, [])
44+
const handleSubmit = useCallback(() => {
45+
console.log('submitted')
46+
}, [])
4747

48-
return { handleClick, handleSubmit }
48+
return { handleClick, handleSubmit }
4949
}
5050
```
5151

@@ -54,11 +54,11 @@ import * as React from 'react'
5454

5555
// Only uses useMemo
5656
function useMemoValues() {
57-
const expensiveValue = React.useMemo(() => {
58-
return calculateSomething()
59-
}, [])
57+
const expensiveValue = React.useMemo(() => {
58+
return calculateSomething()
59+
}, [])
6060

61-
return expensiveValue
61+
return expensiveValue
6262
}
6363
```
6464

@@ -67,9 +67,9 @@ import React from 'react'
6767

6868
// Uses both useCallback and useMemo but no other hooks
6969
function useMixed() {
70-
const callback = React.useCallback(() => {}, [])
71-
const value = React.useMemo(() => ({}), [])
72-
return { callback, value }
70+
const callback = React.useCallback(() => {}, [])
71+
const value = React.useMemo(() => ({}), [])
72+
return { callback, value }
7373
}
7474
```
7575

@@ -78,9 +78,9 @@ function useMixed() {
7878
```jsx
7979
// Calls no hooks at all (see top of file for note about this example)
8080
function useUtilities() {
81-
const format = (text) => text.toUpperCase()
82-
const process = (data) => data.map(x => x * 2)
83-
return { format, process }
81+
const format = (text) => text.toUpperCase()
82+
const process = (data) => data.map(x => x * 2)
83+
return { format, process }
8484
}
8585
```
8686

@@ -89,9 +89,9 @@ import { useState, useCallback } from 'react'
8989

9090
// Uses other hooks (useState) - React Compiler can optimize this
9191
function useCounter() {
92-
const [count, setCount] = useState(0)
93-
const increment = useCallback(() => setCount(c => c + 1), [])
94-
return { count, increment }
92+
const [count, setCount] = useState(0)
93+
const increment = useCallback(() => setCount(c => c + 1), [])
94+
return { count, increment }
9595
}
9696
```
9797

@@ -100,19 +100,19 @@ import { useState, useMemo, useEffect } from 'react'
100100

101101
// Uses useEffect - React Compiler can optimize this
102102
function useWindowSize() {
103-
const [size, setSize] = useState({ width: 0, height: 0 })
104-
105-
useEffect(() => {
106-
const handler = () => setSize({
107-
width: window.innerWidth,
108-
height: window.innerHeight
109-
})
110-
window.addEventListener('resize', handler)
111-
return () => window.removeEventListener('resize', handler)
112-
}, [])
113-
114-
const memoizedSize = useMemo(() => size, [size])
115-
return memoizedSize
103+
const [size, setSize] = useState({ width: 0, height: 0 })
104+
105+
useEffect(() => {
106+
const handler = () => setSize({
107+
width: window.innerWidth,
108+
height: window.innerHeight
109+
})
110+
window.addEventListener('resize', handler)
111+
return () => window.removeEventListener('resize', handler)
112+
}, [])
113+
114+
const memoizedSize = useMemo(() => size, [size])
115+
return memoizedSize
116116
}
117117
```
118118

@@ -121,11 +121,11 @@ import { useCallback } from 'react'
121121

122122
// Contains JSX - different use case
123123
function useButton() {
124-
const handleClick = useCallback(() => {
125-
console.log('clicked')
126-
}, [])
124+
const handleClick = useCallback(() => {
125+
console.log('clicked')
126+
}, [])
127127

128-
return <button onClick={handleClick}>Click me</button>
128+
return <button onClick={handleClick}>Click me</button>
129129
}
130130
```
131131

@@ -137,9 +137,9 @@ function useButton() {
137137
```jsx
138138
import { useCallback } from 'react'
139139
function createHelpers() {
140-
const helper1 = useCallback(() => {}, [])
141-
const helper2 = useMemo(() => ({}), [])
142-
return { helper1, helper2 }
140+
const helper1 = useCallback(() => {}, [])
141+
const helper2 = useMemo(() => ({}), [])
142+
return { helper1, helper2 }
143143
}
144144
```
145145

0 commit comments

Comments
 (0)