@angular-eslint/schematics 15.2.2-alpha.25 → 15.2.2-alpha.26

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.
@@ -1,120 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.uninstallTSLintAndCodelyzer = exports.ensureESLintPluginsAreInstalled = exports.updateObjPropAndRemoveDuplication = exports.updateArrPropAndRemoveDuplication = void 0;
27
- const tasks_1 = require("@angular-devkit/schematics/tasks");
28
- const assert = __importStar(require("assert"));
29
- const utils_1 = require("../utils");
30
- function updateArrPropAndRemoveDuplication(
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- json,
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- configBeingExtended, arrPropName, deleteIfUltimatelyEmpty) {
35
- json[arrPropName] = json[arrPropName] || [];
36
- configBeingExtended[arrPropName] = configBeingExtended[arrPropName] || [];
37
- json[arrPropName] = json[arrPropName].filter((extended) => !configBeingExtended[arrPropName].includes(extended));
38
- json[arrPropName] = Array.from(new Set(json[arrPropName]));
39
- if (deleteIfUltimatelyEmpty && json[arrPropName].length === 0) {
40
- delete json[arrPropName];
41
- }
42
- }
43
- exports.updateArrPropAndRemoveDuplication = updateArrPropAndRemoveDuplication;
44
- function updateObjPropAndRemoveDuplication(
45
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
- json,
47
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- configBeingExtended, objPropName, deleteIfUltimatelyEmpty) {
49
- json[objPropName] = json[objPropName] || {};
50
- configBeingExtended[objPropName] = configBeingExtended[objPropName] || {};
51
- for (const [name, val] of Object.entries(json[objPropName])) {
52
- const valueOfSamePropInExtendedConfig = configBeingExtended[objPropName][name];
53
- try {
54
- assert.deepStrictEqual(val, valueOfSamePropInExtendedConfig);
55
- delete json[objPropName][name];
56
- // eslint-disable-next-line no-empty
57
- }
58
- catch (_a) { }
59
- }
60
- if (deleteIfUltimatelyEmpty && Object.keys(json[objPropName]).length === 0) {
61
- delete json[objPropName];
62
- }
63
- }
64
- exports.updateObjPropAndRemoveDuplication = updateObjPropAndRemoveDuplication;
65
- function ensureESLintPluginsAreInstalled(eslintPluginsToBeInstalled) {
66
- return (host, context) => {
67
- var _a;
68
- if (!(eslintPluginsToBeInstalled === null || eslintPluginsToBeInstalled === void 0 ? void 0 : eslintPluginsToBeInstalled.length)) {
69
- return;
70
- }
71
- if (!host.exists('package.json')) {
72
- throw new Error('Could not find a `package.json` file at the root of your workspace');
73
- }
74
- const projectPackageJSON = host.read('package.json').toString('utf-8');
75
- const json = JSON.parse(projectPackageJSON);
76
- json.devDependencies = json.devDependencies || {};
77
- const pluginsToInstall = [];
78
- for (const pluginName of eslintPluginsToBeInstalled) {
79
- if (!json.devDependencies[pluginName] &&
80
- !((_a = json.dependencies) === null || _a === void 0 ? void 0 : _a[pluginName])) {
81
- json.devDependencies[pluginName] =
82
- // Hard code eslint-plugin-jsdoc version for now so that breaking rule change does not apply
83
- pluginName === 'eslint-plugin-jsdoc' ? '41.1.2' : 'latest';
84
- pluginsToInstall.push(pluginName);
85
- }
86
- }
87
- if (pluginsToInstall.length > 0) {
88
- context.logger.info('\nINFO: To most closely match your tslint.json, the `latest` version of the following eslint plugin(s) have been installed:');
89
- context.logger.info('\n - ' + pluginsToInstall.join('\n - '));
90
- context.logger.info('\nPlease note, you may wish to pin these to a specific version number in your package.json, rather than leaving it open to `latest`.\n');
91
- host.overwrite('package.json', JSON.stringify(json, null, 2));
92
- context.addTask(new tasks_1.NodePackageInstallTask());
93
- }
94
- return host;
95
- };
96
- }
97
- exports.ensureESLintPluginsAreInstalled = ensureESLintPluginsAreInstalled;
98
- function uninstallTSLintAndCodelyzer() {
99
- return (host, context) => {
100
- if (!host.exists('package.json')) {
101
- throw new Error('Could not find a `package.json` file at the root of your workspace');
102
- }
103
- const projectPackageJSON = host.read('package.json').toString('utf-8');
104
- const json = JSON.parse(projectPackageJSON);
105
- if (json.devDependencies) {
106
- delete json.devDependencies['tslint'];
107
- delete json.devDependencies['codelyzer'];
108
- json.devDependencies = (0, utils_1.sortObjectByKeys)(json.devDependencies);
109
- }
110
- if (json.dependencies) {
111
- delete json.dependencies['tslint'];
112
- delete json.dependencies['codelyzer'];
113
- json.dependencies = (0, utils_1.sortObjectByKeys)(json.dependencies);
114
- }
115
- host.overwrite('package.json', JSON.stringify(json, null, 2));
116
- context.addTask(new tasks_1.NodePackageInstallTask());
117
- return host;
118
- };
119
- }
120
- exports.uninstallTSLintAndCodelyzer = uninstallTSLintAndCodelyzer;