Skip to content

Commit 70fb4c9

Browse files
committed
main 🧊 add docs for reactuse json
1 parent 47e77ea commit 70fb4c9

File tree

7 files changed

+71
-6
lines changed

7 files changed

+71
-6
lines changed

‎packages/cli/src/init.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const init = async () => {
4040
const configPath = path.join(APP_PATH, 'reactuse.json');
4141
const config = {
4242
ts: fs.existsSync(path.join(APP_PATH, 'tsconfig.json')),
43-
alias: {
43+
aliases: {
4444
hooks: '@/shared/hooks',
4545
utils: '@/utils/lib'
4646
}

‎packages/core/src/bundle/hooks/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export * from './useBrowserLanguage/useBrowserLanguage';
88
export * from './useClickOutside/useClickOutside';
99
export * from './useClipboard/useClipboard';
1010
export * from './useConst/useConst';
11-
export * from './useConst/useConst';
1211
export * from './useCookie/useCookie';
1312
export * from './useCookies/useCookies';
1413
export * from './useCounter/useCounter';

‎packages/core/src/hooks/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export * from './useBrowserLanguage/useBrowserLanguage';
88
export * from './useClickOutside/useClickOutside';
99
export * from './useClipboard/useClipboard';
1010
export * from './useConst/useConst';
11-
export * from './useConst/useConst';
1211
export * from './useCookie/useCookie';
1312
export * from './useCookies/useCookies';
1413
export * from './useCounter/useCounter';

‎packages/docs/app/.vitepress/config.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export default async () => {
9797
items: [
9898
{ text: 'Introduction', link: '/introduction' },
9999
{ text: 'Installation', link: '/installation' },
100-
{ text: 'Config', link: '/config' },
100+
{ text: 'reactuse.json', link: '/reactuse-json' },
101101
{ text: 'CLI', link: '/cli' }
102102
]
103103
},

‎packages/docs/app/cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Use the CLI to add hooks to your project with [useverse](https://www.npmjs.com/p
66

77
Use the `init` command to initialize configuration and dependencies for a new project.
88

9-
The `init` command installs dependencies, adds configures [`reactuse.json`](./config.html).
9+
The `init` command installs dependencies, adds configures [`reactuse.json`](./reactuse-json.html).
1010

1111
```bash
1212
npx useverse@latest init

‎packages/docs/app/config.md

-1
This file was deleted.
+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# reactuse.json
2+
3+
Configuration for your project.
4+
5+
The `reactuse.json` file holds configuration for your project.
6+
7+
We use it to understand how your project is set up and how to generate hooks customized for your project.
8+
9+
::: info
10+
Note: The `reactuse.json` file is optional and **only required if you're
11+
using the CLI** to add hooks to your project. If you're using the copy
12+
and paste method, you don't need this file.
13+
:::
14+
15+
You can create a `reactuse.json` file in your project by running the following command:
16+
17+
```bash
18+
npx useverse@latest init
19+
```
20+
21+
See the [CLI section](./cli.md) for more information.
22+
23+
## ts
24+
25+
Choose between TypeScript or JavaScript hooks.
26+
27+
Setting this option to `false` allows hooks to be added as JavaScript with the `.jsx` file extension.
28+
29+
```json title="reactuse.json"
30+
{
31+
"ts": `true` | `false`
32+
}
33+
```
34+
35+
## aliases
36+
37+
The CLI uses these values and the `paths` config from your `tsconfig.json` or `jsconfig.json` file to place generated hooks in the correct location.
38+
39+
Path aliases have to be set up in your `tsconfig.json` or `jsconfig.json` file.
40+
41+
::: info
42+
**Important:** If you're using the `src` directory, make sure it is included
43+
under `paths` in your `tsconfig.json` or `jsconfig.json` file.
44+
:::
45+
46+
### aliases.utils
47+
48+
Import alias for your utility functions.
49+
50+
```json title="reactuse.json"
51+
{
52+
"aliases": {
53+
"utils": "@/utils/lib"
54+
}
55+
}
56+
```
57+
58+
### aliases.hooks
59+
60+
Import alias for your hooks.
61+
62+
```json title="reactuse.json"
63+
{
64+
"aliases": {
65+
"hooks": "@/shared/hooks"
66+
}
67+
}
68+
```

0 commit comments

Comments
 (0)