From 7c03b1dc32cf38e8cbd6649b59a0e6f0a6d613e4 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Thu, 5 Sep 2024 15:05:04 -0400 Subject: [PATCH] fix(misc): fix up flat configs for playwright --- packages/playwright/src/utils/add-linter.ts | 25 ++++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/playwright/src/utils/add-linter.ts b/packages/playwright/src/utils/add-linter.ts index c1822c2731d23e..efaa4127f94071 100644 --- a/packages/playwright/src/utils/add-linter.ts +++ b/packages/playwright/src/utils/add-linter.ts @@ -13,9 +13,11 @@ import { addExtendsToLintConfig, addOverrideToLintConfig, addPluginsToLintConfig, + addPredefinedConfigToFlatLintConfig, findEslintFile, isEslintConfigSupported, } from '@nx/eslint/src/generators/utils/eslint-file'; +import { useFlatConfig } from '@nx/eslint/src/utils/flat-config'; export interface PlaywrightLinterOptions { project: string; @@ -76,12 +78,23 @@ export async function addLinterToPlaywrightProject( isEslintConfigSupported(tree, projectConfig.root) || isEslintConfigSupported(tree) ) { - const addExtendsTask = addExtendsToLintConfig( - tree, - projectConfig.root, - 'plugin:playwright/recommended' - ); - tasks.push(addExtendsTask); + if (useFlatConfig(tree)) { + addPredefinedConfigToFlatLintConfig( + tree, + projectConfig.root, + 'flat/recommended', + 'playwright', + 'eslint-plugin-playwright', + false + ); + } else { + const addExtendsTask = addExtendsToLintConfig( + tree, + projectConfig.root, + 'plugin:playwright/recommended' + ); + tasks.push(addExtendsTask); + } if (options.rootProject) { addPluginsToLintConfig(tree, projectConfig.root, '@nx'); addOverrideToLintConfig(tree, projectConfig.root, javaScriptOverride);