@nx/react-native 18.0.0-canary.20240202-ea5befb → 18.0.0

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.
package/generators.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "extends": ["@nx/workspace"],
5
5
  "generators": {
6
6
  "init": {
7
- "factory": "./src/generators/init/init#reactNativeInitGenerator",
7
+ "factory": "./src/generators/init/init#reactNativeInitGeneratorInternal",
8
8
  "schema": "./src/generators/init/schema.json",
9
9
  "description": "Initialize the `@nx/react-native` plugin.",
10
10
  "hidden": true
@@ -30,7 +30,7 @@
30
30
  "aliases": ["c"]
31
31
  },
32
32
  "storybook-configuration": {
33
- "factory": "./src/generators/storybook-configuration/configuration#storybookConfigurationGenerator",
33
+ "factory": "./src/generators/storybook-configuration/configuration#storybookConfigurationGeneratorInternal",
34
34
  "schema": "./src/generators/storybook-configuration/schema.json",
35
35
  "description": "Set up Storybook for a React Native application or library."
36
36
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react-native",
3
- "version": "18.0.0-canary.20240202-ea5befb",
3
+ "version": "18.0.0",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides: \n\n-Integration with libraries such as Jest, Detox, and Storybook.\n-Scaffolding for creating buildable libraries that can be published to npm.\n-Utilities for automatic workspace refactoring.",
6
6
  "keywords": [
@@ -35,13 +35,13 @@
35
35
  "node-fetch": "^2.6.7",
36
36
  "tsconfig-paths": "^4.1.2",
37
37
  "tslib": "^2.3.0",
38
- "@nx/devkit": "18.0.0-canary.20240202-ea5befb",
39
- "@nx/jest": "18.0.0-canary.20240202-ea5befb",
40
- "@nx/js": "18.0.0-canary.20240202-ea5befb",
41
- "@nx/eslint": "18.0.0-canary.20240202-ea5befb",
42
- "@nx/react": "18.0.0-canary.20240202-ea5befb",
43
- "@nx/workspace": "18.0.0-canary.20240202-ea5befb",
44
- "@nrwl/react-native": "18.0.0-canary.20240202-ea5befb"
38
+ "@nx/devkit": "18.0.0",
39
+ "@nx/jest": "18.0.0",
40
+ "@nx/js": "18.0.0",
41
+ "@nx/eslint": "18.0.0",
42
+ "@nx/react": "18.0.0",
43
+ "@nx/workspace": "18.0.0",
44
+ "@nrwl/react-native": "18.0.0"
45
45
  },
46
46
  "executors": "./executors.json",
47
47
  "ng-update": {
@@ -7,6 +7,8 @@ export interface ReactNativePluginOptions {
7
7
  buildIosTargetName?: string;
8
8
  buildAndroidTargetName?: string;
9
9
  bundleTargetName?: string;
10
+ syncDepsTargetName?: string;
11
+ upgradeTargetname?: string;
10
12
  }
11
13
  export declare const createDependencies: CreateDependencies;
12
14
  export declare const createNodes: CreateNodes<ReactNativePluginOptions>;
package/plugins/plugin.js CHANGED
@@ -57,11 +57,13 @@ function buildReactNativeTargets(projectRoot, options, context) {
57
57
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
58
58
  const targets = {
59
59
  [options.startTargetName]: {
60
- executor: `@nx/react-native:start`,
60
+ command: `react-native start`,
61
+ options: { cwd: projectRoot },
61
62
  },
62
63
  [options.podInstallTargetName]: {
63
64
  command: `pod install`,
64
65
  options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot, 'ios') },
66
+ dependsOn: [`${options.syncDepsTargetName}`],
65
67
  cache: true,
66
68
  inputs: getInputs(namedInputs),
67
69
  outputs: [
@@ -99,6 +101,13 @@ function buildReactNativeTargets(projectRoot, options, context) {
99
101
  dependsOn: [`^${options.bundleTargetName}`],
100
102
  inputs: getInputs(namedInputs),
101
103
  },
104
+ [options.syncDepsTargetName]: {
105
+ executor: '@nx/react-native:sync-deps',
106
+ },
107
+ [options.upgradeTargetname]: {
108
+ command: `react-native upgrade`,
109
+ options: { cwd: projectRoot },
110
+ },
102
111
  };
103
112
  return targets;
104
113
  }
@@ -147,5 +156,7 @@ function normalizeOptions(options) {
147
156
  options.buildIosTargetName ??= 'build-ios';
148
157
  options.buildAndroidTargetName ??= 'build-android';
149
158
  options.bundleTargetName ??= 'bundle';
159
+ options.syncDepsTargetName ??= 'sync-deps';
160
+ options.upgradeTargetname ??= 'upgrade';
150
161
  return options;
151
162
  }
@@ -18,6 +18,7 @@ const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
18
18
  const sync_deps_impl_1 = require("../../executors/sync-deps/sync-deps.impl");
19
19
  async function reactNativeApplicationGenerator(host, schema) {
20
20
  return await reactNativeApplicationGeneratorInternal(host, {
21
+ addPlugin: false,
21
22
  projectNameAndRootFormat: 'derived',
22
23
  ...schema,
23
24
  });
@@ -46,7 +47,7 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
46
47
  ],
47
48
  });
48
49
  tasks.push(lintTask);
49
- const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson);
50
+ const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson, options.addPlugin);
50
51
  tasks.push(jestTask);
51
52
  const webTask = await (0, web_configuration_1.webConfigurationGenerator)(host, {
52
53
  ...options,
@@ -108,8 +108,8 @@ describe('app', () => {
108
108
  unitTestRunner: 'jest',
109
109
  bundler: 'vite',
110
110
  });
111
- const targets = readProjectConfiguration(appTree, 'my-app').targets;
112
- expect(targets.test).toBeDefined();
111
+
112
+ expect(appTree.exists('my-app/jest.config.ts')).toBeTruthy();
113
113
  });
114
114
 
115
115
  it('should extend from root tsconfig.json when no tsconfig.base.json', async () => {
@@ -24,7 +24,6 @@ async function addE2e(host, options) {
24
24
  hasStyles: false,
25
25
  unitTestRunner: 'none',
26
26
  });
27
- case 'detox':
28
27
  case 'detox':
29
28
  const { detoxApplicationGenerator } = (0, devkit_1.ensurePackage)('@nx/detox', versions_1.nxVersion);
30
29
  return detoxApplicationGenerator(host, {
@@ -12,6 +12,7 @@ async function normalizeOptions(host, options) {
12
12
  callingGenerator: '@nx/react-native:application',
13
13
  });
14
14
  options.projectNameAndRootFormat = projectNameAndRootFormat;
15
+ options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
15
16
  const { className, fileName } = (0, devkit_1.names)(options.name);
16
17
  const iosProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'ios');
17
18
  const androidProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'android');
@@ -23,6 +23,7 @@ describe('Normalize Options', () => {
23
23
  };
24
24
  const options = await normalizeOptions(appTree, schema);
25
25
  expect(options).toEqual({
26
+ addPlugin: true,
26
27
  androidProjectRoot: 'my-app/android',
27
28
  appProjectRoot: 'my-app',
28
29
  fileName: 'my-app',
@@ -58,6 +59,7 @@ describe('Normalize Options', () => {
58
59
  };
59
60
  const options = await normalizeOptions(appTree, schema);
60
61
  expect(options).toEqual({
62
+ addPlugin: true,
61
63
  androidProjectRoot: 'myApp/android',
62
64
  appProjectRoot: 'myApp',
63
65
  className: 'MyApp',
@@ -94,6 +96,7 @@ describe('Normalize Options', () => {
94
96
  };
95
97
  const options = await normalizeOptions(appTree, schema);
96
98
  expect(options).toEqual({
99
+ addPlugin: true,
97
100
  androidProjectRoot: 'directory/my-app/android',
98
101
  appProjectRoot: 'directory/my-app',
99
102
  className: 'MyApp',
@@ -130,6 +133,7 @@ describe('Normalize Options', () => {
130
133
  };
131
134
  const options = await normalizeOptions(appTree, schema);
132
135
  expect(options).toEqual({
136
+ addPlugin: true,
133
137
  androidProjectRoot: 'directory/my-app/android',
134
138
  appProjectRoot: 'directory/my-app',
135
139
  className: 'DirectoryMyApp',
@@ -166,6 +170,7 @@ describe('Normalize Options', () => {
166
170
  };
167
171
  const options = await normalizeOptions(appTree, schema);
168
172
  expect(options).toEqual({
173
+ addPlugin: true,
169
174
  androidProjectRoot: 'my-app/android',
170
175
  appProjectRoot: 'my-app',
171
176
  className: 'MyApp',
@@ -19,4 +19,5 @@ export interface Schema {
19
19
  bundler: 'webpack' | 'vite'; // default is webpack
20
20
  install: boolean; // default is true
21
21
  skipPackageJson?: boolean; //default is false
22
+ addPlugin?: boolean;
22
23
  }
@@ -1,5 +1,6 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function reactNativeInitGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function reactNativeInitGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
5
  export declare function updateDependencies(host: Tree, schema: Schema): GeneratorCallback;
5
6
  export default reactNativeInitGenerator;
@@ -1,14 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateDependencies = exports.reactNativeInitGenerator = void 0;
3
+ exports.updateDependencies = exports.reactNativeInitGeneratorInternal = exports.reactNativeInitGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
6
6
  const plugin_1 = require("../../../plugins/plugin");
7
7
  const versions_1 = require("../../utils/versions");
8
8
  const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
9
- async function reactNativeInitGenerator(host, schema) {
9
+ function reactNativeInitGenerator(host, schema) {
10
+ return reactNativeInitGeneratorInternal(host, {
11
+ addPlugin: false,
12
+ ...schema,
13
+ });
14
+ }
15
+ exports.reactNativeInitGenerator = reactNativeInitGenerator;
16
+ async function reactNativeInitGeneratorInternal(host, schema) {
10
17
  (0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
11
- if (process.env.NX_PCV3 === 'true') {
18
+ schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
19
+ if (schema.addPlugin) {
12
20
  addPlugin(host);
13
21
  }
14
22
  const tasks = [];
@@ -24,7 +32,7 @@ async function reactNativeInitGenerator(host, schema) {
24
32
  }
25
33
  return (0, devkit_1.runTasksInSerial)(...tasks);
26
34
  }
27
- exports.reactNativeInitGenerator = reactNativeInitGenerator;
35
+ exports.reactNativeInitGeneratorInternal = reactNativeInitGeneratorInternal;
28
36
  function updateDependencies(host, schema) {
29
37
  return (0, devkit_1.addDependenciesToPackageJson)(host, {
30
38
  react: versions_1.reactVersion,
@@ -58,6 +66,8 @@ function addPlugin(host) {
58
66
  runAndroidTargetName: 'run-android',
59
67
  buildIosTargetName: 'build-ios',
60
68
  buildAndroidTargetName: 'build-android',
69
+ syncDepsTargetName: 'sync-deps',
70
+ upgradeTargetname: 'upgrade',
61
71
  },
62
72
  });
63
73
  (0, devkit_1.updateNxJson)(host, nxJson);
@@ -11,7 +11,9 @@ describe('init', () => {
11
11
  });
12
12
 
13
13
  it('should add react native dependencies', async () => {
14
- await reactNativeInitGenerator(tree, {});
14
+ await reactNativeInitGenerator(tree, {
15
+ addPlugin: true,
16
+ });
15
17
  const packageJson = readJson(tree, 'package.json');
16
18
  expect(packageJson.dependencies['react']).toBeDefined();
17
19
  expect(packageJson.dependencies['react-native']).toBeDefined();
@@ -24,7 +26,9 @@ describe('init', () => {
24
26
  /node_modules
25
27
  `
26
28
  );
27
- await reactNativeInitGenerator(tree, {});
29
+ await reactNativeInitGenerator(tree, {
30
+ addPlugin: true,
31
+ });
28
32
 
29
33
  const content = tree.read('/.gitignore').toString();
30
34
 
@@ -3,4 +3,5 @@ export interface Schema {
3
3
  skipPackageJson?: boolean; //default is false
4
4
  keepExistingVersions?: boolean; //default is false
5
5
  updatePackageScripts?: boolean;
6
+ addPlugin?: boolean;
6
7
  }
@@ -11,6 +11,7 @@ async function normalizeOptions(host, options) {
11
11
  projectNameAndRootFormat: options.projectNameAndRootFormat,
12
12
  callingGenerator: '@nx/react-native:library',
13
13
  });
14
+ options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
14
15
  const parsedTags = options.tags
15
16
  ? options.tags.split(',').map((s) => s.trim())
16
17
  : [];
@@ -12,6 +12,7 @@ const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
12
12
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
13
13
  async function reactNativeLibraryGenerator(host, schema) {
14
14
  return await reactNativeLibraryGeneratorInternal(host, {
15
+ addPlugin: false,
15
16
  projectNameAndRootFormat: 'derived',
16
17
  ...schema,
17
18
  });
@@ -46,7 +47,7 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
46
47
  ],
47
48
  });
48
49
  tasks.push(lintTask);
49
- const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson);
50
+ const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin);
50
51
  tasks.push(jestTask);
51
52
  if (options.publishable || options.buildable) {
52
53
  updateLibPackageNpmScope(host, options);
@@ -20,6 +20,7 @@ describe('lib', () => {
20
20
  unitTestRunner: 'jest',
21
21
  strict: true,
22
22
  projectNameAndRootFormat: 'as-provided',
23
+ addPlugin: true,
23
24
  };
24
25
 
25
26
  beforeEach(() => {
@@ -28,17 +29,6 @@ describe('lib', () => {
28
29
  });
29
30
 
30
31
  describe('not nested', () => {
31
- it('should update project.json', async () => {
32
- await libraryGenerator(appTree, { ...defaultSchema, tags: 'one,two' });
33
- const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
34
- expect(projectConfiguration.root).toEqual('my-lib');
35
- expect(projectConfiguration.targets.build).toBeUndefined();
36
- expect(projectConfiguration.targets.lint).toEqual({
37
- executor: '@nx/eslint:lint',
38
- });
39
- expect(projectConfiguration.tags).toEqual(['one', 'two']);
40
- });
41
-
42
32
  it('should update root tsconfig.base.json', async () => {
43
33
  await libraryGenerator(appTree, defaultSchema);
44
34
  const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
@@ -145,19 +135,6 @@ describe('lib', () => {
145
135
  });
146
136
  });
147
137
 
148
- it('should update project.json', async () => {
149
- await libraryGenerator(appTree, {
150
- ...defaultSchema,
151
- directory: 'my-dir',
152
- });
153
- const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
154
-
155
- expect(projectConfiguration.root).toEqual('my-dir');
156
- expect(projectConfiguration.targets.lint).toEqual({
157
- executor: '@nx/eslint:lint',
158
- });
159
- });
160
-
161
138
  it('should update root tsconfig.base.json', async () => {
162
139
  await libraryGenerator(appTree, {
163
140
  ...defaultSchema,
@@ -229,11 +206,6 @@ describe('lib', () => {
229
206
 
230
207
  expect(appTree.exists('my-lib/tsconfig.spec.json')).toBeFalsy();
231
208
  expect(appTree.exists('my-lib/jest.config.ts')).toBeFalsy();
232
- const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
233
- expect(projectConfiguration.targets.test).toBeUndefined();
234
- expect(projectConfiguration.targets.lint).toMatchObject({
235
- executor: '@nx/eslint:lint',
236
- });
237
209
  });
238
210
 
239
211
  it('should generate test configuration', async () => {
@@ -292,18 +264,6 @@ describe('lib', () => {
292
264
  };
293
265
  "
294
266
  `);
295
- const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
296
- expect(projectConfiguration.targets.test).toMatchInlineSnapshot(`
297
- {
298
- "executor": "@nx/jest:jest",
299
- "options": {
300
- "jestConfig": "my-lib/jest.config.ts",
301
- },
302
- "outputs": [
303
- "{workspaceRoot}/coverage/{projectRoot}",
304
- ],
305
- }
306
- `);
307
267
  });
308
268
  });
309
269
 
@@ -21,4 +21,5 @@ export interface Schema {
21
21
  strict?: boolean;
22
22
  setParserOptionsProject?: boolean;
23
23
  skipPackageJson?: boolean; //default is false
24
+ addPlugin?: boolean;
24
25
  }
@@ -1,8 +1,9 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { StorybookConfigureSchema } from './schema';
3
+ export declare function storybookConfigurationGenerator(tree: Tree, schema: StorybookConfigureSchema): Promise<import("@nx/devkit").GeneratorCallback>;
3
4
  /**
4
5
  * This would be a direct pass through to @nx/react:storybook-configuration generator.
5
6
  * @TODO (@xiongemi): remove this generator for v19
6
7
  */
7
- export declare function storybookConfigurationGenerator(host: Tree, schema: StorybookConfigureSchema): Promise<import("@nx/devkit").GeneratorCallback>;
8
+ export declare function storybookConfigurationGeneratorInternal(host: Tree, schema: StorybookConfigureSchema): Promise<import("@nx/devkit").GeneratorCallback>;
8
9
  export default storybookConfigurationGenerator;
@@ -1,15 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.storybookConfigurationGenerator = void 0;
3
+ exports.storybookConfigurationGeneratorInternal = exports.storybookConfigurationGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const react_1 = require("@nx/react");
6
+ function storybookConfigurationGenerator(tree, schema) {
7
+ return storybookConfigurationGeneratorInternal(tree, {
8
+ addPlugin: false,
9
+ ...schema,
10
+ });
11
+ }
12
+ exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
6
13
  /**
7
14
  * This would be a direct pass through to @nx/react:storybook-configuration generator.
8
15
  * @TODO (@xiongemi): remove this generator for v19
9
16
  */
10
- async function storybookConfigurationGenerator(host, schema) {
17
+ async function storybookConfigurationGeneratorInternal(host, schema) {
11
18
  devkit_1.logger.warn(`Please run 'nx run @nx/react:storybook-configuration ${schema.project}' instead.`);
19
+ schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
12
20
  return (0, react_1.storybookConfigurationGenerator)(host, schema);
13
21
  }
14
- exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
22
+ exports.storybookConfigurationGeneratorInternal = storybookConfigurationGeneratorInternal;
15
23
  exports.default = storybookConfigurationGenerator;
@@ -9,4 +9,5 @@ export interface StorybookConfigureSchema {
9
9
  linter?: Linter;
10
10
  ignorePaths?: string[];
11
11
  configureStaticServe?: boolean;
12
+ addPlugin?: boolean;
12
13
  }
@@ -55,6 +55,7 @@ async function addBundlerConfiguration(tree, normalizedSchema) {
55
55
  if (normalizedSchema.bundler === 'vite') {
56
56
  const { viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
57
57
  const viteTask = await viteConfigurationGenerator(tree, {
58
+ ...normalizedSchema,
58
59
  uiFramework: 'react',
59
60
  project: normalizedSchema.project,
60
61
  newProject: true,
@@ -67,6 +68,7 @@ async function addBundlerConfiguration(tree, normalizedSchema) {
67
68
  else {
68
69
  const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
69
70
  const webpackInitTask = await webpackInitGenerator(tree, {
71
+ ...normalizedSchema,
70
72
  skipFormat: true,
71
73
  skipPackageJson: normalizedSchema.skipPackageJson,
72
74
  });
@@ -13,7 +13,9 @@ async function update(tree) {
13
13
  let content = tree
14
14
  .read((0, devkit_1.joinPathFragments)(config.root, 'metro.config.js'))
15
15
  .toString();
16
- content = content.replace(`blockList: exclusionList([/^(?!.*node_modules).*/dist/.*/]),`, '');
16
+ content = content.replace(/blockList: exclusionList(.+?(?=\n))/, '');
17
+ content = content.replace('// unstable_enableSymlinks: true,', '');
18
+ content = content.replace('// unstable_enablePackageExports: true,', '');
17
19
  content = content.replace('unstable_enableSymlinks: true,', '');
18
20
  content = content.replace('unstable_enablePackageExports: true,', '');
19
21
  content = content.replace(`const exclusionList = require('metro-config/src/defaults/exclusionList');`, '');
@@ -1,2 +1,2 @@
1
1
  import { Tree } from '@nx/devkit';
2
- export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
2
+ export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean, addPlugin: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addJest = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const jest_1 = require("@nx/jest");
6
- async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson) {
6
+ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson, addPlugin) {
7
7
  if (unitTestRunner !== 'jest') {
8
8
  return () => { };
9
9
  }
@@ -16,6 +16,7 @@ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, sk
16
16
  compiler: 'babel',
17
17
  skipPackageJson,
18
18
  skipFormat: true,
19
+ addPlugin,
19
20
  });
20
21
  // overwrite the jest.config.ts file because react native needs to have special transform property
21
22
  const configPath = `${appProjectRoot}/jest.config.${js ? 'js' : 'ts'}`;
@@ -7,6 +7,7 @@ interface NormalizedSchema {
7
7
  setParserOptionsProject?: boolean;
8
8
  tsConfigPaths: string[];
9
9
  skipPackageJson?: boolean;
10
+ addPlugin?: boolean;
10
11
  }
11
12
  export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
12
13
  export {};
@@ -16,6 +16,7 @@ async function addLinting(host, options) {
16
16
  tsConfigPaths: options.tsConfigPaths,
17
17
  skipFormat: true,
18
18
  skipPackageJson: options.skipPackageJson,
19
+ addPlugin: options.addPlugin,
19
20
  });
20
21
  tasks.push(lintTask);
21
22
  if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
@@ -15,17 +15,15 @@ describe('Add Linting', () => {
15
15
  });
16
16
  });
17
17
 
18
- it('should add update configuration when eslint is passed', async () => {
18
+ it('should add a .eslintrc.json when is passed', async () => {
19
19
  await addLinting(tree, {
20
20
  projectName: 'my-lib',
21
21
  linter: Linter.EsLint,
22
22
  tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
23
23
  projectRoot: 'libs/my-lib',
24
24
  });
25
- const project = readProjectConfiguration(tree, 'my-lib');
26
25
 
27
- expect(project.targets.lint).toBeDefined();
28
- expect(project.targets.lint.executor).toEqual('@nx/eslint:lint');
26
+ expect(tree.exists('libs/my-lib/.eslintrc.json')).toBeTruthy();
29
27
  });
30
28
 
31
29
  it('should not add lint target when "none" is passed', async () => {