Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@
# dependencies
/node_modules
/.pnp
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*


# testing
/coverage

Expand All @@ -33,6 +26,7 @@ yarn-error.log*
.idea
.cache/
package-lock.json
.vscode
tsconfig.tsbuildinfo
.next/

Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.18.1
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pnpm-lock.yaml
.cache/
.contentlayer/
.next/
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"endOfLine": "lf",
"semi": false,
"singleQuote": false,
Expand Down
35 changes: 31 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,52 @@ Here is a quick guide to doing code contributions to the library.

3. Install packages by running:

> yarn
```shellscript
pnpm install
```

4. Startup a local version of the docs

> yarn start
```shellscript
pnpm run dev
```

5. Ensure your code is formatted properly

> yarn format
```shellscript
pnpm run format
```

6. Push your branch: `git push -u origin your-meaningful-branch-name`

7. Submit a pull request to the upstream react-hook-form repository.

8. Choose a descriptive title and describe your changes briefly.

## Testing production build

To test the documentation production site on your local machine,
first execute the build script:

```shellscript
pnpm run build
```

Then start a local server which serves the file created by executing

```shellscript
pnpm run start
```

## Coding style

Please follow the coding style of the project. React Hook Form uses prettier. If possible, enable the prettier plugin in your editor to get real-time feedback. The formatting can be run manually with the following command: `yarn format`
Please follow the coding style of the project.
React Hook Form uses prettier.
If possible, enable the prettier plugin in your editor to get real-time feedback. The formatting can be run manually with the following command:

```shellscript
pnpm run format:fix
```

## License

Expand Down
Empty file added changes.diff
Empty file.
16 changes: 13 additions & 3 deletions contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import remarkGfm from "remark-gfm"
import rehypeMdxCodeProps from "rehype-mdx-code-props"
import emoji from "remark-emoji"
import * as sidebar from "./src/components/Menu/MenuLinks"
import type { Pages } from "./src/types/types"

export const Doc = defineDocumentType(() => ({
name: "Doc",
Expand Down Expand Up @@ -33,13 +34,22 @@ export const Doc = defineDocumentType(() => ({
type: "string",
resolve: (doc) => doc._raw.flattenedPath.split("/").slice(1).join("/"),
},

/**
* Can't define value different from primitives, so hardcoding the correct type
* @see https://github.com/contentlayerdev/contentlayer/issues/149
*/
segment: {
type: "list",
type: "string[]" as "list",
resolve: (doc) => doc._raw.flattenedPath.split("/"),
},
pages: {
type: "list",
resolve: (doc) => sidebar[doc.sidebar] ?? [],
type: "json",
resolve: (doc) => {
// added explicit type casting to keep track of this data structure
// in case in the future contentlayer will support values different than primitives
return sidebar[doc.sidebar] as unknown as Pages
},
},
},
}))
Expand Down
67 changes: 67 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// @ts-check
import tseslint from "typescript-eslint"
import { FlatCompat } from "@eslint/eslintrc"
import eslintPluginJsxA11y from "eslint-plugin-jsx-a11y"
import eslintPluginReact from "eslint-plugin-react"

const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
})

export default tseslint.config(
tseslint.configs.recommendedTypeChecked,

...compat.config({
extends: ["next"],
rules: {
// react
"react/prop-types": "off",
"react/no-unescaped-entities": "off",
"react/jsx-curly-brace-presence": "warn",

// jsx-ally is already included in next-js so
// we are adding only recommended rules directly here
...eslintPluginJsxA11y.flatConfigs.recommended.rules,
"jsx-a11y/no-onchange": "warn",

// import
"import/no-anonymous-default-export": "off",

// next
"@next/next/no-img-element": "off",
},
}),

// @ts-expect-error eslintPluginReact.configs.flat, but runtime is always defined
eslintPluginReact.configs.flat["jsx-runtime"],

{
linterOptions: {
reportUnusedDisableDirectives: "error",
},
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// typescript
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowAny: false,
allowBoolean: false,
allowNever: false,
allowNullish: false,
allowNumber: true,
allowRegExp: false,
},
],
},
}
)
3 changes: 2 additions & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
27 changes: 27 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { NextConfig } from "next"
import { withContentlayer } from "next-contentlayer"
import withBundleAnalyzer from "@next/bundle-analyzer"

const nextConfig: NextConfig = {
eslint: {
/**
* Now eslint requires typecheck so we have to run build before executing lint
* These check are performed via `.github/workflows/ci.yml` action
*
* @see https://github.com/react-hook-form/documentation/pull/1107
*/
ignoreDuringBuilds: true,
},
typescript: {
/** @see `eslint.ignoreDuringBuilds` comment */
ignoreBuildErrors: true,
},
reactStrictMode: true,
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
}

const bundleAnalyzer = withBundleAnalyzer({
enabled: process.env.ANALYZE === "true",
})

export default bundleAnalyzer(withContentlayer(nextConfig))
79 changes: 45 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,55 @@
"@hookform/devtools": "4.3.1",
"@mdx-js/loader": "^2.3.0",
"@mdx-js/react": "^2.3.0",
"@next/mdx": "^13.4.5",
"@types/node": "^20.3.1",
"class-variance-authority": "^0.6.0",
"@next/mdx": "15.1.0",
"class-variance-authority": "^0.6.1",
"clsx": "^1.2.1",
"contentlayer": "^0.3.3",
"date-fns": "^2.30.0",
"little-state-machine": "^4.8.0",
"next": "^14.1.1",
"next-contentlayer": "^0.3.3",
"next-sitemap": "^4.2.3",
"contentlayer": "^0.3.4",
"little-state-machine": "^4.8.1",
"next": "^15.5.2",
"next-contentlayer": "^0.3.4",
"next-themes": "^0.2.1",
"posthog-js": "^1.239.1",
"prism-react-renderer": "^2.0.5",
"prismjs": "^1.29.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"prism-react-renderer": "^2.4.1",
"prismjs": "^1.30.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-github-btn": "1.4.0",
"react-hook-form": "7.44.3",
"react-simple-animate": "^3.5.2",
"react-simple-animate": "^3.5.3",
"react-simple-img": "3.0.0",
"react-sortablejs": "1.5.1",
"rehype-mdx-code-props": "^1.0.0",
"remark-custom-heading-id": "^1.0.1",
"remark-emoji": "^3.1.2",
"remark-gfm": "^3.0.1",
"sortablejs": "1.15.0"
"sortablejs": "1.15.0",
"@types/node": "^20.3.1",
"date-fns": "^2.30.0",
"next-sitemap": "^4.2.3",
"posthog-js": "^1.239.1"
},
"devDependencies": {
"@next/bundle-analyzer": "^13.4.5",
"@types/react-helmet": "^6.1.6",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"@next/bundle-analyzer": "15.1.0",
"@types/eslint-plugin-jsx-a11y": "6.10.0",
"@types/eslint__eslintrc": "2.1.2",
"@types/node": "20.17.10",
"@types/react": "18.3.17",
"@types/react-dom": "18.3.5",
"@types/react-helmet": "^6.1.11",
"cross-env": "^7.0.3",
"eslint": "^8.42.0",
"eslint-config-next": "^13.4.5",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint": "9.17.0",
"eslint-config-next": "15.1.0",
"eslint-plugin-jsx-a11y": "6.10.2",
"eslint-plugin-react": "7.37.2",
"eslint-plugin-react-hooks": "5.1.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"prettier": "^2.8.8",
"typescript": "^5.1.3"
"lint-staged": "^13.3.0",
"prettier": "^3.6.2",
"typescript": "^5.9.2",
"typescript-eslint": "8.18.1",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"eslint-config-prettier": "^8.8.0"
},
"keywords": [
"react-hook-form",
Expand All @@ -60,17 +66,21 @@
"analyze": "cross-env ANALYZE=true next build",
"build": "next build",
"dev": "next dev",
"format": "prettier --write",
"lint": "next lint --fix",
"now-build": "npm run build",
"format": "prettier . --check",
"format:fix": "prettier . --write",
"lint": "next lint",
"lint:fix": "next lint --fix",
"lint:ci": "next build --no-lint && next lint",
"now-build": "pnpm run build",
"start": "next start",
"typecheck": "tsc --noEmit",
"typecheck:ci": "next build --no-lint && tsc --noEmit",
"prepare": "husky install",
"postbuild": "next-sitemap"
},
"lint-staged": {
"*.{ts,tsx,mdx,css,json}": [
"npm run format"
"pnpm run format:fix"
]
},
"packageManager": "[email protected]+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c",
Expand All @@ -79,5 +89,6 @@
"@types/react": "18.3.17",
"@types/react-dom": "18.3.5"
}
}
},
"peerDependencies": {}
}
Loading