Skip to content

Commit bce221b

Browse files
committed
feat(next.js): add rules for instrumentation and proxy files
1 parent 276a296 commit bce221b

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

configs/nextjs.js

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,32 @@ module.exports = defineConfig(
6666
},
6767
},
6868
{
69+
files: [`{instrumentation,src/instrumentation}.{ts,tsx}`],
70+
rules: {
71+
'import/no-unused-modules': ['off'],
72+
73+
// eslint-plugin-react-refresh: https://github.com/ArnaudBarre/eslint-plugin-react-refresh
74+
'react-refresh/only-export-components': [
75+
'warn',
76+
{
77+
allowExportNames: [
78+
/**
79+
* Next.js allows exporting the following exports in instrumentation files
80+
*
81+
* @link https://nextjs.org/docs/app/guides/instrumentation#convention
82+
*/
83+
'register',
84+
],
85+
},
86+
],
87+
},
88+
},
89+
{
90+
/**
91+
* Next.js 'middleware' files are beeing deprecated in favor of the new proxy files with v16+
92+
*
93+
* @link https://nextjs.org/blog/next-16#proxyts-formerly-middlewarets
94+
*/
6995
files: [`{middleware,src/middleware}.{ts,tsx}`],
7096
rules: {
7197
'import/no-unused-modules': ['off'],
@@ -87,6 +113,25 @@ module.exports = defineConfig(
87113
},
88114
},
89115
{
90-
ignores: ['.next/*'],
116+
files: [`{proxy,src/proxy}.{ts,tsx}`],
117+
rules: {
118+
'import/no-unused-modules': ['off'],
119+
120+
// eslint-plugin-react-refresh: https://github.com/ArnaudBarre/eslint-plugin-react-refresh
121+
'react-refresh/only-export-components': [
122+
'warn',
123+
{
124+
allowExportNames: [
125+
/**
126+
* Next.js allows exporting the following exports in proxy files
127+
*
128+
* @link https://nextjs.org/docs/app/api-reference/file-conventions/proxy#config-object-optional
129+
*/
130+
'config',
131+
'proxy',
132+
],
133+
},
134+
],
135+
},
91136
},
92137
);

0 commit comments

Comments
 (0)