diff --git a/.changeset/sour-games-try.md b/.changeset/sour-games-try.md new file mode 100644 index 0000000..4d3e407 --- /dev/null +++ b/.changeset/sour-games-try.md @@ -0,0 +1,18 @@ +--- +"eslint-plugin-react-server-components": minor +--- + +Added `allowedServerHooks` option. Hooks specified here will not throw an error in files that do not have the `'use client'` directive. + +Example: + +```json +{ + "rules": { + "react-server-components/use-client": [ + "error", + { "allowedServerHooks": ["useTranslation"] } + ] + } +} +``` diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1346625..500df00 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,9 +12,7 @@ jobs: env: CI: true steps: - - uses: pnpm/action-setup@v2.2.4 - with: - version: 6.23.1 + - uses: pnpm/action-setup@v3.0.0 - name: Checkout Repo uses: actions/checkout@main diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 20cf234..7ae9b69 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -13,12 +13,10 @@ jobs: env: CI: true steps: - - uses: pnpm/action-setup@v2.2.4 - with: - version: 6.23.1 + - uses: actions/checkout@main - - name: Checkout Repo - uses: actions/checkout@main + - name: Install pnpm + uses: pnpm/action-setup@v3 - name: Setup Node.js uses: actions/setup-node@main diff --git a/.nvmrc b/.nvmrc index b6a7d89..209e3ef 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -16 +20 diff --git a/example/.eslintrc.json b/example/.eslintrc.json new file mode 100644 index 0000000..956668f --- /dev/null +++ b/example/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "extends": [ + "next/core-web-vitals", + "plugin:react-server-components/recommended" + ], + "rules": { + "react-server-components/use-client": [ + "error", + { "allowedServerHooks": ["useTranslation"] } + ] + } +} diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..fd3dbb5 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,36 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js +.yarn/install-state.gz + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..0dc9ea2 --- /dev/null +++ b/example/README.md @@ -0,0 +1,36 @@ +This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). + +## Getting Started + +First, run the development server: + +```bash +npm run dev +# or +yarn dev +# or +pnpm dev +# or +bun dev +``` + +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. + +You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file. + +This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. + +## Learn More + +To learn more about Next.js, take a look at the following resources: + +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. + +You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! + +## Deploy on Vercel + +The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. + +Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. diff --git a/example/app/ClientComponent.js b/example/app/ClientComponent.js new file mode 100644 index 0000000..30ab59b --- /dev/null +++ b/example/app/ClientComponent.js @@ -0,0 +1,5 @@ +"use client"; + +export function Button(props) { + return