diff --git a/packages/eslint-plugin-next-on-pages/src/rules/no-unsupported-configs.ts b/packages/eslint-plugin-next-on-pages/src/rules/no-unsupported-configs.ts index 55565fce8..4d471ac0a 100644 --- a/packages/eslint-plugin-next-on-pages/src/rules/no-unsupported-configs.ts +++ b/packages/eslint-plugin-next-on-pages/src/rules/no-unsupported-configs.ts @@ -97,7 +97,7 @@ const ruleSchema = { const rule: Rule.RuleModule = { create: context => { const code = context.sourceCode; - const exportedConfigName = context.filename.match(/next\.config\.m?js$/) + const exportedConfigName = context.filename.match(/next\.config\.(js|cjs|mjs|ts|cts|mts)$/) ? getConfigVariableName(code) : null; diff --git a/packages/eslint-plugin-next-on-pages/tests/rules/no-unsupported-configs.test.ts b/packages/eslint-plugin-next-on-pages/tests/rules/no-unsupported-configs.test.ts index d17d3e4f4..25b00ceee 100644 --- a/packages/eslint-plugin-next-on-pages/tests/rules/no-unsupported-configs.test.ts +++ b/packages/eslint-plugin-next-on-pages/tests/rules/no-unsupported-configs.test.ts @@ -497,4 +497,38 @@ describe('no-unsupported-configs', () => { ], }); }); + + test('should work with .ts config file extension', () => { + tester.run('', rule, { + valid: [ + { + filename: 'next.config.ts', + code: ` + const nextConfig = { + } + + export default nextConfig; + `, + }, + ], + invalid: [ + { + filename: 'next.config.ts', + code: ` + const nextConfig = { + compress: true, + } + + export default nextConfig; + `, + errors: [ + { + message: + 'The "compress" configuration is not supported by next-on-pages (and is unlikely to be supported in the future).', + }, + ], + }, + ], + }); + }); });