@nx/playwright 23.1.0-rc.3 → 23.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -149,7 +149,7 @@ async function configurationGeneratorInternal(tree, rawOptions) {
149
149
  skipPackageJson: options.skipPackageJson,
150
150
  js: options.js,
151
151
  directory: options.directory,
152
- setParserOptionsProject: options.setParserOptionsProject,
152
+ enableTypedLinting: (0, internal_3.isTypedLintingEnabled)(options),
153
153
  rootProject: options.rootProject ?? projectConfig.root === '.',
154
154
  addPlugin: options.addPlugin,
155
155
  }));
@@ -11,6 +11,10 @@ export interface ConfigurationGeneratorSchema {
11
11
  skipPackageJson?: boolean;
12
12
  skipInstall?: boolean;
13
13
  linter?: Linter | LinterType;
14
+ enableTypedLinting?: boolean; // default is false
15
+ /**
16
+ * @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
17
+ */
14
18
  setParserOptionsProject?: boolean; // default is false
15
19
  /**
16
20
  * command to give playwright to run the web server
@@ -39,11 +39,17 @@
39
39
  "type": "string",
40
40
  "description": "The address of the web server."
41
41
  },
42
- "setParserOptionsProject": {
42
+ "enableTypedLinting": {
43
43
  "type": "boolean",
44
- "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
44
+ "description": "Whether to enable typed linting. For flat configs, this configures the recommended `parserOptions.projectService` and `tsconfigRootDir`. For legacy `.eslintrc` configs, this configures `parserOptions.project`. We do not enable this by default for lint performance reasons.",
45
45
  "default": false
46
46
  },
47
+ "setParserOptionsProject": {
48
+ "type": "boolean",
49
+ "description": "Deprecated alias for `enableTypedLinting`.",
50
+ "default": false,
51
+ "x-deprecated": "Use `enableTypedLinting` instead. This option will be removed in Nx v24."
52
+ },
47
53
  "skipFormat": {
48
54
  "description": "Skip formatting files.",
49
55
  "type": "boolean",
@@ -3,7 +3,11 @@ import { Linter, LinterType } from '@nx/eslint';
3
3
  export interface PlaywrightLinterOptions {
4
4
  project: string;
5
5
  linter: Linter | LinterType;
6
- setParserOptionsProject: boolean;
6
+ enableTypedLinting?: boolean;
7
+ /**
8
+ * @deprecated Use `enableTypedLinting` instead. This option will be removed in Nx v24.
9
+ */
10
+ setParserOptionsProject?: boolean;
7
11
  skipPackageJson: boolean;
8
12
  rootProject: boolean;
9
13
  js?: boolean;
@@ -12,13 +12,14 @@ async function addLinterToPlaywrightProject(tree, options) {
12
12
  const tasks = [];
13
13
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
14
14
  const eslintFile = (0, internal_1.findEslintFile)(tree, projectConfig.root);
15
+ const enableTypedLinting = (0, internal_1.isTypedLintingEnabled)(options);
15
16
  if (!eslintFile) {
16
17
  tasks.push(await (0, eslint_1.lintProjectGenerator)(tree, {
17
18
  project: options.project,
18
19
  linter: options.linter,
19
20
  skipFormat: true,
20
21
  tsConfigPaths: [(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json')],
21
- setParserOptionsProject: options.setParserOptionsProject,
22
+ enableTypedLinting,
22
23
  skipPackageJson: options.skipPackageJson,
23
24
  rootProject: options.rootProject,
24
25
  addPlugin: options.addPlugin,
@@ -43,6 +44,13 @@ async function addLinterToPlaywrightProject(tree, options) {
43
44
  files: ['*.ts', '*.js'],
44
45
  rules: {},
45
46
  });
47
+ // `lintProjectGenerator` only runs when the project has no ESLint config
48
+ // (it already emits the projectService block in that case). For an
49
+ // existing flat config it didn't run, so emit the block here when typed
50
+ // linting is requested.
51
+ if (eslintFile && enableTypedLinting) {
52
+ (0, internal_1.addTypedLintingToFlatConfig)(tree, projectConfig.root);
53
+ }
46
54
  }
47
55
  else {
48
56
  const addExtendsTask = (0, internal_1.addExtendsToLintConfig)(tree, projectConfig.root, 'plugin:playwright/recommended');
@@ -53,11 +61,12 @@ async function addLinterToPlaywrightProject(tree, options) {
53
61
  }
54
62
  (0, internal_1.addOverrideToLintConfig)(tree, projectConfig.root, {
55
63
  files: [`${options.directory}/**/*.{ts,js,tsx,jsx}`],
56
- parserOptions: !options.setParserOptionsProject
57
- ? undefined
58
- : {
59
- project: `${projectConfig.root}/tsconfig.*?.json`,
60
- },
64
+ // Only emit `parserOptions.project` here on the legacy `.eslintrc`
65
+ // stack. Flat configs use `parserOptions.projectService` emitted by
66
+ // `lintProjectGenerator`.
67
+ parserOptions: enableTypedLinting
68
+ ? { project: `${projectConfig.root}/tsconfig.*?.json` }
69
+ : undefined,
61
70
  rules: {},
62
71
  });
63
72
  }
@@ -41,4 +41,12 @@ export interface NxPlaywrightOptions {
41
41
  * @param pathToConfig will be used to construct the output paths for reporters and test results
42
42
  * @param options optional configuration options
43
43
  */
44
- export declare function nxE2EPreset(pathToConfig: string, options?: NxPlaywrightOptions): import("@playwright/test").PlaywrightTestConfig<{}, {}>;
44
+ export declare function nxE2EPreset(pathToConfig: string, options?: NxPlaywrightOptions): {
45
+ testDir: string;
46
+ outputDir: string;
47
+ fullyParallel: true;
48
+ forbidOnly: boolean;
49
+ retries: number;
50
+ workers: number;
51
+ reporter: any[];
52
+ };
@@ -4,7 +4,6 @@ exports.nxE2EPreset = nxE2EPreset;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const internal_1 = require("@nx/devkit/internal");
6
6
  const internal_2 = require("@nx/js/internal");
7
- const test_1 = require("@playwright/test");
8
7
  const node_fs_1 = require("node:fs");
9
8
  const node_path_1 = require("node:path");
10
9
  const semver_1 = require("semver");
@@ -71,7 +70,12 @@ function nxE2EPreset(pathToConfig, options) {
71
70
  },
72
71
  ]);
73
72
  }
74
- return (0, test_1.defineConfig)({
73
+ // Plain object on purpose: consumers spread this into their own
74
+ // `defineConfig(...)` call. Calling `defineConfig` here would require
75
+ // `@playwright/test` at runtime, which crashes when the preset package and
76
+ // the consuming workspace resolve different copies of it (playwright
77
+ // refuses to be loaded twice in one process).
78
+ return {
75
79
  testDir: options?.testDir ?? './src',
76
80
  outputDir: testResultOuputDir,
77
81
  /* Run tests in files in parallel */
@@ -84,5 +88,5 @@ function nxE2EPreset(pathToConfig, options) {
84
88
  workers: process.env.CI ? 1 : undefined,
85
89
  /* Reporter to use. See https://playwright.dev/docs/test-reporters */
86
90
  reporter: [...reporters],
87
- });
91
+ };
88
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/playwright",
3
- "version": "23.1.0-rc.3",
3
+ "version": "23.1.1",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -78,12 +78,12 @@
78
78
  "tslib": "^2.3.0",
79
79
  "minimatch": "10.2.5",
80
80
  "semver": "^7.6.3",
81
- "@nx/devkit": "23.1.0-rc.3",
82
- "@nx/eslint": "23.1.0-rc.3",
83
- "@nx/js": "23.1.0-rc.3"
81
+ "@nx/devkit": "23.1.1",
82
+ "@nx/eslint": "23.1.1",
83
+ "@nx/js": "23.1.1"
84
84
  },
85
85
  "devDependencies": {
86
- "nx": "23.1.0-rc.3"
86
+ "nx": "23.1.1"
87
87
  },
88
88
  "peerDependencies": {
89
89
  "@playwright/test": "^1.36.0"