From ee03263c757419e8ee5470a2864c55f5b7a1a8c0 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Tue, 15 Oct 2024 18:48:41 +0900 Subject: [PATCH] fix(next): eslint v9 not picking up config --- packages/next/src/lib/eslint/runLintCheck.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/next/src/lib/eslint/runLintCheck.ts b/packages/next/src/lib/eslint/runLintCheck.ts index 8f175506d4540..41fb20e79df97 100644 --- a/packages/next/src/lib/eslint/runLintCheck.ts +++ b/packages/next/src/lib/eslint/runLintCheck.ts @@ -135,9 +135,11 @@ async function lint( const mod = await Promise.resolve(require(deps.resolved.get('eslint')!)) - const useFlatConfig = - // If V9 config was found, use flat config, or else use legacy. - eslintrcFile?.startsWith('eslint.config.') + // If V9 config was found, use flat config, or else use legacy. + const useFlatConfig = eslintrcFile + ? // eslintrcFile is absolute path + path.basename(eslintrcFile).startsWith('eslint.config.') + : false let ESLint // loadESLint is >= 8.57.0 @@ -211,6 +213,15 @@ async function lint( : // in ESLint >= 9, `plugins` value is Record '@next/next' in plugins + console.log({ + hasNextPlugin, + plugins, + completeConfig, + configFile, + eslint, + useFlatConfig, + }) + if (hasNextPlugin) { nextEslintPluginIsEnabled = true for (const [name, [severity]] of Object.entries(completeConfig.rules)) {