|
61 | 61 | 30. [서버 로딩 중일 때 Fallback UI를 선언적으로 보여주기 위한 Suspense](#suspense) |
62 | 62 | 31. [앱 전체에 동일한 쿼리 함수를 공유하는 Default Query Function](#default-query-function) |
63 | 63 | 32. [리액트 쿼리에 타입스크립트 적용](#react-query-typescript) |
64 | | -33. [리액트 쿼리 지원 버전](#지원-버전) |
| 64 | +33. [리액트 쿼리 ESLint 적용](#react-query-eslint-plugin) |
| 65 | +34. [리액트 쿼리 지원 버전](#지원-버전) |
65 | 66 |
|
66 | 67 | <br /> |
67 | 68 |
|
@@ -1447,7 +1448,9 @@ const queryClient = new QueryClient({ |
1447 | 1448 | }); |
1448 | 1449 |
|
1449 | 1450 | function App() { |
1450 | | - return <QueryClientProvider client={queryClient}>{/* ... */}</QueryClientProvider>; |
| 1451 | + return ( |
| 1452 | + <QueryClientProvider client={queryClient}>{/* ... */}</QueryClientProvider> |
| 1453 | + ); |
1451 | 1454 | } |
1452 | 1455 | ``` |
1453 | 1456 |
|
@@ -1657,6 +1660,62 @@ const { data } = useQuery({ |
1657 | 1660 |
|
1658 | 1661 | <br /> |
1659 | 1662 |
|
| 1663 | +## React Query ESLint Plugin |
| 1664 | + |
| 1665 | +[목차 이동](#주요-컨셉-및-가이드-목차) |
| 1666 | + |
| 1667 | +- Tanstack Query는 `자체 ESLint Plugin`을 제공합니다. 해당 플러그인을 통해 모범 사례를 적용하고, 일반적인 실수를 방지할 수 있습니다. |
| 1668 | + |
| 1669 | +### 설치 |
| 1670 | + |
| 1671 | +```bash |
| 1672 | +$ npm i -D @tanstack/eslint-plugin-query |
| 1673 | +# or |
| 1674 | +$ pnpm add -D @tanstack/eslint-plugin-query |
| 1675 | +# or |
| 1676 | +$ yarn add -D @tanstack/eslint-plugin-query |
| 1677 | +# or |
| 1678 | +$ bun add -D @tanstack/eslint-plugin-query |
| 1679 | +``` |
| 1680 | + |
| 1681 | +<br /> |
| 1682 | + |
| 1683 | +### 사용 방법(1) |
| 1684 | + |
| 1685 | +- 플러그인에 대한 `권장하는 모든 rule`을 적용하려면 아래와 같이 `.eslintrc.js` 파일 `extends`배열 안에 `plugin:@tanstack/eslint-plugin-query/recommended`을 추가합니다. |
| 1686 | + |
| 1687 | +```js |
| 1688 | +module.exports = { |
| 1689 | + // ... |
| 1690 | + extends: ["plugin:@tanstack/eslint-plugin-query/recommended"], |
| 1691 | + rules: { |
| 1692 | + /* 수정하고자 하는 rule 추가 가능... */ |
| 1693 | + }, |
| 1694 | +}; |
| 1695 | +``` |
| 1696 | + |
| 1697 | +- 물론, rule을 변경하고 싶다면 rules에 아래 `사용방법(2)`와 같이 rule을 추가하면 됩니다. |
| 1698 | + |
| 1699 | +<br /> |
| 1700 | + |
| 1701 | +### 사용 방법(2) |
| 1702 | + |
| 1703 | +- 원하는 `rule`을 개별적으로 셋팅해서 적용하려면 아래와 같이 `.eslintrc.js` 파일 `plugins`배열 안에 `@tanstack/query`를 추가하고, 적용하고자 하는 rules에 규칙을 추가합니다. |
| 1704 | + |
| 1705 | +```js |
| 1706 | +module.exports = { |
| 1707 | + // ... |
| 1708 | + plugins: ["@tanstack/query"], |
| 1709 | + rules: { |
| 1710 | + "@tanstack/query/exhaustive-deps": "error", |
| 1711 | + "@tanstack/query/no-rest-destructuring": "warn", |
| 1712 | + "@tanstack/query/stable-query-client": "error", |
| 1713 | + }, |
| 1714 | +}; |
| 1715 | +``` |
| 1716 | + |
| 1717 | +<br /> |
| 1718 | + |
1660 | 1719 | ## 지원 버전 |
1661 | 1720 |
|
1662 | 1721 | [목차 이동](#주요-컨셉-및-가이드-목차) |
|
0 commit comments