@angular-eslint/schematics 17.5.3-alpha.1 → 17.5.3

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/README.md CHANGED
@@ -1,5 +1 @@
1
1
  # @angular-eslint/schematics
2
-
3
- Please see https://github.com/angular-eslint/angular-eslint for full usage instructions and guidance.
4
-
5
- The `@angular-eslint/schematics` package is a set of custom Angular CLI Schematics which are used to add and update dependencies and configuration files which are relevant for running ESLint on an Angular workspace.
@@ -1,7 +1,8 @@
1
+ import type { Rule } from '@angular-devkit/schematics';
1
2
  interface Schema {
2
3
  project?: string;
3
4
  setParserOptionsProject?: boolean;
4
5
  }
5
- declare const _default: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
6
- export default _default;
6
+ export default function addESLintToProject(schema: Schema): Rule;
7
+ export {};
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/add-eslint-to-project/index.ts"],"names":[],"mappings":"AAQA,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;;AAED,wBAsBG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/add-eslint-to-project/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAQ,MAAM,4BAA4B,CAAC;AAQ7D,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAuB/D"}
@@ -1,19 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_imports_1 = require("../devkit-imports");
3
+ const schematics_1 = require("@angular-devkit/schematics");
4
4
  const utils_1 = require("../utils");
5
- exports.default = (0, devkit_imports_1.convertNxGenerator)(async (tree, options) => {
6
- const projectName = (0, utils_1.determineTargetProjectName)(tree, options.project);
7
- if (!projectName) {
8
- throw new Error('\n' +
9
- `
5
+ function addESLintToProject(schema) {
6
+ return (tree) => {
7
+ const projectName = (0, utils_1.determineTargetProjectName)(tree, schema.project);
8
+ if (!projectName) {
9
+ throw new Error('\n' +
10
+ `
10
11
  Error: You must specify a project to add ESLint to because you have multiple projects in your angular.json
11
12
 
12
13
  E.g. npx ng g @angular-eslint/schematics:add-eslint-to-project {{YOUR_PROJECT_NAME_GOES_HERE}}
13
- `.trim());
14
- }
15
- // Create the config file first so that we can check for its existence when setting the target
16
- (0, utils_1.createESLintConfigForProject)(tree, projectName, options.setParserOptionsProject ?? false);
17
- // Update the lint builder and config in angular.json
18
- (0, utils_1.addESLintTargetToProject)(tree, projectName, 'lint');
19
- });
14
+ `.trim());
15
+ }
16
+ return (0, schematics_1.chain)([
17
+ // Create the ESLint config file for the project
18
+ (0, utils_1.createESLintConfigForProject)(projectName, schema.setParserOptionsProject ?? false),
19
+ // Set the lint builder and config in angular.json
20
+ (0, utils_1.addESLintTargetToProject)(projectName, 'lint'),
21
+ ]);
22
+ };
23
+ }
24
+ exports.default = addESLintToProject;
@@ -1,3 +1,4 @@
1
+ import type { Rule } from '@angular-devkit/schematics';
1
2
  /**
2
3
  * We are able to use the full, unaltered Schema directly from @schematics/angular
3
4
  * The applicable json file is copied from node_modules as a prebuiid step to ensure
@@ -7,6 +8,6 @@ import type { Schema as AngularSchema } from '@schematics/angular/application/sc
7
8
  interface Schema extends AngularSchema {
8
9
  setParserOptionsProject?: boolean;
9
10
  }
10
- declare const _default: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
11
- export default _default;
11
+ export default function (options: Schema): Rule;
12
+ export {};
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAWtF,UAAU,MAAO,SAAQ,aAAa;IACpC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;;AAED,wBAqBG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAE/E;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAMtF,UAAU,MAAO,SAAQ,aAAa;IACpC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAcD,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,MAAM,GAAG,IAAI,CAW9C"}
@@ -1,15 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_imports_1 = require("../devkit-imports");
3
+ const schematics_1 = require("@angular-devkit/schematics");
4
4
  const utils_1 = require("../utils");
5
- exports.default = (0, devkit_imports_1.convertNxGenerator)(async (tree, options) => {
6
- // Remove angular-eslint specific options before passing to the Angular schematic
7
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
- const { setParserOptionsProject, ...angularOptions } = options;
9
- const applicationGenerator = (0, devkit_imports_1.wrapAngularDevkitSchematic)('@schematics/angular', 'application');
10
- await applicationGenerator(tree, angularOptions);
11
- // Create the config file first so that we can check for its existence when setting the target
12
- (0, utils_1.createESLintConfigForProject)(tree, options.name, options.setParserOptionsProject ?? false);
13
- // Update the lint builder and config in angular.json
14
- (0, utils_1.addESLintTargetToProject)(tree, options.name, 'lint');
15
- });
5
+ function eslintRelatedChanges(options) {
6
+ return (0, schematics_1.chain)([
7
+ // Create the ESLint config file for the project
8
+ (0, utils_1.createESLintConfigForProject)(options.name, options.setParserOptionsProject ?? false),
9
+ // Update the lint builder and config in angular.json
10
+ (0, utils_1.addESLintTargetToProject)(options.name, 'lint'),
11
+ ]);
12
+ }
13
+ function default_1(options) {
14
+ return (host, context) => {
15
+ // Remove angular-eslint specific options before passing to the Angular schematic
16
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
+ const { setParserOptionsProject, ...angularOptions } = options;
18
+ return (0, schematics_1.chain)([
19
+ (0, schematics_1.externalSchematic)('@schematics/angular', 'application', angularOptions),
20
+ eslintRelatedChanges(options),
21
+ ])(host, context);
22
+ };
23
+ }
24
+ exports.default = default_1;
@@ -1,3 +1,4 @@
1
+ import type { Rule } from '@angular-devkit/schematics';
1
2
  /**
2
3
  * We are able to use the full, unaltered Schema directly from @schematics/angular
3
4
  * The applicable json file is copied from node_modules as a prebuiid step to ensure
@@ -7,6 +8,6 @@ import type { Schema as AngularSchema } from '@schematics/angular/library/schema
7
8
  interface Schema extends AngularSchema {
8
9
  setParserOptionsProject?: boolean;
9
10
  }
10
- declare const _default: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
11
- export default _default;
11
+ export default function (options: Schema): Rule;
12
+ export {};
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/library/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAWlF,UAAU,MAAO,SAAQ,aAAa;IACpC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;;AAED,wBAqBG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/library/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAE/E;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAMlF,UAAU,MAAO,SAAQ,aAAa;IACpC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAcD,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,MAAM,GAAG,IAAI,CAW9C"}
@@ -1,15 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_imports_1 = require("../devkit-imports");
3
+ const schematics_1 = require("@angular-devkit/schematics");
4
4
  const utils_1 = require("../utils");
5
- exports.default = (0, devkit_imports_1.convertNxGenerator)(async (tree, options) => {
6
- // Remove angular-eslint specific options before passing to the Angular schematic
7
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
- const { setParserOptionsProject, ...angularOptions } = options;
9
- const libraryGenerator = (0, devkit_imports_1.wrapAngularDevkitSchematic)('@schematics/angular', 'library');
10
- await libraryGenerator(tree, angularOptions);
11
- // Create the config file first so that we can check for its existence when setting the target
12
- (0, utils_1.createESLintConfigForProject)(tree, options.name, options.setParserOptionsProject ?? false);
13
- // Update the lint builder and config in angular.json
14
- (0, utils_1.addESLintTargetToProject)(tree, options.name, 'lint');
15
- });
5
+ function eslintRelatedChanges(options) {
6
+ return (0, schematics_1.chain)([
7
+ // Create the ESLint config file for the project
8
+ (0, utils_1.createESLintConfigForProject)(options.name, options.setParserOptionsProject ?? false),
9
+ // Update the lint builder and config in angular.json
10
+ (0, utils_1.addESLintTargetToProject)(options.name, 'lint'),
11
+ ]);
12
+ }
13
+ function default_1(options) {
14
+ return (host, context) => {
15
+ // Remove angular-eslint specific options before passing to the Angular schematic
16
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
+ const { setParserOptionsProject, ...angularOptions } = options;
18
+ return (0, schematics_1.chain)([
19
+ (0, schematics_1.externalSchematic)('@schematics/angular', 'library', angularOptions),
20
+ eslintRelatedChanges(options),
21
+ ])(host, context);
22
+ };
23
+ }
24
+ exports.default = default_1;
@@ -1,5 +1,3 @@
1
1
  import type { Rule } from '@angular-devkit/schematics';
2
- export declare const FIXED_ESLINT_V8_VERSION = "8.57.0";
3
- export declare const FIXED_TYPESCRIPT_ESLINT_V7_VERSION = "7.11.0";
4
2
  export default function (): Rule;
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAc/E,eAAO,MAAM,uBAAuB,WAAW,CAAC;AAChD,eAAO,MAAM,kCAAkC,WAAW,CAAC;AA+K3D,MAAM,CAAC,OAAO,cAAc,IAAI,CAa/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAiJ/E,MAAM,CAAC,OAAO,cAAc,IAAI,CAwB/B"}
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FIXED_TYPESCRIPT_ESLINT_V7_VERSION = exports.FIXED_ESLINT_V8_VERSION = void 0;
4
3
  const schematics_1 = require("@angular-devkit/schematics");
5
4
  const tasks_1 = require("@angular-devkit/schematics/tasks");
6
5
  const utils_1 = require("../utils");
7
- exports.FIXED_ESLINT_V8_VERSION = '8.57.0';
8
- exports.FIXED_TYPESCRIPT_ESLINT_V7_VERSION = '7.11.0';
9
6
  // eslint-disable-next-line @typescript-eslint/no-var-requires
10
7
  const packageJSON = require('../../package.json');
11
- function addAngularESLintPackages(json, useFlatConfig) {
8
+ function addAngularESLintPackages() {
12
9
  return (host, context) => {
13
10
  if (!host.exists('package.json')) {
14
11
  throw new Error('Could not find a `package.json` file at the root of your workspace');
@@ -16,67 +13,50 @@ function addAngularESLintPackages(json, useFlatConfig) {
16
13
  if (host.exists('tsconfig.base.json')) {
17
14
  throw new Error('\nError: Angular CLI v10.1.0 and later (and no `tsconfig.base.json`) is required in order to run this schematic. Please update your workspace and try again.\n');
18
15
  }
16
+ const projectPackageJSON = host.read('package.json').toString('utf-8');
17
+ const json = JSON.parse(projectPackageJSON);
18
+ json.devDependencies = json.devDependencies || {};
19
+ json.devDependencies['eslint'] =
20
+ `^${packageJSON.devDependencies['eslint']}`;
19
21
  json.scripts = json.scripts || {};
20
22
  json.scripts['lint'] = json.scripts['lint'] || 'ng lint';
21
- if (useFlatConfig) {
22
- applyDevDependenciesForFlatConfig(json);
23
- }
24
- else {
25
- applyDevDependenciesForESLintRC(json);
23
+ /**
24
+ * @angular-eslint packages
25
+ */
26
+ json.devDependencies['@angular-eslint/builder'] = packageJSON.version;
27
+ json.devDependencies['@angular-eslint/eslint-plugin'] = packageJSON.version;
28
+ json.devDependencies['@angular-eslint/eslint-plugin-template'] =
29
+ packageJSON.version;
30
+ /**
31
+ * It seems in certain versions of Angular CLI `ng add` will automatically add the
32
+ * @angular-eslint/schematics package to the dependencies section, so clean that up
33
+ * at this point
34
+ */
35
+ if (json.dependencies?.['@angular-eslint/schematics']) {
36
+ delete json.dependencies['@angular-eslint/schematics'];
26
37
  }
38
+ json.devDependencies['@angular-eslint/schematics'] = packageJSON.version;
39
+ json.devDependencies['@angular-eslint/template-parser'] =
40
+ packageJSON.version;
41
+ /**
42
+ * @typescript-eslint packages
43
+ */
44
+ const typescriptESLintVersion = packageJSON.devDependencies['@typescript-eslint/utils'];
45
+ json.devDependencies['@typescript-eslint/eslint-plugin'] =
46
+ typescriptESLintVersion;
47
+ json.devDependencies['@typescript-eslint/parser'] = typescriptESLintVersion;
27
48
  json.devDependencies = (0, utils_1.sortObjectByKeys)(json.devDependencies);
28
49
  host.overwrite('package.json', JSON.stringify(json, null, 2));
29
50
  context.addTask(new tasks_1.NodePackageInstallTask());
30
51
  context.logger.info(`
31
- All angular-eslint dependencies have been successfully installed 🎉
52
+ All @angular-eslint dependencies have been successfully installed 🎉
32
53
 
33
54
  Please see https://github.com/angular-eslint/angular-eslint for how to add ESLint configuration to your project.
34
55
  `);
35
56
  return host;
36
57
  };
37
58
  }
38
- function applyDevDependenciesForESLintRC(json) {
39
- json.devDependencies['eslint'] = exports.FIXED_ESLINT_V8_VERSION;
40
- /**
41
- * @angular-eslint packages
42
- */
43
- json.devDependencies['@angular-eslint/builder'] = packageJSON.version;
44
- json.devDependencies['@angular-eslint/eslint-plugin'] = packageJSON.version;
45
- json.devDependencies['@angular-eslint/eslint-plugin-template'] =
46
- packageJSON.version;
47
- json.devDependencies['@angular-eslint/schematics'] = packageJSON.version;
48
- json.devDependencies['@angular-eslint/template-parser'] = packageJSON.version;
49
- /**
50
- * @typescript-eslint packages
51
- */
52
- json.devDependencies['@typescript-eslint/eslint-plugin'] =
53
- exports.FIXED_TYPESCRIPT_ESLINT_V7_VERSION;
54
- json.devDependencies['@typescript-eslint/parser'] =
55
- exports.FIXED_TYPESCRIPT_ESLINT_V7_VERSION;
56
- }
57
- function applyDevDependenciesForFlatConfig(json) {
58
- json.devDependencies['eslint'] = `^${packageJSON.devDependencies['eslint']}`;
59
- /**
60
- * angular-eslint packages
61
- */
62
- json.devDependencies['angular-eslint'] = packageJSON.version;
63
- // Clean up individual packages from devDependencies
64
- delete json.devDependencies['@angular-eslint/builder'];
65
- delete json.devDependencies['@angular-eslint/eslint-plugin'];
66
- delete json.devDependencies['@angular-eslint/eslint-plugin-template'];
67
- delete json.devDependencies['@angular-eslint/schematics'];
68
- delete json.devDependencies['@angular-eslint/template-parser'];
69
- /**
70
- * typescript-eslint
71
- */
72
- const typescriptESLintVersion = packageJSON.devDependencies['@typescript-eslint/utils'];
73
- json.devDependencies['typescript-eslint'] = typescriptESLintVersion;
74
- // Clean up individual packages from devDependencies
75
- delete json.devDependencies['@typescript-eslint/parser'];
76
- delete json.devDependencies['@typescript-eslint/eslint-plugin'];
77
- delete json.devDependencies['@typescript-eslint/utils'];
78
- }
79
- function applyESLintConfigIfSingleProjectWithNoExistingTSLint(useFlatConfig) {
59
+ function applyESLintConfigIfSingleProjectWithNoExistingTSLint() {
80
60
  return (host, context) => {
81
61
  const angularJson = (0, utils_1.readJsonInTree)(host, 'angular.json');
82
62
  if (!angularJson || !angularJson.projects) {
@@ -93,12 +73,7 @@ function applyESLintConfigIfSingleProjectWithNoExistingTSLint(useFlatConfig) {
93
73
  const projectNames = Object.keys(angularJson.projects);
94
74
  if (projectNames.length === 0) {
95
75
  return (0, schematics_1.chain)([
96
- useFlatConfig
97
- ? (host) => {
98
- host.create('eslint.config.js', (0, utils_1.createStringifiedRootESLintConfig)(null));
99
- return host;
100
- }
101
- : (0, utils_1.updateJsonInTree)('.eslintrc.json', () => (0, utils_1.createRootESLintConfig)(null)),
76
+ (0, utils_1.updateJsonInTree)('.eslintrc.json', () => (0, utils_1.createRootESLintConfig)(null)),
102
77
  (0, utils_1.updateJsonInTree)('angular.json', (json) => (0, utils_1.updateSchematicCollections)(json)),
103
78
  ]);
104
79
  }
@@ -133,12 +108,23 @@ Please see https://github.com/angular-eslint/angular-eslint for more information
133
108
  }
134
109
  function default_1() {
135
110
  return (host, context) => {
136
- const workspacePackageJSON = host.read('package.json').toString('utf-8');
137
- const json = JSON.parse(workspacePackageJSON);
138
- const useFlatConfig = (0, utils_1.shouldUseFlatConfig)(host, json);
139
111
  return (0, schematics_1.chain)([
140
- addAngularESLintPackages(json, useFlatConfig),
141
- applyESLintConfigIfSingleProjectWithNoExistingTSLint(useFlatConfig),
112
+ addAngularESLintPackages(),
113
+ applyESLintConfigIfSingleProjectWithNoExistingTSLint(),
114
+ () => {
115
+ const additionalGitignoreEntries = `.nx/cache
116
+ .nx/workspace-data
117
+ `;
118
+ if (!host.exists('.gitignore')) {
119
+ host.create('.gitignore', additionalGitignoreEntries);
120
+ return;
121
+ }
122
+ const gitIgnore = host.read('.gitignore')?.toString();
123
+ if (gitIgnore?.includes('.nx')) {
124
+ return;
125
+ }
126
+ host.overwrite('.gitignore', `${gitIgnore}\n${additionalGitignoreEntries}`);
127
+ },
142
128
  ])(host, context);
143
129
  };
144
130
  }
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,11 @@
1
+ /**
2
+ * Some utils taken from various parts of Nx:
3
+ * https://github.com/nrwl/nx
4
+ *
5
+ * Thanks, Nrwl folks!
6
+ */
1
7
  import type { Path } from '@angular-devkit/core';
2
8
  import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
3
- import type { Tree as NxTree } from './devkit-imports';
4
9
  /**
5
10
  * This method is specifically for reading JSON files in a Tree
6
11
  * @param host The host tree
@@ -24,7 +29,7 @@ export declare function getTargetsConfigFromProject(projectConfig: {
24
29
  } & {
25
30
  targets?: TargetsConfig;
26
31
  }): TargetsConfig | null;
27
- export declare function addESLintTargetToProject(tree: NxTree, projectName: string, targetName: 'eslint' | 'lint'): void;
32
+ export declare function addESLintTargetToProject(projectName: string, targetName: 'eslint' | 'lint'): Rule;
28
33
  /**
29
34
  * Utility to act on all files in a tree that are not ignored by git.
30
35
  */
@@ -52,26 +57,18 @@ export declare function createRootESLintConfig(prefix: string | null): {
52
57
  };
53
58
  }[];
54
59
  };
55
- export declare function createStringifiedRootESLintConfig(prefix: string | null): string;
56
- export declare function createESLintConfigForProject(tree: NxTree, projectName: string, setParserOptionsProject: boolean): void;
60
+ export declare function createESLintConfigForProject(projectName: string, setParserOptionsProject: boolean): Rule;
57
61
  export declare function sortObjectByKeys(obj: Record<string, unknown>): Record<string, unknown>;
58
62
  /**
59
63
  * To make certain schematic usage conversion more ergonomic, if the user does not specify a project
60
64
  * and only has a single project in their angular.json we will just go ahead and use that one.
61
65
  */
62
- export declare function determineTargetProjectName(tree: NxTree, maybeProject?: string): string | null;
66
+ export declare function determineTargetProjectName(tree: Tree, maybeProject?: string): string | null;
63
67
  /**
64
68
  * See `schematicCollections` docs here:
65
69
  * https://github.com/angular/angular-cli/blob/8431b3f0769b5f95b9e13807a09293d820c4b017/docs/specifications/schematic-collections-config.md
66
70
  */
67
71
  export declare function updateSchematicCollections(angularJson: Record<string, any>): Record<string, any>;
68
72
  export declare function updateSchematicDefaults(angularJson: Record<string, any>, schematicFullName: string, defaultValues: Record<string, unknown>): Record<string, any>;
69
- /**
70
- * In order to support both flat config and eslintrc we need to dynamically figure out
71
- * what the user should be using based on:
72
- * - their existing files
73
- * - their eslint version
74
- */
75
- export declare function shouldUseFlatConfig(tree: NxTree | Tree, existingJson?: Record<string, unknown>): boolean;
76
73
  export {};
77
74
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAM/E,OAAO,KAAK,EAAE,IAAI,IAAI,MAAM,EAAwB,MAAM,kBAAkB,CAAC;AAK7E;;;;;GAKG;AAEH,wBAAgB,cAAc,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAcnE;AAED;;;;;GAKG;AAEH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAC7C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,gBAAgB,KAAK,CAAC,GAClD,IAAI,CAYN;AAED,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAE3E,wBAAgB,2BAA2B,CACzC,aAAa,EAAE;IAAE,SAAS,CAAC,EAAE,aAAa,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,aAAa,CAAA;CAAE,GACzE,aAAa,GAAG,IAAI,CAYtB;AAqBD,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,QAAQ,GAAG,MAAM,QAqC9B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,KAAK,IAAI,GAAG,IAAI,EAC3E,GAAG,GAAE,IAAoB,GACxB,IAAI,CA8BN;AA0BD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;EAyC3D;AAGD,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,CAiDR;AAiGD,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,uBAAuB,EAAE,OAAO,QAsDjC;AAgBD,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,GAAG,IAAI,CAUf;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,uBAS1E;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,iBAAiB,EAAE,MAAM,EACzB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,uBAUvC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,OAAO,CA4BT"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAQ/E;;;;;GAKG;AAEH,wBAAgB,cAAc,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAcnE;AAED;;;;;GAKG;AAEH,wBAAgB,gBAAgB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,EAC7C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,gBAAgB,KAAK,CAAC,GAClD,IAAI,CAYN;AAQD,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAE3E,wBAAgB,2BAA2B,CACzC,aAAa,EAAE;IAAE,SAAS,CAAC,EAAE,aAAa,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,aAAa,CAAA;CAAE,GACzE,aAAa,GAAG,IAAI,CAYtB;AA6BD,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,QAAQ,GAAG,MAAM,GAC5B,IAAI,CA4BN;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,KAAK,IAAI,GAAG,IAAI,EAC3E,GAAG,GAAE,IAAoB,GACxB,IAAI,CA8BN;AA0BD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;EAyC3D;AA8CD,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,MAAM,EACnB,uBAAuB,EAAE,OAAO,GAC/B,IAAI,CAmCN;AAkBD,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,IAAI,EACV,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,GAAG,IAAI,CAUf;AAcD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,uBAS1E;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,iBAAiB,EAAE,MAAM,EACzB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,uBAUvC"}
package/dist/utils.js CHANGED
@@ -3,13 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.shouldUseFlatConfig = exports.updateSchematicDefaults = exports.updateSchematicCollections = exports.determineTargetProjectName = exports.sortObjectByKeys = exports.createESLintConfigForProject = exports.createStringifiedRootESLintConfig = exports.createRootESLintConfig = exports.visitNotIgnoredFiles = exports.addESLintTargetToProject = exports.getTargetsConfigFromProject = exports.updateJsonInTree = exports.readJsonInTree = void 0;
6
+ exports.updateSchematicDefaults = exports.updateSchematicCollections = exports.determineTargetProjectName = exports.sortObjectByKeys = exports.createESLintConfigForProject = exports.createRootESLintConfig = exports.visitNotIgnoredFiles = exports.addESLintTargetToProject = exports.getTargetsConfigFromProject = exports.updateJsonInTree = exports.readJsonInTree = void 0;
7
7
  const core_1 = require("@angular-devkit/core");
8
8
  const schematics_1 = require("@angular-devkit/schematics");
9
9
  const ignore_1 = __importDefault(require("ignore"));
10
- const semver_1 = __importDefault(require("semver"));
11
10
  const strip_json_comments_1 = __importDefault(require("strip-json-comments"));
12
- const devkit_imports_1 = require("./devkit-imports");
13
11
  const DEFAULT_PREFIX = 'app';
14
12
  /**
15
13
  * This method is specifically for reading JSON files in a Tree
@@ -49,6 +47,11 @@ function updateJsonInTree(path, callback) {
49
47
  };
50
48
  }
51
49
  exports.updateJsonInTree = updateJsonInTree;
50
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
51
+ function getWorkspacePath(host) {
52
+ const possibleFiles = ['/workspace.json', '/angular.json', '/.angular.json'];
53
+ return possibleFiles.filter((path) => host.exists(path))[0];
54
+ }
52
55
  function getTargetsConfigFromProject(projectConfig) {
53
56
  if (!projectConfig) {
54
57
  return null;
@@ -63,48 +66,49 @@ function getTargetsConfigFromProject(projectConfig) {
63
66
  return null;
64
67
  }
65
68
  exports.getTargetsConfigFromProject = getTargetsConfigFromProject;
69
+ function offsetFromRoot(fullPathToSourceDir) {
70
+ const parts = (0, core_1.normalize)(fullPathToSourceDir).split('/');
71
+ let offset = '';
72
+ for (let i = 0; i < parts.length; ++i) {
73
+ offset += '../';
74
+ }
75
+ return offset;
76
+ }
66
77
  function serializeJson(json) {
67
78
  return `${JSON.stringify(json, null, 2)}\n`;
68
79
  }
69
- function readProjectConfiguration(tree, projectName) {
70
- const angularJSON = (0, devkit_imports_1.readJson)(tree, 'angular.json');
71
- return angularJSON.projects[projectName];
72
- }
73
- function updateProjectConfiguration(tree, projectName, projectConfig) {
74
- const angularJSON = (0, devkit_imports_1.readJson)(tree, 'angular.json');
75
- angularJSON.projects[projectName] = projectConfig;
76
- (0, devkit_imports_1.writeJson)(tree, 'angular.json', angularJSON);
77
- }
78
- function addESLintTargetToProject(tree, projectName, targetName) {
79
- const existingProjectConfig = readProjectConfiguration(tree, projectName);
80
- let lintFilePatternsRoot = '';
81
- // Default Angular CLI project at the root of the workspace
82
- if (existingProjectConfig.root === '') {
83
- lintFilePatternsRoot = existingProjectConfig.sourceRoot || 'src';
84
- }
85
- else {
86
- lintFilePatternsRoot = existingProjectConfig.root;
87
- }
88
- const eslintTargetConfig = {
89
- builder: '@angular-eslint/builder:lint',
90
- options: {
91
- lintFilePatterns: [
92
- `${lintFilePatternsRoot}/**/*.ts`,
93
- `${lintFilePatternsRoot}/**/*.html`,
94
- ],
95
- },
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ function updateWorkspaceInTree(callback) {
82
+ return (host, context) => {
83
+ const path = 'angular.json';
84
+ host.overwrite(path, serializeJson(callback(readJsonInTree(host, path), context, host)));
85
+ return host;
96
86
  };
97
- let eslintConfig;
98
- if (existingProjectConfig.root !== '') {
99
- const flatConfigPath = (0, core_1.join)(existingProjectConfig.root, 'eslint.config.js');
100
- if (tree.exists(flatConfigPath)) {
101
- eslintConfig = flatConfigPath;
87
+ }
88
+ function addESLintTargetToProject(projectName, targetName) {
89
+ return updateWorkspaceInTree((workspaceJson) => {
90
+ const existingProjectConfig = workspaceJson.projects[projectName];
91
+ let lintFilePatternsRoot = '';
92
+ // Default Angular CLI project at the root of the workspace
93
+ if (existingProjectConfig.root === '') {
94
+ lintFilePatternsRoot = existingProjectConfig.sourceRoot || 'src';
102
95
  }
103
- }
104
- eslintTargetConfig.options.eslintConfig = eslintConfig;
105
- existingProjectConfig.architect = existingProjectConfig.architect || {};
106
- existingProjectConfig.architect[targetName] = eslintTargetConfig;
107
- updateProjectConfiguration(tree, projectName, existingProjectConfig);
96
+ else {
97
+ lintFilePatternsRoot = existingProjectConfig.root;
98
+ }
99
+ const eslintTargetConfig = {
100
+ builder: '@angular-eslint/builder:lint',
101
+ options: {
102
+ lintFilePatterns: [
103
+ `${lintFilePatternsRoot}/**/*.ts`,
104
+ `${lintFilePatternsRoot}/**/*.html`,
105
+ ],
106
+ },
107
+ };
108
+ existingProjectConfig.architect = existingProjectConfig.architect || {};
109
+ existingProjectConfig.architect[targetName] = eslintTargetConfig;
110
+ return workspaceJson;
111
+ });
108
112
  }
109
113
  exports.addESLintTargetToProject = addESLintTargetToProject;
110
114
  /**
@@ -198,59 +202,9 @@ function createRootESLintConfig(prefix) {
198
202
  };
199
203
  }
200
204
  exports.createRootESLintConfig = createRootESLintConfig;
201
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
202
- function createStringifiedRootESLintConfig(prefix) {
203
- return `// @ts-check
204
- const eslint = require("@eslint/js");
205
- const tseslint = require("typescript-eslint");
206
- const angular = require("angular-eslint");
207
-
208
- module.exports = tseslint.config(
209
- {
210
- files: ["**/*.ts"],
211
- extends: [
212
- eslint.configs.recommended,
213
- ...tseslint.configs.recommended,
214
- ...tseslint.configs.stylistic,
215
- ...angular.configs.tsRecommended,
216
- ],
217
- processor: angular.processInlineTemplates,
218
- rules: ${prefix
219
- ? `{
220
- "@angular-eslint/directive-selector": [
221
- "error",
222
- {
223
- type: "attribute",
224
- prefix: "${prefix}",
225
- style: "camelCase",
226
- },
227
- ],
228
- "@angular-eslint/component-selector": [
229
- "error",
230
- {
231
- type: "element",
232
- prefix: "${prefix}",
233
- style: "kebab-case",
234
- },
235
- ],
236
- }`
237
- : '{}'},
238
- },
239
- {
240
- files: ["**/*.html"],
241
- extends: [
242
- ...angular.configs.templateRecommended,
243
- ...angular.configs.templateAccessibility,
244
- ],
245
- rules: {},
246
- }
247
- );
248
- `;
249
- }
250
- exports.createStringifiedRootESLintConfig = createStringifiedRootESLintConfig;
251
205
  function createProjectESLintConfig(projectRoot, projectType, prefix, setParserOptionsProject, hasE2e) {
252
206
  return {
253
- extends: `${(0, devkit_imports_1.offsetFromRoot)(projectRoot)}.eslintrc.json`,
207
+ extends: `${offsetFromRoot(projectRoot)}.eslintrc.json`,
254
208
  ignorePatterns: ['!**/*'],
255
209
  overrides: [
256
210
  {
@@ -280,80 +234,38 @@ function createProjectESLintConfig(projectRoot, projectType, prefix, setParserOp
280
234
  ],
281
235
  };
282
236
  }
283
- function createStringifiedProjectESLintConfig(projectRoot, projectType, prefix, setParserOptionsProject, hasE2e) {
284
- return `// @ts-check
285
- const tseslint = require("typescript-eslint");
286
- const rootConfig = require("${(0, devkit_imports_1.offsetFromRoot)(projectRoot)}eslint.config.js");
287
-
288
- module.exports = tseslint.config(
289
- ...rootConfig,
290
- {
291
- files: ["**/*.ts"],${setParserOptionsProject
292
- ? `
293
- languageOptions: {
294
- parserOptions: {
295
- projectService: true,
296
- },
297
- },`
298
- : ''}
299
- rules: {
300
- "@angular-eslint/directive-selector": [
301
- "error",
302
- {
303
- type: "attribute",
304
- prefix: "${prefix}",
305
- style: "camelCase",
306
- },
307
- ],
308
- "@angular-eslint/component-selector": [
309
- "error",
310
- {
311
- type: "element",
312
- prefix: "${prefix}",
313
- style: "kebab-case",
314
- },
315
- ],
316
- },
317
- },
318
- {
319
- files: ["**/*.html"],
320
- rules: {},
321
- }
322
- );
323
- `;
324
- }
325
- function createESLintConfigForProject(tree, projectName, setParserOptionsProject) {
326
- const existingProjectConfig = readProjectConfiguration(tree, projectName);
327
- const targets = existingProjectConfig.architect || existingProjectConfig.targets;
328
- const { root: projectRoot, projectType, prefix } = existingProjectConfig;
329
- const hasE2e = !!targets?.e2e;
330
- const useFlatConfig = shouldUseFlatConfig(tree);
331
- const alreadyHasRootFlatConfig = tree.exists('eslint.config.js');
332
- const alreadyHasRootESLintRC = tree.exists('.eslintrc.json');
333
- /**
334
- * If the root is an empty string it must be the initial project created at the
335
- * root by the Angular CLI's workspace schematic
336
- */
337
- if (projectRoot === '') {
338
- return createRootESLintConfigFile(tree, prefix || DEFAULT_PREFIX, useFlatConfig);
339
- }
340
- // If, for whatever reason, the root eslint.config.js/.eslintrc.json doesn't exist yet, create it
341
- if (!alreadyHasRootESLintRC && !alreadyHasRootFlatConfig) {
342
- createRootESLintConfigFile(tree, prefix || DEFAULT_PREFIX, useFlatConfig);
343
- }
344
- if (useFlatConfig) {
345
- tree.write((0, core_1.join)((0, core_1.normalize)(projectRoot), 'eslint.config.js'), createStringifiedProjectESLintConfig(projectRoot, projectType || 'library', prefix || DEFAULT_PREFIX, setParserOptionsProject, hasE2e));
346
- }
347
- else {
348
- (0, devkit_imports_1.writeJson)(tree, (0, core_1.join)((0, core_1.normalize)(projectRoot), '.eslintrc.json'), createProjectESLintConfig(projectRoot, projectType || 'library', prefix || DEFAULT_PREFIX, setParserOptionsProject, hasE2e));
349
- }
237
+ function createESLintConfigForProject(projectName, setParserOptionsProject) {
238
+ return (tree) => {
239
+ const angularJSON = readJsonInTree(tree, 'angular.json');
240
+ const { root: projectRoot, projectType, prefix, } = angularJSON.projects[projectName];
241
+ const hasE2e = determineTargetProjectHasE2E(angularJSON, projectName);
242
+ /**
243
+ * If the root is an empty string it must be the initial project created at the
244
+ * root by the Angular CLI's workspace schematic
245
+ */
246
+ if (projectRoot === '') {
247
+ return createRootESLintConfigFile(projectName);
248
+ }
249
+ return (0, schematics_1.chain)([
250
+ // If, for whatever reason, the root .eslintrc.json doesn't exist yet, create it
251
+ tree.exists('.eslintrc.json')
252
+ ? () => undefined
253
+ : createRootESLintConfigFile(projectName),
254
+ updateJsonInTree((0, core_1.join)((0, core_1.normalize)(projectRoot), '.eslintrc.json'), () => createProjectESLintConfig(projectRoot, projectType, prefix, setParserOptionsProject, hasE2e)),
255
+ ]);
256
+ };
350
257
  }
351
258
  exports.createESLintConfigForProject = createESLintConfigForProject;
352
- function createRootESLintConfigFile(tree, prefix, useFlatConfig) {
353
- if (useFlatConfig) {
354
- return tree.write('eslint.config.js', createStringifiedRootESLintConfig(prefix));
355
- }
356
- return (0, devkit_imports_1.writeJson)(tree, '.eslintrc.json', createRootESLintConfig(prefix));
259
+ function createRootESLintConfigFile(projectName) {
260
+ return (tree) => {
261
+ const angularJSON = readJsonInTree(tree, getWorkspacePath(tree));
262
+ let lintPrefix = DEFAULT_PREFIX;
263
+ if (angularJSON.projects?.[projectName]) {
264
+ const { prefix } = angularJSON.projects[projectName];
265
+ lintPrefix = prefix;
266
+ }
267
+ return updateJsonInTree('.eslintrc.json', () => createRootESLintConfig(lintPrefix));
268
+ };
357
269
  }
358
270
  function sortObjectByKeys(obj) {
359
271
  return Object.keys(obj)
@@ -374,7 +286,7 @@ function determineTargetProjectName(tree, maybeProject) {
374
286
  if (maybeProject) {
375
287
  return maybeProject;
376
288
  }
377
- const workspaceJson = (0, devkit_imports_1.readJson)(tree, 'angular.json');
289
+ const workspaceJson = readJsonInTree(tree, 'angular.json');
378
290
  const projects = Object.keys(workspaceJson.projects);
379
291
  if (projects.length === 1) {
380
292
  return projects[0];
@@ -382,6 +294,15 @@ function determineTargetProjectName(tree, maybeProject) {
382
294
  return null;
383
295
  }
384
296
  exports.determineTargetProjectName = determineTargetProjectName;
297
+ /**
298
+ * Checking if the target project has e2e setup
299
+ * Method will check if angular project architect has e2e configuration to determine if e2e setup
300
+ */
301
+ function determineTargetProjectHasE2E(
302
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
303
+ angularJSON, projectName) {
304
+ return !!getTargetsConfigFromProject(angularJSON.projects[projectName])?.e2e;
305
+ }
385
306
  /**
386
307
  * See `schematicCollections` docs here:
387
308
  * https://github.com/angular/angular-cli/blob/8431b3f0769b5f95b9e13807a09293d820c4b017/docs/specifications/schematic-collections-config.md
@@ -408,39 +329,3 @@ function updateSchematicDefaults(angularJson, schematicFullName, defaultValues)
408
329
  return angularJson;
409
330
  }
410
331
  exports.updateSchematicDefaults = updateSchematicDefaults;
411
- /**
412
- * In order to support both flat config and eslintrc we need to dynamically figure out
413
- * what the user should be using based on:
414
- * - their existing files
415
- * - their eslint version
416
- */
417
- function shouldUseFlatConfig(tree, existingJson) {
418
- let useFlatConfig = true;
419
- try {
420
- const alreadyHasRootFlatConfig = tree.exists('eslint.config.js');
421
- const alreadyHasRootESLintRC = tree.exists('.eslintrc.json');
422
- if (alreadyHasRootFlatConfig) {
423
- useFlatConfig = true;
424
- }
425
- else if (alreadyHasRootESLintRC) {
426
- useFlatConfig = false;
427
- }
428
- else {
429
- const json = existingJson ??
430
- JSON.parse(tree.read('package.json').toString('utf-8'));
431
- json.devDependencies = json.devDependencies || {};
432
- const existingESLintVersion = json.devDependencies['eslint'];
433
- if (existingESLintVersion) {
434
- const v = semver_1.default.minVersion(existingESLintVersion);
435
- if (v) {
436
- useFlatConfig = semver_1.default.gte(v.raw, '9.0.0');
437
- }
438
- }
439
- }
440
- return useFlatConfig;
441
- }
442
- catch {
443
- return useFlatConfig;
444
- }
445
- }
446
- exports.shouldUseFlatConfig = shouldUseFlatConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/schematics",
3
- "version": "17.5.3-alpha.1",
3
+ "version": "17.5.3",
4
4
  "description": "Angular Schematics for angular-eslint",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -27,30 +27,26 @@
27
27
  "@angular-eslint/eslint-plugin",
28
28
  "@angular-eslint/eslint-plugin-template",
29
29
  "@angular-eslint/template-parser",
30
- "@angular-eslint/test-utils",
31
- "@angular-eslint/utils",
32
- "angular-eslint"
30
+ "@angular-eslint/utils"
33
31
  ]
34
32
  },
35
33
  "ng-add": {
36
34
  "save": "devDependencies"
37
35
  },
38
36
  "dependencies": {
39
- "@angular-eslint/eslint-plugin": "17.5.3-alpha.1",
40
- "@angular-eslint/eslint-plugin-template": "17.5.3-alpha.1",
41
- "@nx/devkit": "^19.0.6",
37
+ "@angular-eslint/eslint-plugin": "17.5.3",
38
+ "@angular-eslint/eslint-plugin-template": "17.5.3",
42
39
  "ignore": "5.3.1",
43
- "nx": "^19.0.6",
44
- "semver": "7.6.2",
45
- "strip-json-comments": "3.1.1"
40
+ "strip-json-comments": "3.1.1",
41
+ "tmp": "0.2.3"
46
42
  },
47
43
  "devDependencies": {
48
- "@typescript-eslint/utils": "8.0.0-alpha.20",
49
- "eslint": "9.3.0"
44
+ "@types/tmp": "0.2.6",
45
+ "@typescript-eslint/utils": "7.11.0",
46
+ "eslint": "8.57.0"
50
47
  },
51
48
  "peerDependencies": {
52
- "@angular-devkit/core": ">= 18.0.0 < 19.0.0",
53
- "@angular-devkit/schematics": ">= 18.0.0 < 19.0.0"
49
+ "@angular/cli": ">= 17.0.0 < 18.0.0"
54
50
  },
55
51
  "gitHead": "e2006e5e9c99e5a943d1a999e0efa5247d29ec24"
56
52
  }