Skip to content
Merged
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-refresh",
"version": "0.4.20",
"version": "0.4.21",
"type": "module",
"license": "MIT",
"scripts": {
Expand Down
22 changes: 22 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArnaudBarre I just discovered that this is also allowed:

viewport

See https://nextjs.org/docs/app/api-reference/functions/generate-viewport.

"experimental_ppr",
"dynamic",
"dynamicParams",
"revalidate",
"fetchCache",
"runtime",
"preferredRegion",
"maxDuration",
],
},
],
},
},
};

// Probably not needed, but keep for backwards compatibility
Expand Down
1 change: 1 addition & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ declare const _default: {
configs: {
recommended: Config;
vite: Config;
next: Config;
};
};

Expand Down