@angular-eslint/schematics 14.3.1-alpha.0 → 15.0.0-alpha.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.
@@ -4,6 +4,7 @@ const schematics_1 = require("@angular-devkit/schematics");
4
4
  const utils_1 = require("../utils");
5
5
  function addESLintToProject(schema) {
6
6
  return (tree) => {
7
+ var _a;
7
8
  const projectName = (0, utils_1.determineTargetProjectName)(tree, schema.project);
8
9
  if (!projectName) {
9
10
  throw new Error('\n' +
@@ -17,7 +18,7 @@ E.g. npx ng g @angular-eslint/schematics:add-eslint-to-project {{YOUR_PROJECT_NA
17
18
  // Set the lint builder and config in angular.json
18
19
  (0, utils_1.addESLintTargetToProject)(projectName, 'lint'),
19
20
  // Create the ESLint config file for the project
20
- (0, utils_1.createESLintConfigForProject)(projectName),
21
+ (0, utils_1.createESLintConfigForProject)(projectName, (_a = schema.setParserOptionsProject) !== null && _a !== void 0 ? _a : false),
21
22
  ]);
22
23
  };
23
24
  }
@@ -11,6 +11,11 @@
11
11
  "$source": "argv",
12
12
  "index": 0
13
13
  }
14
+ },
15
+ "setParserOptionsProject": {
16
+ "type": "boolean",
17
+ "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
18
+ "default": false
14
19
  }
15
20
  },
16
21
  "required": []
@@ -1,21 +1,36 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  const schematics_1 = require("@angular-devkit/schematics");
4
15
  const utils_1 = require("../utils");
5
16
  function eslintRelatedChanges(options) {
17
+ var _a;
6
18
  return (0, schematics_1.chain)([
7
19
  // Update the lint builder and config in angular.json
8
20
  (0, utils_1.addESLintTargetToProject)(options.name, 'lint'),
9
21
  // Create the ESLint config file for the project
10
- (0, utils_1.createESLintConfigForProject)(options.name),
22
+ (0, utils_1.createESLintConfigForProject)(options.name, (_a = options.setParserOptionsProject) !== null && _a !== void 0 ? _a : false),
11
23
  // Delete the TSLint config file for the project
12
24
  (0, utils_1.removeTSLintJSONForProject)(options.name),
13
25
  ]);
14
26
  }
15
27
  function default_1(options) {
16
28
  return (host, context) => {
29
+ // Remove angular-eslint specific options before passing to the Angular schematic
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ const { setParserOptionsProject } = options, angularOptions = __rest(options, ["setParserOptionsProject"]);
17
32
  return (0, schematics_1.chain)([
18
- (0, schematics_1.externalSchematic)('@schematics/angular', 'application', options),
33
+ (0, schematics_1.externalSchematic)('@schematics/angular', 'application', angularOptions),
19
34
  eslintRelatedChanges(options),
20
35
  ])(host, context);
21
36
  };
@@ -7,12 +7,11 @@
7
7
  "additionalProperties": false,
8
8
  "properties": {
9
9
  "projectRoot": {
10
- "description": "The root directory of the new app.",
11
- "type": "string",
12
- "visible": false
10
+ "description": "The root directory of the new application.",
11
+ "type": "string"
13
12
  },
14
13
  "name": {
15
- "description": "The name of the new app.",
14
+ "description": "The name of the new application.",
16
15
  "type": "string",
17
16
  "pattern": "^(?:@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*/)?[a-zA-Z0-9-~][a-zA-Z0-9-._~]*$",
18
17
  "$default": {
@@ -25,26 +24,25 @@
25
24
  "description": "Include styles inline in the root component.ts file. Only CSS styles can be included inline. Default is false, meaning that an external styles file is created and referenced in the root component.ts file.",
26
25
  "type": "boolean",
27
26
  "alias": "s",
28
- "x-user-analytics": 9
27
+ "x-user-analytics": "ep.ng_inline_style"
29
28
  },
30
29
  "inlineTemplate": {
31
30
  "description": "Include template inline in the root component.ts file. Default is false, meaning that an external template file is created and referenced in the root component.ts file. ",
32
31
  "type": "boolean",
33
32
  "alias": "t",
34
- "x-user-analytics": 10
33
+ "x-user-analytics": "ep.ng_inline_template"
35
34
  },
36
35
  "viewEncapsulation": {
37
36
  "description": "The view encapsulation strategy to use in the new application.",
38
37
  "enum": ["Emulated", "None", "ShadowDom"],
39
- "type": "string",
40
- "x-user-analytics": 11
38
+ "type": "string"
41
39
  },
42
40
  "routing": {
43
41
  "type": "boolean",
44
42
  "description": "Create a routing NgModule.",
45
43
  "default": false,
46
44
  "x-prompt": "Would you like to add Angular routing?",
47
- "x-user-analytics": 17
45
+ "x-user-analytics": "ep.ng_routing"
48
46
  },
49
47
  "prefix": {
50
48
  "type": "string",
@@ -62,7 +60,10 @@
62
60
  "message": "Which stylesheet format would you like to use?",
63
61
  "type": "list",
64
62
  "items": [
65
- { "value": "css", "label": "CSS" },
63
+ {
64
+ "value": "css",
65
+ "label": "CSS"
66
+ },
66
67
  {
67
68
  "value": "scss",
68
69
  "label": "SCSS [ https://sass-lang.com/documentation/syntax#scss ]"
@@ -77,14 +78,13 @@
77
78
  }
78
79
  ]
79
80
  },
80
- "x-user-analytics": 5
81
+ "x-user-analytics": "ep.ng_style"
81
82
  },
82
83
  "skipTests": {
83
84
  "description": "Do not create \"spec.ts\" test files for the application.",
84
85
  "type": "boolean",
85
86
  "default": false,
86
- "alias": "S",
87
- "x-user-analytics": 12
87
+ "alias": "S"
88
88
  },
89
89
  "skipPackageJson": {
90
90
  "type": "boolean",
@@ -94,8 +94,7 @@
94
94
  "minimal": {
95
95
  "description": "Create a bare-bones project without any testing frameworks. (Use for learning purposes only.)",
96
96
  "type": "boolean",
97
- "default": false,
98
- "x-user-analytics": 14
97
+ "default": false
99
98
  },
100
99
  "skipInstall": {
101
100
  "description": "Skip installing dependency packages.",
@@ -105,8 +104,12 @@
105
104
  "strict": {
106
105
  "description": "Creates an application with stricter bundle budgets settings.",
107
106
  "type": "boolean",
108
- "default": true,
109
- "x-user-analytics": 7
107
+ "default": true
108
+ },
109
+ "setParserOptionsProject": {
110
+ "type": "boolean",
111
+ "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
112
+ "default": false
110
113
  }
111
114
  },
112
115
  "required": ["name"]
@@ -47,7 +47,7 @@ E.g. npx ng g @angular-eslint/schematics:convert-tslint-to-eslint {{YOUR_PROJECT
47
47
  : schema.ignoreExistingTslintConfig
48
48
  ? (0, schematics_1.chain)([
49
49
  // Create the latest recommended ESLint config file for the project
50
- (0, utils_1.createESLintConfigForProject)(projectName),
50
+ (0, utils_1.createESLintConfigForProject)(projectName, true),
51
51
  // Delete the TSLint config file for the project
52
52
  (0, utils_1.removeTSLintJSONForProject)(projectName),
53
53
  ])
@@ -1,26 +1,36 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  const schematics_1 = require("@angular-devkit/schematics");
4
15
  const utils_1 = require("../utils");
5
16
  function eslintRelatedChanges(options) {
6
- /**
7
- * The types coming from the @schematics/angular schema seem to be wrong, if name isn't
8
- * provided the interactive CLI prompt will throw
9
- */
10
- const projectName = options.name;
17
+ var _a;
11
18
  return (0, schematics_1.chain)([
12
19
  // Update the lint builder and config in angular.json
13
- (0, utils_1.addESLintTargetToProject)(projectName, 'lint'),
20
+ (0, utils_1.addESLintTargetToProject)(options.name, 'lint'),
14
21
  // Create the ESLint config file for the project
15
- (0, utils_1.createESLintConfigForProject)(projectName),
22
+ (0, utils_1.createESLintConfigForProject)(options.name, (_a = options.setParserOptionsProject) !== null && _a !== void 0 ? _a : false),
16
23
  // Delete the TSLint config file for the project
17
- (0, utils_1.removeTSLintJSONForProject)(projectName),
24
+ (0, utils_1.removeTSLintJSONForProject)(options.name),
18
25
  ]);
19
26
  }
20
27
  function default_1(options) {
21
28
  return (host, context) => {
29
+ // Remove angular-eslint specific options before passing to the Angular schematic
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ const { setParserOptionsProject } = options, angularOptions = __rest(options, ["setParserOptionsProject"]);
22
32
  return (0, schematics_1.chain)([
23
- (0, schematics_1.externalSchematic)('@schematics/angular', 'library', options),
33
+ (0, schematics_1.externalSchematic)('@schematics/angular', 'library', angularOptions),
24
34
  eslintRelatedChanges(options),
25
35
  ])(host, context);
26
36
  };
@@ -43,6 +43,15 @@
43
43
  "type": "boolean",
44
44
  "default": false,
45
45
  "description": "Do not update \"tsconfig.json\" to add a path mapping for the new library. The path mapping is needed to use the library in an app, but can be disabled here to simplify development."
46
+ },
47
+ "projectRoot": {
48
+ "type": "string",
49
+ "description": "The root directory of the new library."
50
+ },
51
+ "setParserOptionsProject": {
52
+ "type": "boolean",
53
+ "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
54
+ "default": false
46
55
  }
47
56
  },
48
57
  "required": ["name"]
@@ -73,7 +73,7 @@ function applyESLintConfigIfSingleProjectWithNoExistingTSLint() {
73
73
  const projectNames = Object.keys(angularJson.projects);
74
74
  if (projectNames.length === 0) {
75
75
  return (0, schematics_1.chain)([
76
- (0, utils_1.updateJsonInTree)('.eslintrc.json', () => (0, utils_1.createRootESLintConfig)(null, false)),
76
+ (0, utils_1.updateJsonInTree)('.eslintrc.json', () => (0, utils_1.createRootESLintConfig)(null)),
77
77
  (0, utils_1.updateJsonInTree)('angular.json', (json) => (0, utils_1.updateSchematicCollections)(json)),
78
78
  ]);
79
79
  }
package/dist/utils.js CHANGED
@@ -184,26 +184,20 @@ exports.visitNotIgnoredFiles = visitNotIgnoredFiles;
184
184
  function setESLintProjectBasedOnProjectType(projectRoot, projectType, hasE2e) {
185
185
  let project;
186
186
  if (projectType === 'application') {
187
- project = [
188
- `${projectRoot}/tsconfig.app.json`,
189
- `${projectRoot}/tsconfig.spec.json`,
190
- ];
187
+ project = [`${projectRoot}/tsconfig.(app|spec).json`];
191
188
  if (hasE2e) {
192
189
  project.push(`${projectRoot}/e2e/tsconfig.json`);
193
190
  }
194
191
  }
195
192
  // Libraries don't have an e2e directory
196
193
  if (projectType === 'library') {
197
- project = [
198
- `${projectRoot}/tsconfig.lib.json`,
199
- `${projectRoot}/tsconfig.spec.json`,
200
- ];
194
+ project = [`${projectRoot}/tsconfig.(lib|spec).json`];
201
195
  }
202
196
  return project;
203
197
  }
204
198
  exports.setESLintProjectBasedOnProjectType = setESLintProjectBasedOnProjectType;
205
199
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
206
- function createRootESLintConfig(prefix, hasE2e) {
200
+ function createRootESLintConfig(prefix) {
207
201
  let codeRules;
208
202
  if (prefix) {
209
203
  codeRules = {
@@ -226,13 +220,9 @@ function createRootESLintConfig(prefix, hasE2e) {
226
220
  overrides: [
227
221
  {
228
222
  files: ['*.ts'],
229
- parserOptions: {
230
- project: hasE2e
231
- ? ['tsconfig.json', 'e2e/tsconfig.json']
232
- : ['tsconfig.json'],
233
- createDefaultProgram: true,
234
- },
235
223
  extends: [
224
+ 'eslint:recommended',
225
+ 'plugin:@typescript-eslint/recommended',
236
226
  'plugin:@angular-eslint/recommended',
237
227
  'plugin:@angular-eslint/template/process-inline-templates',
238
228
  ],
@@ -247,18 +237,18 @@ function createRootESLintConfig(prefix, hasE2e) {
247
237
  };
248
238
  }
249
239
  exports.createRootESLintConfig = createRootESLintConfig;
250
- function createProjectESLintConfig(rootPath, projectRoot, projectType, prefix, hasE2e) {
240
+ function createProjectESLintConfig(rootPath, projectRoot, projectType, prefix, setParserOptionsProject, hasE2e) {
251
241
  return {
252
242
  extends: `${offsetFromRoot(rootPath)}.eslintrc.json`,
253
243
  ignorePatterns: ['!**/*'],
254
244
  overrides: [
255
- {
256
- files: ['*.ts'],
257
- parserOptions: {
258
- project: setESLintProjectBasedOnProjectType(projectRoot, projectType, hasE2e),
259
- createDefaultProgram: true,
260
- },
261
- rules: {
245
+ Object.assign(Object.assign({ files: ['*.ts'] }, (setParserOptionsProject
246
+ ? {
247
+ parserOptions: {
248
+ project: setESLintProjectBasedOnProjectType(projectRoot, projectType, hasE2e),
249
+ },
250
+ }
251
+ : null)), { rules: {
262
252
  '@angular-eslint/directive-selector': [
263
253
  'error',
264
254
  { type: 'attribute', prefix, style: 'camelCase' },
@@ -267,8 +257,7 @@ function createProjectESLintConfig(rootPath, projectRoot, projectType, prefix, h
267
257
  'error',
268
258
  { type: 'element', prefix, style: 'kebab-case' },
269
259
  ],
270
- },
271
- },
260
+ } }),
272
261
  {
273
262
  files: ['*.html'],
274
263
  rules: {},
@@ -276,7 +265,7 @@ function createProjectESLintConfig(rootPath, projectRoot, projectType, prefix, h
276
265
  ],
277
266
  };
278
267
  }
279
- function createESLintConfigForProject(projectName) {
268
+ function createESLintConfigForProject(projectName, setParserOptionsProject) {
280
269
  return (tree) => {
281
270
  const angularJSON = readJsonInTree(tree, 'angular.json');
282
271
  const { root: projectRoot, projectType, prefix, } = angularJSON.projects[projectName];
@@ -293,7 +282,7 @@ function createESLintConfigForProject(projectName) {
293
282
  tree.exists('.eslintrc.json')
294
283
  ? () => undefined
295
284
  : createRootESLintConfigFile(projectName),
296
- updateJsonInTree((0, core_1.join)((0, core_1.normalize)(projectRoot), '.eslintrc.json'), () => createProjectESLintConfig(tree.root.path, projectRoot, projectType, prefix, hasE2e)),
285
+ updateJsonInTree((0, core_1.join)((0, core_1.normalize)(projectRoot), '.eslintrc.json'), () => createProjectESLintConfig(tree.root.path, projectRoot, projectType, prefix, setParserOptionsProject, hasE2e)),
297
286
  ]);
298
287
  };
299
288
  }
@@ -314,12 +303,11 @@ function createRootESLintConfigFile(projectName) {
314
303
  var _a;
315
304
  const angularJSON = readJsonInTree(tree, getWorkspacePath(tree));
316
305
  let lintPrefix = null;
317
- const hasE2e = determineTargetProjectHasE2E(angularJSON, projectName);
318
306
  if ((_a = angularJSON.projects) === null || _a === void 0 ? void 0 : _a[projectName]) {
319
307
  const { prefix } = angularJSON.projects[projectName];
320
308
  lintPrefix = prefix;
321
309
  }
322
- return updateJsonInTree('.eslintrc.json', () => createRootESLintConfig(lintPrefix, hasE2e));
310
+ return updateJsonInTree('.eslintrc.json', () => createRootESLintConfig(lintPrefix));
323
311
  };
324
312
  }
325
313
  function sortObjectByKeys(obj) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/schematics",
3
- "version": "14.3.1-alpha.0+f71f236",
3
+ "version": "15.0.0-alpha.1",
4
4
  "description": "Angular Schematics for angular-eslint",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -33,8 +33,8 @@
33
33
  "save": "devDependencies"
34
34
  },
35
35
  "dependencies": {
36
- "@angular-eslint/eslint-plugin": "14.3.1-alpha.0+f71f236",
37
- "@angular-eslint/eslint-plugin-template": "14.3.1-alpha.0+f71f236",
36
+ "@angular-eslint/eslint-plugin": "15.0.0-alpha.1",
37
+ "@angular-eslint/eslint-plugin-template": "15.0.0-alpha.1",
38
38
  "ignore": "5.2.0",
39
39
  "strip-json-comments": "3.1.1",
40
40
  "tmp": "0.2.1"
@@ -46,7 +46,7 @@
46
46
  "tslint-to-eslint-config": "2.4.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@angular/cli": ">= 14.0.0 < 15.0.0"
49
+ "@angular/cli": ">= 15.0.0 < 16.0.0"
50
50
  },
51
- "gitHead": "f71f23652a74ebd2f650baeb3a91051db554c5d9"
51
+ "gitHead": "58e6105c2375550f2b786406f25e304b0d59095b"
52
52
  }