@nx/node 23.2.0-beta.6 → 23.2.0-beta.7

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.
@@ -118,7 +118,7 @@ async function applicationGeneratorInternal(tree, schema) {
118
118
  await (0, internal_2.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
119
119
  }
120
120
  updateTsConfigOptions(tree, options);
121
- if (options.linter === 'eslint') {
121
+ if (options.linter !== 'none') {
122
122
  const lintTask = await (0, lib_1.addLintingToApplication)(tree, options);
123
123
  tasks.push(lintTask);
124
124
  }
@@ -2,20 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLintingToApplication = addLintingToApplication;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const eslint_1 = require("@nx/eslint");
6
5
  const internal_1 = require("@nx/eslint/internal");
6
+ const internal_2 = require("@nx/js/internal");
7
7
  async function addLintingToApplication(tree, options) {
8
- const lintTask = await (0, eslint_1.lintProjectGenerator)(tree, {
8
+ return (0, internal_2.addLintingToProject)(tree, {
9
9
  linter: options.linter,
10
10
  project: options.name,
11
11
  tsConfigPaths: [
12
12
  (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
13
13
  ],
14
14
  unitTestRunner: options.unitTestRunner,
15
- skipFormat: true,
16
15
  enableTypedLinting: (0, internal_1.isTypedLintingEnabled)(options),
17
16
  rootProject: options.rootProject,
18
17
  addPlugin: options.addPlugin,
19
18
  });
20
- return lintTask;
21
19
  }
@@ -36,7 +36,7 @@ async function normalizeOptions(host, options) {
36
36
  appProjectRoot,
37
37
  importPath,
38
38
  parsedTags,
39
- linter: options.linter ?? 'eslint',
39
+ linter: await (0, internal_2.normalizeLinterOption)(host, options.linter),
40
40
  unitTestRunner: options.unitTestRunner ?? 'jest',
41
41
  rootProject: options.rootProject ?? false,
42
42
  port: options.port ?? 3000,
@@ -1,4 +1,4 @@
1
- import type { Linter, LinterType } from '@nx/eslint';
1
+ import type { LinterType } from '@nx/js';
2
2
 
3
3
  export interface Schema {
4
4
  directory: string;
@@ -7,7 +7,7 @@ export interface Schema {
7
7
  skipPackageJson?: boolean;
8
8
  unitTestRunner?: 'jest' | 'none';
9
9
  e2eTestRunner?: 'jest' | 'none';
10
- linter?: Linter | LinterType;
10
+ linter?: LinterType;
11
11
  formatter?: 'none' | 'prettier';
12
12
  tags?: string;
13
13
  frontendProject?: string;
@@ -34,11 +34,9 @@
34
34
  "x-priority": "internal"
35
35
  },
36
36
  "linter": {
37
- "description": "The tool to use for running lint checks.",
37
+ "description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
38
38
  "type": "string",
39
- "enum": ["eslint", "none"],
40
- "default": "none",
41
- "x-prompt": "Which linter would you like to use?",
39
+ "enum": ["eslint", "oxlint", "none"],
42
40
  "x-priority": "important"
43
41
  },
44
42
  "unitTestRunner": {
@@ -6,11 +6,11 @@ const tslib_1 = require("tslib");
6
6
  const internal_1 = require("@nx/devkit/internal");
7
7
  const devkit_1 = require("@nx/devkit");
8
8
  const eslint_1 = require("@nx/eslint");
9
- const internal_2 = require("@nx/eslint/internal");
9
+ const internal_2 = require("@nx/js/internal");
10
+ const internal_3 = require("@nx/eslint/internal");
10
11
  const path = tslib_1.__importStar(require("path"));
11
12
  const versions_1 = require("../../utils/versions");
12
- const internal_3 = require("@nx/jest/internal");
13
- const internal_4 = require("@nx/js/internal");
13
+ const internal_4 = require("@nx/jest/internal");
14
14
  const posix_1 = require("node:path/posix");
15
15
  async function e2eProjectGenerator(host, options) {
16
16
  return await e2eProjectGeneratorInternal(host, {
@@ -24,7 +24,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
24
24
  const options = await normalizeOptions(host, _options);
25
25
  const appProject = (0, devkit_1.readProjectConfiguration)(host, options.project);
26
26
  // Detect Jest 30+ to use .cts config files (CommonJS TypeScript)
27
- const jestMajorVersion = (0, internal_3.getInstalledJestMajorVersion)(host);
27
+ const jestMajorVersion = (0, internal_4.getInstalledJestMajorVersion)(host);
28
28
  const useCommonJsConfig = jestMajorVersion === null || jestMajorVersion >= 30;
29
29
  const jestConfigExt = useCommonJsConfig ? 'cts' : 'ts';
30
30
  // TODO(@ndcunningham): This is broken.. the outputs are wrong.. and this isn't using the jest generator
@@ -98,7 +98,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
98
98
  };
99
99
  });
100
100
  }
101
- const jestPreset = (0, internal_3.findRootJestPreset)(host) ?? 'jest.preset.js';
101
+ const jestPreset = (0, internal_4.findRootJestPreset)(host) ?? 'jest.preset.js';
102
102
  const tsConfigFile = options.isUsingTsSolutionConfig
103
103
  ? 'tsconfig.json'
104
104
  : 'tsconfig.spec.json';
@@ -146,7 +146,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
146
146
  host.rename(jestConfigPath, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'jest.config.cts'));
147
147
  }
148
148
  if (options.isUsingTsSolutionConfig) {
149
- (0, internal_4.addSwcTestConfig)(host, options.e2eProjectRoot, 'es6');
149
+ (0, internal_2.addSwcTestConfig)(host, options.e2eProjectRoot, 'es6');
150
150
  (0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/ts-solution'), options.e2eProjectRoot, {
151
151
  ...options,
152
152
  relativeProjectReferencePath: (0, posix_1.relative)(options.e2eProjectRoot, appProject.root),
@@ -164,6 +164,19 @@ async function e2eProjectGeneratorInternal(host, _options) {
164
164
  // axios is more than likely used in the application code, so install it as a regular dependency.
165
165
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { axios: versions_1.axiosVersion }, {});
166
166
  tasks.push(installTask);
167
+ if (options.linter &&
168
+ options.linter !== 'eslint' &&
169
+ options.linter !== 'none') {
170
+ tasks.push(await (0, internal_2.addLintingToProject)(host, {
171
+ linter: options.linter,
172
+ project: options.e2eProjectName,
173
+ rootProject: options.rootProject,
174
+ addPlugin: options.addPlugin,
175
+ // The generated e2e specs are Jest; this is what enables the linter's
176
+ // Jest rules.
177
+ unitTestRunner: 'jest',
178
+ }));
179
+ }
167
180
  if (options.linter === 'eslint') {
168
181
  const linterTask = await (0, eslint_1.lintProjectGenerator)(host, {
169
182
  project: options.e2eProjectName,
@@ -178,11 +191,11 @@ async function e2eProjectGeneratorInternal(host, _options) {
178
191
  addPlugin: options.addPlugin,
179
192
  });
180
193
  tasks.push(linterTask);
181
- if (options.rootProject && (0, internal_2.isEslintConfigSupported)(host)) {
182
- (0, internal_2.addPluginsToLintConfig)(host, options.e2eProjectRoot, '@nx');
183
- (0, internal_2.replaceOverridesInLintConfig)(host, options.e2eProjectRoot, [
184
- internal_2.typeScriptOverride,
185
- internal_2.javaScriptOverride,
194
+ if (options.rootProject && (0, internal_3.isEslintConfigSupported)(host)) {
195
+ (0, internal_3.addPluginsToLintConfig)(host, options.e2eProjectRoot, '@nx');
196
+ (0, internal_3.replaceOverridesInLintConfig)(host, options.e2eProjectRoot, [
197
+ internal_3.typeScriptOverride,
198
+ internal_3.javaScriptOverride,
186
199
  ]);
187
200
  }
188
201
  }
@@ -199,7 +212,7 @@ async function e2eProjectGeneratorInternal(host, _options) {
199
212
  // If we are using the new TS solution
200
213
  // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
201
214
  if (options.isUsingTsSolutionConfig) {
202
- await (0, internal_4.addProjectToTsSolutionWorkspace)(host, options.e2eProjectRoot);
215
+ await (0, internal_2.addProjectToTsSolutionWorkspace)(host, options.e2eProjectRoot);
203
216
  }
204
217
  if (!options.skipFormat) {
205
218
  await (0, devkit_1.formatFiles)(host);
@@ -223,10 +236,13 @@ async function normalizeOptions(tree, options) {
223
236
  const nxJson = (0, devkit_1.readNxJson)(tree);
224
237
  const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
225
238
  nxJson.useInferencePlugins !== false;
226
- const isUsingTsSolutionConfig = (0, internal_4.isUsingTsSolutionSetup)(tree);
239
+ const isUsingTsSolutionConfig = (0, internal_2.isUsingTsSolutionSetup)(tree);
227
240
  return {
228
241
  addPlugin,
229
242
  ...options,
243
+ // Both arms below test for a concrete linter, so an unresolved `undefined`
244
+ // would fall through them and leave the e2e project with no linter at all.
245
+ linter: await (0, internal_2.normalizeLinterOption)(tree, options.linter),
230
246
  e2eProjectRoot,
231
247
  e2eProjectName,
232
248
  importPath,
@@ -4,7 +4,7 @@ export interface Schema {
4
4
  directory?: string;
5
5
  name?: string;
6
6
  port?: number;
7
- linter?: 'eslint' | 'none';
7
+ linter?: 'eslint' | 'oxlint' | 'none';
8
8
  rootProject?: boolean;
9
9
  isNest?: boolean;
10
10
  skipFormat?: boolean;
@@ -9,7 +9,10 @@
9
9
  "project": {
10
10
  "type": "string",
11
11
  "description": "The name of the project.",
12
- "$default": { "$source": "argv", "index": 0 },
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
13
16
  "x-dropdown": "project",
14
17
  "x-prompt": "What project is this for?"
15
18
  },
@@ -34,10 +37,9 @@
34
37
  "default": 3000
35
38
  },
36
39
  "linter": {
37
- "description": "Linter to be used for the E2E project",
40
+ "description": "Linter to be used for the E2E project. Defaults to the linter the workspace already uses.",
38
41
  "type": "string",
39
- "enum": ["eslint", "none"],
40
- "default": "eslint"
42
+ "enum": ["eslint", "oxlint", "none"]
41
43
  },
42
44
  "isNest": {
43
45
  "description": "Is the E2E server project nest",
@@ -1,4 +1,4 @@
1
- import type { Linter, LinterType } from '@nx/eslint';
1
+ import type { LinterType } from '@nx/js';
2
2
 
3
3
  export interface Schema {
4
4
  directory: string;
@@ -8,7 +8,7 @@ export interface Schema {
8
8
  skipFormat?: boolean;
9
9
  tags?: string;
10
10
  unitTestRunner?: 'jest' | 'none';
11
- linter?: Linter | LinterType;
11
+ linter?: LinterType;
12
12
  buildable?: boolean;
13
13
  publishable?: boolean;
14
14
  importPath?: string;
@@ -34,11 +34,9 @@
34
34
  "default": false
35
35
  },
36
36
  "linter": {
37
- "description": "The tool to use for running lint checks.",
37
+ "description": "The tool to use for running lint checks. Defaults to the linter the workspace already uses.",
38
38
  "type": "string",
39
- "enum": ["eslint", "none"],
40
- "default": "none",
41
- "x-prompt": "Which linter would you like to use?",
39
+ "enum": ["eslint", "oxlint", "none"],
42
40
  "x-priority": "important"
43
41
  },
44
42
  "unitTestRunner": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/node",
3
- "version": "23.2.0-beta.6",
3
+ "version": "23.2.0-beta.7",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -73,15 +73,15 @@
73
73
  "semver": "^7.6.3",
74
74
  "tcp-port-used": "^1.0.2",
75
75
  "kill-port": "^1.6.1",
76
- "@nx/devkit": "23.2.0-beta.6",
77
- "@nx/jest": "23.2.0-beta.6",
78
- "@nx/js": "23.2.0-beta.6",
79
- "@nx/eslint": "23.2.0-beta.6",
80
- "@nx/docker": "23.2.0-beta.6"
76
+ "@nx/devkit": "23.2.0-beta.7",
77
+ "@nx/jest": "23.2.0-beta.7",
78
+ "@nx/js": "23.2.0-beta.7",
79
+ "@nx/eslint": "23.2.0-beta.7",
80
+ "@nx/docker": "23.2.0-beta.7"
81
81
  },
82
82
  "devDependencies": {
83
- "nx": "23.2.0-beta.6",
84
- "@nx/webpack": "23.2.0-beta.6"
83
+ "nx": "23.2.0-beta.7",
84
+ "@nx/webpack": "23.2.0-beta.7"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "express": ">=4.0.0 <6.0.0",