Skip to content

Commit

Permalink
fix(misc): fix up flat configs for playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Sep 5, 2024
1 parent 91fc112 commit 7c03b1d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions packages/playwright/src/utils/add-linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7c03b1d

Please sign in to comment.