diff --git a/CHANGELOG.md b/CHANGELOG.md index af3d27a..4dc5bc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 0.4.21 + +- Add Next config (fixes [#85](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues/85)) + +This allows exports like `fetchCache` and `revalidate` which are used in Page or Layout components and don't trigger a full page reload. + +```js +import reactRefresh from "eslint-plugin-react-refresh"; + +export default [ + /* Main config */ + reactRefresh.configs.next, +]; +``` + ## 0.4.20 - Don't warn on nested HOC calls (fixes [#79](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues/79)) diff --git a/README.md b/README.md index c335327..2d05b7a 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,19 @@ export default [ ]; ``` +### Next config + +This allows exports like `fetchCache` and `revalidate` which are used in Page or Layout components and don't trigger a full page reload. + +```js +import reactRefresh from "eslint-plugin-react-refresh"; + +export default [ + /* Main config */ + reactRefresh.configs.next, +]; +``` + ### Without config ```js diff --git a/package.json b/package.json index 213dc51..92e0e9e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-react-refresh", - "version": "0.4.20", + "version": "0.4.21", "type": "module", "license": "MIT", "scripts": { diff --git a/src/index.ts b/src/index.ts index bb74708..f5e03a7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,6 +22,28 @@ export const configs = { ], }, }, + next: { + name: "react-refresh/vite", + plugins: { "react-refresh": plugin }, + rules: { + "react-refresh/only-export-components": [ + "error", + { + // from https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config + allowExportNames: [ + "experimental_ppr", + "dynamic", + "dynamicParams", + "revalidate", + "fetchCache", + "runtime", + "preferredRegion", + "maxDuration", + ], + }, + ], + }, + }, }; // Probably not needed, but keep for backwards compatibility diff --git a/src/types.d.ts b/src/types.d.ts index 26d7393..29d520f 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -8,6 +8,7 @@ declare const _default: { configs: { recommended: Config; vite: Config; + next: Config; }; };