@angular-eslint/schematics 17.3.1-alpha.2 → 17.3.1-alpha.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/dist/add-eslint-to-project/index.js +1 -2
- package/dist/application/index.js +2 -14
- package/dist/application/schema.json +4 -4
- package/dist/library/index.js +2 -14
- package/dist/migrations/update-12-0-0/update-12-0-0.js +4 -6
- package/dist/migrations/update-14-0-0/update-14-0-0.js +2 -4
- package/dist/migrations/update-2-0-0/update-2-0-0.js +1 -1
- package/dist/migrations/update-3-0-0/update-3-0-0.js +5 -6
- package/dist/migrations/update-4-0-0/update-4-0-0.js +1 -1
- package/dist/ng-add/index.js +1 -2
- package/dist/utils.js +37 -25
- package/package.json +3 -3
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const devkit_1 = require("@nx/devkit");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
exports.default = (0, devkit_1.convertNxGenerator)(async (tree, options) => {
|
|
6
|
-
var _a;
|
|
7
6
|
const projectName = (0, utils_1.determineTargetProjectName__NX)(tree, options.project);
|
|
8
7
|
if (!projectName) {
|
|
9
8
|
throw new Error('\n' +
|
|
@@ -15,5 +14,5 @@ E.g. npx ng g @angular-eslint/schematics:add-eslint-to-project {{YOUR_PROJECT_NA
|
|
|
15
14
|
}
|
|
16
15
|
// Update the lint builder and config in angular.json
|
|
17
16
|
(0, utils_1.addESLintTargetToProject__NX)(tree, projectName, 'lint');
|
|
18
|
-
(0, utils_1.createESLintConfigForProject__NX)(tree, projectName,
|
|
17
|
+
(0, utils_1.createESLintConfigForProject__NX)(tree, projectName, options.setParserOptionsProject ?? false);
|
|
19
18
|
});
|
|
@@ -1,27 +1,15 @@
|
|
|
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
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
const devkit_1 = require("@nx/devkit");
|
|
15
4
|
const ngcli_adapter_1 = require("@nx/devkit/ngcli-adapter");
|
|
16
5
|
const utils_1 = require("../utils");
|
|
17
6
|
exports.default = (0, devkit_1.convertNxGenerator)(async (tree, options) => {
|
|
18
|
-
var _a;
|
|
19
7
|
// Remove angular-eslint specific options before passing to the Angular schematic
|
|
20
8
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
-
const { setParserOptionsProject
|
|
9
|
+
const { setParserOptionsProject, ...angularOptions } = options;
|
|
22
10
|
const applicationGenerator = (0, ngcli_adapter_1.wrapAngularDevkitSchematic)('@schematics/angular', 'application');
|
|
23
11
|
await applicationGenerator(tree, angularOptions);
|
|
24
12
|
// Update the lint builder and config in angular.json
|
|
25
13
|
(0, utils_1.addESLintTargetToProject__NX)(tree, options.name, 'lint');
|
|
26
|
-
(0, utils_1.createESLintConfigForProject__NX)(tree, options.name,
|
|
14
|
+
(0, utils_1.createESLintConfigForProject__NX)(tree, options.name, options.setParserOptionsProject ?? false);
|
|
27
15
|
});
|
|
@@ -61,19 +61,19 @@
|
|
|
61
61
|
"items": [
|
|
62
62
|
{
|
|
63
63
|
"value": "css",
|
|
64
|
-
"label": "CSS"
|
|
64
|
+
"label": "CSS [ https://developer.mozilla.org/docs/Web/CSS ]"
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"value": "scss",
|
|
68
|
-
"label": "SCSS
|
|
68
|
+
"label": "Sass (SCSS) [ https://sass-lang.com/documentation/syntax#scss ]"
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
"value": "sass",
|
|
72
|
-
"label": "Sass
|
|
72
|
+
"label": "Sass (Indented) [ https://sass-lang.com/documentation/syntax#the-indented-syntax ]"
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"value": "less",
|
|
76
|
-
"label": "Less
|
|
76
|
+
"label": "Less [ http://lesscss.org ]"
|
|
77
77
|
}
|
|
78
78
|
]
|
|
79
79
|
},
|
package/dist/library/index.js
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
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
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
const devkit_1 = require("@nx/devkit");
|
|
15
4
|
const ngcli_adapter_1 = require("@nx/devkit/ngcli-adapter");
|
|
16
5
|
const utils_1 = require("../utils");
|
|
17
6
|
exports.default = (0, devkit_1.convertNxGenerator)(async (tree, options) => {
|
|
18
|
-
var _a;
|
|
19
7
|
// Remove angular-eslint specific options before passing to the Angular schematic
|
|
20
8
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
-
const { setParserOptionsProject
|
|
9
|
+
const { setParserOptionsProject, ...angularOptions } = options;
|
|
22
10
|
const libraryGenerator = (0, ngcli_adapter_1.wrapAngularDevkitSchematic)('@schematics/angular', 'library');
|
|
23
11
|
await libraryGenerator(tree, angularOptions);
|
|
24
12
|
// Update the lint builder and config in angular.json
|
|
25
13
|
(0, utils_1.addESLintTargetToProject__NX)(tree, options.name, 'lint');
|
|
26
|
-
(0, utils_1.createESLintConfigForProject__NX)(tree, options.name,
|
|
14
|
+
(0, utils_1.createESLintConfigForProject__NX)(tree, options.name, options.setParserOptionsProject ?? false);
|
|
27
15
|
});
|
|
@@ -18,11 +18,10 @@ function migrateToAccessibilityLabelHasAssociatedControlSchema(rule) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
function migrateFromAccessibilityLabelFor({ overrides, rules }) {
|
|
21
|
-
|
|
22
|
-
migrateToAccessibilityLabelHasAssociatedControlSchema(rules === null || rules === void 0 ? void 0 : rules['@angular-eslint/template/accessibility-label-for']);
|
|
21
|
+
migrateToAccessibilityLabelHasAssociatedControlSchema(rules?.['@angular-eslint/template/accessibility-label-for']);
|
|
23
22
|
migrateToAccessibilityLabelHasAssociatedControlName(rules);
|
|
24
|
-
for (const override of overrides
|
|
25
|
-
migrateToAccessibilityLabelHasAssociatedControlSchema(
|
|
23
|
+
for (const override of overrides ?? []) {
|
|
24
|
+
migrateToAccessibilityLabelHasAssociatedControlSchema(override.rules?.['@angular-eslint/template/accessibility-label-for']);
|
|
26
25
|
migrateToAccessibilityLabelHasAssociatedControlName(override.rules);
|
|
27
26
|
}
|
|
28
27
|
}
|
|
@@ -62,9 +61,8 @@ function addEqeqeq() {
|
|
|
62
61
|
return;
|
|
63
62
|
}
|
|
64
63
|
return (0, utils_1.updateJsonInTree)(filePath.toString(), (json) => {
|
|
65
|
-
var _a;
|
|
66
64
|
addEqeqeqIfNeeded(json.rules);
|
|
67
|
-
(
|
|
65
|
+
(json.overrides ?? []).forEach((override) => addEqeqeqIfNeeded(override.rules));
|
|
68
66
|
return json;
|
|
69
67
|
});
|
|
70
68
|
}),
|
|
@@ -27,17 +27,15 @@ function migration() {
|
|
|
27
27
|
},
|
|
28
28
|
]),
|
|
29
29
|
(0, utils_1.updateJsonInTree)('angular.json', (json) => {
|
|
30
|
-
var _a;
|
|
31
30
|
// Migrate any workspaces which use the original defaultCollection (but only if set to `@angular-eslint/schematics`)
|
|
32
|
-
if (
|
|
31
|
+
if (json.cli?.defaultCollection !== '@angular-eslint/schematics') {
|
|
33
32
|
return json;
|
|
34
33
|
}
|
|
35
34
|
return (0, utils_1.updateSchematicCollections)(json);
|
|
36
35
|
}),
|
|
37
36
|
// Migrate from @typescript-eslint/experimental-utils package name to @typescript-eslint/utils
|
|
38
37
|
(host, context) => (0, utils_1.updateJsonInTree)('package.json', (json) => {
|
|
39
|
-
|
|
40
|
-
const devDep = (_a = json.devDependencies) === null || _a === void 0 ? void 0 : _a['@typescript-eslint/experimental-utils'];
|
|
38
|
+
const devDep = json.devDependencies?.['@typescript-eslint/experimental-utils'];
|
|
41
39
|
if (!devDep) {
|
|
42
40
|
return json;
|
|
43
41
|
}
|
|
@@ -6,7 +6,7 @@ const utils_1 = require("../../utils");
|
|
|
6
6
|
const updatedAngularESLintVersion = '^2.0.0';
|
|
7
7
|
const updatedTypeScriptESLintVersion = '4.16.1';
|
|
8
8
|
function updateIfExists(deps, depName, updatedVersion) {
|
|
9
|
-
if (deps
|
|
9
|
+
if (deps?.[depName]) {
|
|
10
10
|
deps[depName] = updatedVersion;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -5,7 +5,7 @@ const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const updatedAngularESLintVersion = '^3.0.0';
|
|
7
7
|
function updateIfExists(deps, depName, updatedVersion) {
|
|
8
|
-
if (deps
|
|
8
|
+
if (deps?.[depName]) {
|
|
9
9
|
deps[depName] = updatedVersion;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -63,14 +63,13 @@ function removeNegativeValuesFromComponentMaxInlineDeclarations(rule) {
|
|
|
63
63
|
return;
|
|
64
64
|
const [, currentSchema] = rule;
|
|
65
65
|
rule[1] = Object.entries(currentSchema).reduce((accumulator, [key, value]) => {
|
|
66
|
-
return Number(value) < 0 ? accumulator :
|
|
66
|
+
return Number(value) < 0 ? accumulator : { ...accumulator, [key]: value };
|
|
67
67
|
}, {});
|
|
68
68
|
}
|
|
69
69
|
function updateComponentMaxInlineDeclarationsSchema({ overrides, rules, }) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
removeNegativeValuesFromComponentMaxInlineDeclarations((_a = override.rules) === null || _a === void 0 ? void 0 : _a['@angular-eslint/component-max-inline-declarations']);
|
|
70
|
+
removeNegativeValuesFromComponentMaxInlineDeclarations(rules?.['@angular-eslint/component-max-inline-declarations']);
|
|
71
|
+
for (const override of overrides ?? []) {
|
|
72
|
+
removeNegativeValuesFromComponentMaxInlineDeclarations(override.rules?.['@angular-eslint/component-max-inline-declarations']);
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
function updateComponentMaxInlineDeclarations() {
|
|
@@ -5,7 +5,7 @@ const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
6
|
const updatedAngularESLintVersion = '^4.0.0';
|
|
7
7
|
function updateIfExists(deps, depName, updatedVersion) {
|
|
8
|
-
if (deps
|
|
8
|
+
if (deps?.[depName]) {
|
|
9
9
|
deps[depName] = updatedVersion;
|
|
10
10
|
}
|
|
11
11
|
}
|
package/dist/ng-add/index.js
CHANGED
|
@@ -7,7 +7,6 @@ const utils_1 = require("../utils");
|
|
|
7
7
|
const packageJSON = require('../../package.json');
|
|
8
8
|
function addAngularESLintPackages() {
|
|
9
9
|
return (host, context) => {
|
|
10
|
-
var _a;
|
|
11
10
|
if (!host.exists('package.json')) {
|
|
12
11
|
throw new Error('Could not find a `package.json` file at the root of your workspace');
|
|
13
12
|
}
|
|
@@ -33,7 +32,7 @@ function addAngularESLintPackages() {
|
|
|
33
32
|
* @angular-eslint/schematics package to the dependencies section, so clean that up
|
|
34
33
|
* at this point
|
|
35
34
|
*/
|
|
36
|
-
if (
|
|
35
|
+
if (json.dependencies?.['@angular-eslint/schematics']) {
|
|
37
36
|
delete json.dependencies['@angular-eslint/schematics'];
|
|
38
37
|
}
|
|
39
38
|
json.devDependencies['@angular-eslint/schematics'] = packageJSON.version;
|
package/dist/utils.js
CHANGED
|
@@ -155,12 +155,12 @@ function visitNotIgnoredFiles(visitor, dir = (0, core_1.normalize)('')) {
|
|
|
155
155
|
ig.add(host.read('.gitignore').toString());
|
|
156
156
|
}
|
|
157
157
|
function visit(_dir) {
|
|
158
|
-
if (_dir &&
|
|
158
|
+
if (_dir && ig?.ignores(_dir)) {
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
const dirEntry = host.getDir(_dir);
|
|
162
162
|
dirEntry.subfiles.forEach((file) => {
|
|
163
|
-
if (ig
|
|
163
|
+
if (ig?.ignores((0, core_1.join)(_dir, file))) {
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
166
|
const maybeRule = visitor((0, core_1.join)(_dir, file), host, context);
|
|
@@ -240,13 +240,16 @@ function createProjectESLintConfig(projectRoot, projectType, prefix, setParserOp
|
|
|
240
240
|
extends: `${offsetFromRoot(projectRoot)}.eslintrc.json`,
|
|
241
241
|
ignorePatterns: ['!**/*'],
|
|
242
242
|
overrides: [
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
{
|
|
244
|
+
files: ['*.ts'],
|
|
245
|
+
...(setParserOptionsProject
|
|
246
|
+
? {
|
|
247
|
+
parserOptions: {
|
|
248
|
+
project: setESLintProjectBasedOnProjectType(projectRoot, projectType, hasE2e),
|
|
249
|
+
},
|
|
250
|
+
}
|
|
251
|
+
: null),
|
|
252
|
+
rules: {
|
|
250
253
|
'@angular-eslint/directive-selector': [
|
|
251
254
|
'error',
|
|
252
255
|
{ type: 'attribute', prefix, style: 'camelCase' },
|
|
@@ -255,7 +258,8 @@ function createProjectESLintConfig(projectRoot, projectType, prefix, setParserOp
|
|
|
255
258
|
'error',
|
|
256
259
|
{ type: 'element', prefix, style: 'kebab-case' },
|
|
257
260
|
],
|
|
258
|
-
}
|
|
261
|
+
},
|
|
262
|
+
},
|
|
259
263
|
{
|
|
260
264
|
files: ['*.html'],
|
|
261
265
|
rules: {},
|
|
@@ -268,13 +272,16 @@ function createProjectESLintConfig__NX(projectRoot, projectType, prefix, setPars
|
|
|
268
272
|
extends: `${(0, devkit_1.offsetFromRoot)(projectRoot)}.eslintrc.json`,
|
|
269
273
|
ignorePatterns: ['!**/*'],
|
|
270
274
|
overrides: [
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
{
|
|
276
|
+
files: ['*.ts'],
|
|
277
|
+
...(setParserOptionsProject
|
|
278
|
+
? {
|
|
279
|
+
parserOptions: {
|
|
280
|
+
project: setESLintProjectBasedOnProjectType(projectRoot, projectType, hasE2e),
|
|
281
|
+
},
|
|
282
|
+
}
|
|
283
|
+
: null),
|
|
284
|
+
rules: {
|
|
278
285
|
'@angular-eslint/directive-selector': [
|
|
279
286
|
'error',
|
|
280
287
|
{ type: 'attribute', prefix, style: 'camelCase' },
|
|
@@ -283,7 +290,8 @@ function createProjectESLintConfig__NX(projectRoot, projectType, prefix, setPars
|
|
|
283
290
|
'error',
|
|
284
291
|
{ type: 'element', prefix, style: 'kebab-case' },
|
|
285
292
|
],
|
|
286
|
-
}
|
|
293
|
+
},
|
|
294
|
+
},
|
|
287
295
|
{
|
|
288
296
|
files: ['*.html'],
|
|
289
297
|
rules: {},
|
|
@@ -295,7 +303,7 @@ function createESLintConfigForProject__NX(tree, projectName, setParserOptionsPro
|
|
|
295
303
|
const existingProjectConfig = readProjectConfiguration(tree, projectName);
|
|
296
304
|
const targets = existingProjectConfig.architect || existingProjectConfig.targets;
|
|
297
305
|
const { root: projectRoot, projectType, prefix } = existingProjectConfig;
|
|
298
|
-
const hasE2e = !!
|
|
306
|
+
const hasE2e = !!targets?.e2e;
|
|
299
307
|
/**
|
|
300
308
|
* If the root is an empty string it must be the initial project created at the
|
|
301
309
|
* root by the Angular CLI's workspace schematic
|
|
@@ -334,10 +342,9 @@ function createESLintConfigForProject(projectName, setParserOptionsProject) {
|
|
|
334
342
|
exports.createESLintConfigForProject = createESLintConfigForProject;
|
|
335
343
|
function createRootESLintConfigFile(projectName) {
|
|
336
344
|
return (tree) => {
|
|
337
|
-
var _a;
|
|
338
345
|
const angularJSON = readJsonInTree(tree, getWorkspacePath(tree));
|
|
339
346
|
let lintPrefix = null;
|
|
340
|
-
if (
|
|
347
|
+
if (angularJSON.projects?.[projectName]) {
|
|
341
348
|
const { prefix } = angularJSON.projects[projectName];
|
|
342
349
|
lintPrefix = prefix;
|
|
343
350
|
}
|
|
@@ -351,7 +358,10 @@ function sortObjectByKeys(obj) {
|
|
|
351
358
|
return Object.keys(obj)
|
|
352
359
|
.sort()
|
|
353
360
|
.reduce((result, key) => {
|
|
354
|
-
return
|
|
361
|
+
return {
|
|
362
|
+
...result,
|
|
363
|
+
[key]: obj[key],
|
|
364
|
+
};
|
|
355
365
|
}, {});
|
|
356
366
|
}
|
|
357
367
|
exports.sortObjectByKeys = sortObjectByKeys;
|
|
@@ -394,8 +404,7 @@ exports.determineTargetProjectName = determineTargetProjectName;
|
|
|
394
404
|
function determineTargetProjectHasE2E(
|
|
395
405
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
396
406
|
angularJSON, projectName) {
|
|
397
|
-
|
|
398
|
-
return !!((_a = getTargetsConfigFromProject(angularJSON.projects[projectName])) === null || _a === void 0 ? void 0 : _a.e2e);
|
|
407
|
+
return !!getTargetsConfigFromProject(angularJSON.projects[projectName])?.e2e;
|
|
399
408
|
}
|
|
400
409
|
/**
|
|
401
410
|
* See `schematicCollections` docs here:
|
|
@@ -416,7 +425,10 @@ function updateSchematicDefaults(angularJson, schematicFullName, defaultValues)
|
|
|
416
425
|
angularJson.schematics = angularJson.schematics || {};
|
|
417
426
|
angularJson.schematics[schematicFullName] =
|
|
418
427
|
angularJson.schematics[schematicFullName] || {};
|
|
419
|
-
angularJson.schematics[schematicFullName] =
|
|
428
|
+
angularJson.schematics[schematicFullName] = {
|
|
429
|
+
...angularJson.schematics[schematicFullName],
|
|
430
|
+
...defaultValues,
|
|
431
|
+
};
|
|
420
432
|
return angularJson;
|
|
421
433
|
}
|
|
422
434
|
exports.updateSchematicDefaults = updateSchematicDefaults;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/schematics",
|
|
3
|
-
"version": "17.3.1-alpha.
|
|
3
|
+
"version": "17.3.1-alpha.3",
|
|
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": "17.3.1-alpha.
|
|
37
|
-
"@angular-eslint/eslint-plugin-template": "17.3.1-alpha.
|
|
36
|
+
"@angular-eslint/eslint-plugin": "17.3.1-alpha.3",
|
|
37
|
+
"@angular-eslint/eslint-plugin-template": "17.3.1-alpha.3",
|
|
38
38
|
"@nx/devkit": "^17.2.8 || ^18.0.0",
|
|
39
39
|
"ignore": "5.3.1",
|
|
40
40
|
"nx": "^17.2.8 || ^18.0.0",
|