Skip to content

Commit cbf1c46

Browse files
Fix: Move deps/devDeps/peerDeps to appropriate location (#5498)
1 parent 626652a commit cbf1c46

File tree

133 files changed

+1299
-1428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1299
-1428
lines changed

examples/react/algolia/.prettierrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/react/algolia/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
"@algolia/transporter": "4.17.1",
1313
"@tanstack/react-query": "^5.0.0-alpha.38",
1414
"@tanstack/react-query-devtools": "^5.0.0-alpha.38",
15-
"algoliasearch": "4.17.1"
15+
"algoliasearch": "4.17.1",
16+
"react": "^18.2.0",
17+
"react-dom": "^18.2.0"
1618
},
1719
"devDependencies": {
1820
"@tanstack/eslint-plugin-query": "^5.0.0-alpha.36",
1921
"@types/react": "^18.2.4",
2022
"@types/react-dom": "^18.2.4",
2123
"@vitejs/plugin-react": "^4.0.0",
22-
"react": "^18.2.0",
23-
"react-dom": "^18.2.0",
2424
"typescript": "^5.0.4",
2525
"vite": "^4.2.0"
2626
},

examples/react/algolia/src/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
1+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
22

3-
import "./styles.css";
4-
import Search from "./Search";
3+
import './styles.css'
4+
import Search from './Search'
55

6-
const queryClient = new QueryClient();
6+
const queryClient = new QueryClient()
77

88
export default function App() {
99
return (
@@ -13,5 +13,5 @@ export default function App() {
1313
<Search />
1414
</div>
1515
</QueryClientProvider>
16-
);
16+
)
1717
}

examples/react/algolia/src/Search.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { useState } from "react";
1+
import { useState } from 'react'
22

3-
import SearchResults from "./SearchResults";
3+
import SearchResults from './SearchResults'
44

55
export default function Search() {
6-
const [query, setQuery] = useState("");
6+
const [query, setQuery] = useState('')
77

88
const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
9-
event.preventDefault();
9+
event.preventDefault()
1010
// It is recommended to debounce this event in prod
11-
setQuery(event.target.value);
12-
};
11+
setQuery(event.target.value)
12+
}
1313

1414
return (
1515
<div>
@@ -20,5 +20,5 @@ export default function Search() {
2020
/>
2121
<SearchResults query={query} />
2222
</div>
23-
);
23+
)
2424
}

examples/react/algolia/src/SearchResults.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import useAlgolia from "./useAlgolia";
1+
import useAlgolia from './useAlgolia'
22

33
type Product = {
4-
name: string;
5-
shortDescription: string;
6-
salePrice: number;
7-
};
4+
name: string
5+
shortDescription: string
6+
salePrice: number
7+
}
88

99
type SearchResultsProps = {
10-
query: string;
11-
};
10+
query: string
11+
}
1212

13-
export default function SearchResults({ query = "" }: SearchResultsProps) {
13+
export default function SearchResults({ query = '' }: SearchResultsProps) {
1414
const {
1515
hits,
1616
isLoading,
@@ -20,17 +20,17 @@ export default function SearchResults({ query = "" }: SearchResultsProps) {
2020
isFetchingNextPage,
2121
fetchNextPage,
2222
} = useAlgolia<Product>({
23-
indexName: "bestbuy",
23+
indexName: 'bestbuy',
2424
query,
2525
hitsPerPage: 5,
2626
staleTime: 1000 * 30, // 30s
2727
gcTime: 1000 * 60 * 15, // 15m
2828
enabled: !!query,
29-
});
29+
})
3030

31-
if (!query) return null;
31+
if (!query) return null
3232

33-
if (isLoading) return <div className="loading">Loading...</div>;
33+
if (isLoading) return <div className="loading">Loading...</div>
3434

3535
return (
3636
<div>
@@ -69,5 +69,5 @@ export default function SearchResults({ query = "" }: SearchResultsProps) {
6969
)}
7070
</div>
7171
</div>
72-
);
72+
)
7373
}

examples/react/algolia/src/algolia.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
import algoliasearch from "algoliasearch";
2-
import { Hit } from "@algolia/client-search";
1+
import algoliasearch from 'algoliasearch'
2+
import { Hit } from '@algolia/client-search'
33

44
// From Algolia example
55
// https://github.com/algolia/react-instantsearch
6-
const ALGOLIA_APP_ID = "latency";
7-
const ALGOLIA_SEARCH_API_KEY = "6be0576ff61c053d5f9a3225e2a90f76";
6+
const ALGOLIA_APP_ID = 'latency'
7+
const ALGOLIA_SEARCH_API_KEY = '6be0576ff61c053d5f9a3225e2a90f76'
88

99
type SearchOptions = {
10-
indexName: string;
11-
query: string;
12-
pageParam: number;
13-
hitsPerPage: number;
14-
};
10+
indexName: string
11+
query: string
12+
pageParam: number
13+
hitsPerPage: number
14+
}
1515

1616
export async function search<TData>({
1717
indexName,
1818
query,
1919
pageParam,
2020
hitsPerPage = 10,
2121
}: SearchOptions): Promise<{
22-
hits: Hit<TData>[];
23-
nextPage: number | undefined;
22+
hits: Hit<TData>[]
23+
nextPage: number | undefined
2424
}> {
25-
const client = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY);
26-
const index = client.initIndex(indexName);
25+
const client = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY)
26+
const index = client.initIndex(indexName)
2727

28-
console.log("alogolia:search", { indexName, query, pageParam, hitsPerPage });
28+
console.log('alogolia:search', { indexName, query, pageParam, hitsPerPage })
2929

3030
const { hits, page, nbPages } = await index.search<TData>(query, {
3131
page: pageParam,
3232
hitsPerPage,
33-
});
33+
})
3434

35-
const nextPage = page + 1 < nbPages ? page + 1 : undefined;
35+
const nextPage = page + 1 < nbPages ? page + 1 : undefined
3636

37-
return { hits, nextPage };
37+
return { hits, nextPage }
3838
}

examples/react/algolia/src/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import ReactDOM from "react-dom/client";
1+
import ReactDOM from 'react-dom/client'
22

3-
import App from "./App";
3+
import App from './App'
44

5-
const rootElement = document.getElementById("root") as HTMLElement;
6-
ReactDOM.createRoot(rootElement).render(<App />);
5+
const rootElement = document.getElementById('root') as HTMLElement
6+
ReactDOM.createRoot(rootElement).render(<App />)
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { useInfiniteQuery } from "@tanstack/react-query";
2-
import { search } from "./algolia";
1+
import { useInfiniteQuery } from '@tanstack/react-query'
2+
import { search } from './algolia'
33

44
export type UseAlgoliaOptions = {
5-
indexName: string;
6-
query: string;
7-
hitsPerPage?: number;
8-
staleTime?: number;
9-
gcTime?: number;
10-
enabled?: boolean;
11-
};
5+
indexName: string
6+
query: string
7+
hitsPerPage?: number
8+
staleTime?: number
9+
gcTime?: number
10+
enabled?: boolean
11+
}
1212

1313
export default function useAlgolia<TData>({
1414
indexName,
@@ -19,17 +19,17 @@ export default function useAlgolia<TData>({
1919
enabled,
2020
}: UseAlgoliaOptions) {
2121
const queryInfo = useInfiniteQuery({
22-
queryKey: ["algolia", indexName, query, hitsPerPage],
22+
queryKey: ['algolia', indexName, query, hitsPerPage],
2323
queryFn: ({ pageParam }) =>
2424
search<TData>({ indexName, query, pageParam, hitsPerPage }),
2525
defaultPageParam: 0,
2626
getNextPageParam: (lastPage) => lastPage?.nextPage,
2727
staleTime,
2828
gcTime,
2929
enabled,
30-
});
30+
})
3131

32-
const hits = queryInfo.data?.pages.map((page) => page.hits).flat();
32+
const hits = queryInfo.data?.pages.map((page) => page.hits).flat()
3333

34-
return { ...queryInfo, hits };
34+
return { ...queryInfo, hits }
3535
}

examples/react/algolia/vite.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { defineConfig } from "vite";
2-
import react from "@vitejs/plugin-react";
1+
import { defineConfig } from 'vite'
2+
import react from '@vitejs/plugin-react'
33

44
export default defineConfig({
55
plugins: [react()],
6-
});
6+
})

examples/react/basic-graphql-request/.prettierrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)