@angular-eslint/schematics 12.6.2-alpha.4 → 13.0.0-alpha.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/dist/add-eslint-to-project/index.js +4 -4
- package/dist/application/index.js +6 -6
- package/dist/application/schema.json +1 -13
- package/dist/convert-tslint-to-eslint/convert-to-eslint-config.js +5 -5
- package/dist/convert-tslint-to-eslint/index.js +50 -53
- package/dist/convert-tslint-to-eslint/utils.js +2 -2
- package/dist/library/index.js +6 -6
- package/dist/library/schema.json +0 -6
- package/dist/migrations/update-12-0-0/update-12-0-0.js +10 -12
- package/dist/migrations/update-13-0-0/update-13-0-0.js +29 -0
- package/dist/migrations/update-2-0-0/update-2-0-0.js +5 -5
- package/dist/migrations/update-3-0-0/update-3-0-0.js +8 -8
- package/dist/migrations/update-4-0-0/update-4-0-0.js +2 -2
- package/dist/migrations/utils/dependencies.js +2 -2
- package/dist/migrations.json +5 -0
- package/dist/ng-add/index.js +7 -7
- package/dist/utils.js +11 -11
- package/package.json +16 -8
|
@@ -4,7 +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
|
-
const projectName = utils_1.determineTargetProjectName(tree, schema.project);
|
|
7
|
+
const projectName = (0, utils_1.determineTargetProjectName)(tree, schema.project);
|
|
8
8
|
if (!projectName) {
|
|
9
9
|
throw new Error('\n' +
|
|
10
10
|
`
|
|
@@ -13,11 +13,11 @@ Error: You must specify a project to add ESLint to because you have multiple pro
|
|
|
13
13
|
E.g. npx ng g @angular-eslint/schematics:add-eslint-to-project {{YOUR_PROJECT_NAME_GOES_HERE}}
|
|
14
14
|
`.trim());
|
|
15
15
|
}
|
|
16
|
-
return schematics_1.chain([
|
|
16
|
+
return (0, schematics_1.chain)([
|
|
17
17
|
// Set the lint builder and config in angular.json
|
|
18
|
-
utils_1.addESLintTargetToProject(projectName, 'lint'),
|
|
18
|
+
(0, utils_1.addESLintTargetToProject)(projectName, 'lint'),
|
|
19
19
|
// Create the ESLint config file for the project
|
|
20
|
-
utils_1.createESLintConfigForProject(projectName),
|
|
20
|
+
(0, utils_1.createESLintConfigForProject)(projectName),
|
|
21
21
|
]);
|
|
22
22
|
};
|
|
23
23
|
}
|
|
@@ -3,19 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
function eslintRelatedChanges(options) {
|
|
6
|
-
return schematics_1.chain([
|
|
6
|
+
return (0, schematics_1.chain)([
|
|
7
7
|
// Update the lint builder and config in angular.json
|
|
8
|
-
utils_1.addESLintTargetToProject(options.name, 'lint'),
|
|
8
|
+
(0, utils_1.addESLintTargetToProject)(options.name, 'lint'),
|
|
9
9
|
// Create the ESLint config file for the project
|
|
10
|
-
utils_1.createESLintConfigForProject(options.name),
|
|
10
|
+
(0, utils_1.createESLintConfigForProject)(options.name),
|
|
11
11
|
// Delete the TSLint config file for the project
|
|
12
|
-
utils_1.removeTSLintJSONForProject(options.name),
|
|
12
|
+
(0, utils_1.removeTSLintJSONForProject)(options.name),
|
|
13
13
|
]);
|
|
14
14
|
}
|
|
15
15
|
function default_1(options) {
|
|
16
16
|
return (host, context) => {
|
|
17
|
-
return schematics_1.chain([
|
|
18
|
-
schematics_1.externalSchematic('@schematics/angular', 'application', options),
|
|
17
|
+
return (0, schematics_1.chain)([
|
|
18
|
+
(0, schematics_1.externalSchematic)('@schematics/angular', 'application', options),
|
|
19
19
|
eslintRelatedChanges(options),
|
|
20
20
|
])(host, context);
|
|
21
21
|
};
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"x-user-analytics": 10
|
|
34
34
|
},
|
|
35
35
|
"viewEncapsulation": {
|
|
36
|
-
"description": "The view encapsulation strategy to use in the new
|
|
36
|
+
"description": "The view encapsulation strategy to use in the new application.",
|
|
37
37
|
"enum": ["Emulated", "None", "ShadowDom"],
|
|
38
38
|
"type": "string",
|
|
39
39
|
"x-user-analytics": 11
|
|
@@ -101,23 +101,11 @@
|
|
|
101
101
|
"type": "boolean",
|
|
102
102
|
"default": false
|
|
103
103
|
},
|
|
104
|
-
"lintFix": {
|
|
105
|
-
"type": "boolean",
|
|
106
|
-
"description": "Apply lint fixes after generating the application.",
|
|
107
|
-
"x-user-analytics": 15,
|
|
108
|
-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
|
|
109
|
-
},
|
|
110
104
|
"strict": {
|
|
111
105
|
"description": "Creates an application with stricter bundle budgets settings.",
|
|
112
106
|
"type": "boolean",
|
|
113
107
|
"default": true,
|
|
114
108
|
"x-user-analytics": 7
|
|
115
|
-
},
|
|
116
|
-
"legacyBrowsers": {
|
|
117
|
-
"type": "boolean",
|
|
118
|
-
"description": "Add support for legacy browsers like Internet Explorer using differential loading.",
|
|
119
|
-
"default": false,
|
|
120
|
-
"x-deprecated": "Legacy browsers support is deprecated since version 12. For more information, see https://angular.io/guide/browser-support"
|
|
121
109
|
}
|
|
122
110
|
},
|
|
123
111
|
"required": ["name"]
|
|
@@ -26,8 +26,8 @@ function getTslintToEslintConfigLibrary(context) {
|
|
|
26
26
|
* in their node_modules, we dynamically install and uninstall the library as part of the conversion
|
|
27
27
|
* process.
|
|
28
28
|
*/
|
|
29
|
-
const tempDir = tmp_1.dirSync().name;
|
|
30
|
-
child_process_1.execSync(`npm i -D tslint-to-eslint-config@${tslintToEslintConfigVersion}`, {
|
|
29
|
+
const tempDir = (0, tmp_1.dirSync)().name;
|
|
30
|
+
(0, child_process_1.execSync)(`npm i -D tslint-to-eslint-config@${tslintToEslintConfigVersion}`, {
|
|
31
31
|
cwd: tempDir,
|
|
32
32
|
stdio: 'ignore',
|
|
33
33
|
});
|
|
@@ -92,7 +92,7 @@ function convertTSLintDisableCommentsForProject(projectName) {
|
|
|
92
92
|
* conversion schematic).
|
|
93
93
|
*/
|
|
94
94
|
const { convertFileComments } = getTslintToEslintConfigLibrary(context);
|
|
95
|
-
const workspaceJson = utils_1.readJsonInTree(tree, 'angular.json');
|
|
95
|
+
const workspaceJson = (0, utils_1.readJsonInTree)(tree, 'angular.json');
|
|
96
96
|
const existingProjectConfig = workspaceJson.projects[projectName];
|
|
97
97
|
let pathRoot = '';
|
|
98
98
|
// Default Angular CLI project at the root of the workspace
|
|
@@ -102,7 +102,7 @@ function convertTSLintDisableCommentsForProject(projectName) {
|
|
|
102
102
|
else {
|
|
103
103
|
pathRoot = existingProjectConfig.root;
|
|
104
104
|
}
|
|
105
|
-
return utils_1.visitNotIgnoredFiles((filePath, host) => {
|
|
105
|
+
return (0, utils_1.visitNotIgnoredFiles)((filePath, host) => {
|
|
106
106
|
if (!filePath.endsWith('.ts')) {
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
@@ -113,7 +113,7 @@ function convertTSLintDisableCommentsForProject(projectName) {
|
|
|
113
113
|
}
|
|
114
114
|
const updatedFileContent = convertFileComments({ fileContent, filePath });
|
|
115
115
|
host.overwrite(filePath, updatedFileContent);
|
|
116
|
-
}, core_1.normalize(pathRoot));
|
|
116
|
+
}, (0, core_1.normalize)(pathRoot));
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
exports.convertTSLintDisableCommentsForProject = convertTSLintDisableCommentsForProject;
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const core_1 = require("@angular-devkit/core");
|
|
7
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
8
|
-
const eslint_plugin_1 = __importDefault(require("@angular-eslint/eslint-plugin"));
|
|
9
|
-
const eslint_plugin_template_1 = __importDefault(require("@angular-eslint/eslint-plugin-template"));
|
|
10
5
|
const utils_1 = require("../utils");
|
|
11
6
|
const convert_to_eslint_config_1 = require("./convert-to-eslint-config");
|
|
12
7
|
const utils_2 = require("./utils");
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
9
|
+
const eslintPlugin = require('@angular-eslint/eslint-plugin');
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
11
|
+
const eslintPluginTemplate = require('@angular-eslint/eslint-plugin-template');
|
|
12
|
+
const eslintPluginConfigBaseOriginal = eslintPlugin.configs.base;
|
|
13
|
+
const eslintPluginConfigNgCliCompatOriginal = eslintPlugin.configs['ng-cli-compat'];
|
|
14
|
+
const eslintPluginConfigNgCliCompatFormattingAddOnOriginal = eslintPlugin.configs['ng-cli-compat--formatting-add-on'];
|
|
15
|
+
const eslintPluginTemplateConfigRecommendedOriginal = eslintPluginTemplate.configs.recommended;
|
|
19
16
|
function convert(schema) {
|
|
20
17
|
return (tree) => {
|
|
21
18
|
if (tree.exists('tsconfig.base.json')) {
|
|
22
19
|
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');
|
|
23
20
|
}
|
|
24
|
-
const projectName = utils_1.determineTargetProjectName(tree, schema.project);
|
|
21
|
+
const projectName = (0, utils_1.determineTargetProjectName)(tree, schema.project);
|
|
25
22
|
if (!projectName) {
|
|
26
23
|
throw new Error('\n' +
|
|
27
24
|
`
|
|
@@ -30,46 +27,46 @@ Error: You must specify a project to convert because you have multiple projects
|
|
|
30
27
|
E.g. npx ng g @angular-eslint/schematics:convert-tslint-to-eslint {{YOUR_PROJECT_NAME_GOES_HERE}}
|
|
31
28
|
`.trim());
|
|
32
29
|
}
|
|
33
|
-
const { root: projectRoot, projectType } = utils_1.getProjectConfig(tree, projectName);
|
|
30
|
+
const { root: projectRoot, projectType } = (0, utils_1.getProjectConfig)(tree, projectName);
|
|
34
31
|
// Default Angular CLI project at the root of the workspace
|
|
35
32
|
const isRootAngularProject = projectRoot === '';
|
|
36
33
|
// May or may not exist yet depending on if this is the root project, or a later one from projects/
|
|
37
|
-
const rootESLintrcJsonPath = core_1.join(core_1.normalize(tree.root.path), '.eslintrc.json');
|
|
34
|
+
const rootESLintrcJsonPath = (0, core_1.join)((0, core_1.normalize)(tree.root.path), '.eslintrc.json');
|
|
38
35
|
// Already exists, will be converted
|
|
39
|
-
const projectTSLintJsonPath = core_1.join(core_1.normalize(projectRoot), 'tslint.json');
|
|
40
|
-
return schematics_1.chain([
|
|
36
|
+
const projectTSLintJsonPath = (0, core_1.join)((0, core_1.normalize)(projectRoot), 'tslint.json');
|
|
37
|
+
return (0, schematics_1.chain)([
|
|
41
38
|
// Overwrite the "lint" target directly for the selected project in the angular.json
|
|
42
|
-
utils_1.addESLintTargetToProject(projectName, 'lint'),
|
|
39
|
+
(0, utils_1.addESLintTargetToProject)(projectName, 'lint'),
|
|
43
40
|
ensureRootESLintConfig(schema, tree, projectName, rootESLintrcJsonPath),
|
|
44
|
-
convert_to_eslint_config_1.convertTSLintDisableCommentsForProject(projectName),
|
|
41
|
+
(0, convert_to_eslint_config_1.convertTSLintDisableCommentsForProject)(projectName),
|
|
45
42
|
isRootAngularProject || schema.ignoreExistingTslintConfig
|
|
46
|
-
? schematics_1.noop()
|
|
43
|
+
? (0, schematics_1.noop)()
|
|
47
44
|
: removeExtendsFromProjectTSLintConfigBeforeConverting(tree, projectTSLintJsonPath),
|
|
48
45
|
isRootAngularProject
|
|
49
|
-
? schematics_1.noop()
|
|
46
|
+
? (0, schematics_1.noop)()
|
|
50
47
|
: schema.ignoreExistingTslintConfig
|
|
51
|
-
? schematics_1.chain([
|
|
48
|
+
? (0, schematics_1.chain)([
|
|
52
49
|
// Create the latest recommended ESLint config file for the project
|
|
53
|
-
utils_1.createESLintConfigForProject(projectName),
|
|
50
|
+
(0, utils_1.createESLintConfigForProject)(projectName),
|
|
54
51
|
// Delete the TSLint config file for the project
|
|
55
|
-
utils_1.removeTSLintJSONForProject(projectName),
|
|
52
|
+
(0, utils_1.removeTSLintJSONForProject)(projectName),
|
|
56
53
|
])
|
|
57
54
|
: convertNonRootTSLintConfig(schema, projectRoot, projectType, projectTSLintJsonPath, rootESLintrcJsonPath),
|
|
58
55
|
function cleanUpTSLintIfNoLongerInUse(tree) {
|
|
59
56
|
if (schema.removeTslintIfNoMoreTslintTargets &&
|
|
60
|
-
!utils_1.isTSLintUsedInWorkspace(tree)) {
|
|
61
|
-
tree.delete(core_1.join(core_1.normalize(tree.root.path), 'tslint.json'));
|
|
62
|
-
return schematics_1.chain([
|
|
57
|
+
!(0, utils_1.isTSLintUsedInWorkspace)(tree)) {
|
|
58
|
+
tree.delete((0, core_1.join)((0, core_1.normalize)(tree.root.path), 'tslint.json'));
|
|
59
|
+
return (0, schematics_1.chain)([
|
|
63
60
|
/**
|
|
64
61
|
* Update the default schematics collection to @angular-eslint so that future projects within
|
|
65
62
|
* the same workspace will also use ESLint
|
|
66
63
|
*/
|
|
67
|
-
utils_1.updateJsonInTree(utils_1.getWorkspacePath(tree), (json) => {
|
|
64
|
+
(0, utils_1.updateJsonInTree)((0, utils_1.getWorkspacePath)(tree), (json) => {
|
|
68
65
|
json.cli = json.cli || {};
|
|
69
66
|
json.cli.defaultCollection = '@angular-eslint/schematics';
|
|
70
67
|
return json;
|
|
71
68
|
}),
|
|
72
|
-
utils_2.uninstallTSLintAndCodelyzer(),
|
|
69
|
+
(0, utils_2.uninstallTSLintAndCodelyzer)(),
|
|
73
70
|
]);
|
|
74
71
|
}
|
|
75
72
|
return undefined;
|
|
@@ -91,7 +88,7 @@ exports.default = convert;
|
|
|
91
88
|
function ensureRootESLintConfig(schema, tree, projectName, rootESLintrcJsonPath) {
|
|
92
89
|
const hasExistingRootESLintrcConfig = tree.exists(rootESLintrcJsonPath);
|
|
93
90
|
if (hasExistingRootESLintrcConfig) {
|
|
94
|
-
return schematics_1.noop();
|
|
91
|
+
return (0, schematics_1.noop)();
|
|
95
92
|
}
|
|
96
93
|
/**
|
|
97
94
|
* When ignoreExistingTslintConfig is set, Do not perform a conversion of the root
|
|
@@ -99,9 +96,9 @@ function ensureRootESLintConfig(schema, tree, projectName, rootESLintrcJsonPath)
|
|
|
99
96
|
* recommended ESLint config.
|
|
100
97
|
*/
|
|
101
98
|
if (schema.ignoreExistingTslintConfig) {
|
|
102
|
-
const workspaceJson = utils_1.readJsonInTree(tree, utils_1.getWorkspacePath(tree));
|
|
99
|
+
const workspaceJson = (0, utils_1.readJsonInTree)(tree, (0, utils_1.getWorkspacePath)(tree));
|
|
103
100
|
const prefix = workspaceJson.projects[projectName].prefix || 'app';
|
|
104
|
-
return utils_1.updateJsonInTree(rootESLintrcJsonPath, () => ({
|
|
101
|
+
return (0, utils_1.updateJsonInTree)(rootESLintrcJsonPath, () => ({
|
|
105
102
|
root: true,
|
|
106
103
|
// Each additional project is linted independently
|
|
107
104
|
ignorePatterns: ['projects/**/*'],
|
|
@@ -147,8 +144,8 @@ function ensureRootESLintConfig(schema, tree, projectName, rootESLintrcJsonPath)
|
|
|
147
144
|
}
|
|
148
145
|
function convertRootTSLintConfig(schema, rootTSLintJsonPath, rootESLintrcJsonPath) {
|
|
149
146
|
return async (tree, context) => {
|
|
150
|
-
const rawRootTSLintJson = utils_1.readJsonInTree(tree, rootTSLintJsonPath);
|
|
151
|
-
const convertToESLintConfig = convert_to_eslint_config_1.createConvertToESLintConfig(context);
|
|
147
|
+
const rawRootTSLintJson = (0, utils_1.readJsonInTree)(tree, rootTSLintJsonPath);
|
|
148
|
+
const convertToESLintConfig = (0, convert_to_eslint_config_1.createConvertToESLintConfig)(context);
|
|
152
149
|
const convertedRoot = await convertToESLintConfig('tslint.json', rawRootTSLintJson);
|
|
153
150
|
const convertedRootESLintConfig = convertedRoot.convertedESLintConfig;
|
|
154
151
|
warnInCaseOfUnconvertedRules(context, rootTSLintJsonPath, convertedRoot.unconvertedTSLintRules);
|
|
@@ -182,7 +179,7 @@ function convertRootTSLintConfig(schema, rootTSLintJsonPath, rootESLintrcJsonPat
|
|
|
182
179
|
],
|
|
183
180
|
},
|
|
184
181
|
]);
|
|
185
|
-
utils_2.updateArrPropAndRemoveDuplication(convertedRootESLintConfig, {
|
|
182
|
+
(0, utils_2.updateArrPropAndRemoveDuplication)(convertedRootESLintConfig, {
|
|
186
183
|
/**
|
|
187
184
|
* For now, extending from these is too different to what the CLI ships with today, so
|
|
188
185
|
* we remove them from the converted results. We should look to move towards extending
|
|
@@ -205,7 +202,7 @@ function convertRootTSLintConfig(schema, rootTSLintJsonPath, rootESLintrcJsonPat
|
|
|
205
202
|
eslintPluginConfigNgCliCompatFormattingAddOn,
|
|
206
203
|
]);
|
|
207
204
|
const { codeRules, templateRules } = separateCodeAndTemplateRules(convertedRootESLintConfig);
|
|
208
|
-
utils_2.updateObjPropAndRemoveDuplication({ rules: templateRules }, eslintPluginTemplateConfigRecommended, 'rules', false);
|
|
205
|
+
(0, utils_2.updateObjPropAndRemoveDuplication)({ rules: templateRules }, eslintPluginTemplateConfigRecommended, 'rules', false);
|
|
209
206
|
convertedRootESLintConfig.root = true;
|
|
210
207
|
// Each additional project is linted independently
|
|
211
208
|
convertedRootESLintConfig.ignorePatterns = ['projects/**/*'];
|
|
@@ -238,8 +235,8 @@ function convertRootTSLintConfig(schema, rootTSLintJsonPath, rootESLintrcJsonPat
|
|
|
238
235
|
delete convertedRootESLintConfig.rules;
|
|
239
236
|
delete convertedRootESLintConfig.plugins;
|
|
240
237
|
delete convertedRootESLintConfig.extends;
|
|
241
|
-
return schematics_1.chain([
|
|
242
|
-
utils_2.ensureESLintPluginsAreInstalled(Array.from(new Set([
|
|
238
|
+
return (0, schematics_1.chain)([
|
|
239
|
+
(0, utils_2.ensureESLintPluginsAreInstalled)(Array.from(new Set([
|
|
243
240
|
/**
|
|
244
241
|
* These three plugins are needed for the ng-cli-compat config
|
|
245
242
|
*/
|
|
@@ -249,15 +246,15 @@ function convertRootTSLintConfig(schema, rootTSLintJsonPath, rootESLintrcJsonPat
|
|
|
249
246
|
...convertedRoot.ensureESLintPlugins,
|
|
250
247
|
]))),
|
|
251
248
|
// Create the .eslintrc.json file in the tree using the finalized config
|
|
252
|
-
utils_1.updateJsonInTree(rootESLintrcJsonPath, () => convertedRootESLintConfig),
|
|
249
|
+
(0, utils_1.updateJsonInTree)(rootESLintrcJsonPath, () => convertedRootESLintConfig),
|
|
253
250
|
]);
|
|
254
251
|
};
|
|
255
252
|
}
|
|
256
253
|
function convertNonRootTSLintConfig(schema, projectRoot, projectType, projectTSLintJsonPath, rootESLintrcJsonPath) {
|
|
257
254
|
return async (tree, context) => {
|
|
258
|
-
const rawProjectTSLintJson = utils_1.readJsonInTree(tree, projectTSLintJsonPath);
|
|
259
|
-
const rawRootESLintrcJson = utils_1.readJsonInTree(tree, rootESLintrcJsonPath);
|
|
260
|
-
const convertToESLintConfig = convert_to_eslint_config_1.createConvertToESLintConfig(context);
|
|
255
|
+
const rawProjectTSLintJson = (0, utils_1.readJsonInTree)(tree, projectTSLintJsonPath);
|
|
256
|
+
const rawRootESLintrcJson = (0, utils_1.readJsonInTree)(tree, rootESLintrcJsonPath);
|
|
257
|
+
const convertToESLintConfig = (0, convert_to_eslint_config_1.createConvertToESLintConfig)(context);
|
|
261
258
|
const convertedProject = await convertToESLintConfig(projectTSLintJsonPath, rawProjectTSLintJson);
|
|
262
259
|
const convertedProjectESLintConfig = convertedProject.convertedESLintConfig;
|
|
263
260
|
warnInCaseOfUnconvertedRules(context, projectTSLintJsonPath, convertedProject.unconvertedTSLintRules);
|
|
@@ -292,7 +289,7 @@ function convertNonRootTSLintConfig(schema, projectRoot, projectType, projectTSL
|
|
|
292
289
|
],
|
|
293
290
|
},
|
|
294
291
|
]);
|
|
295
|
-
utils_2.updateArrPropAndRemoveDuplication(convertedProjectESLintConfig, {
|
|
292
|
+
(0, utils_2.updateArrPropAndRemoveDuplication)(convertedProjectESLintConfig, {
|
|
296
293
|
/**
|
|
297
294
|
* For now, extending from these is too different to what the CLI ships with today, so
|
|
298
295
|
* we remove them from the converted results. We should look to move towards extending
|
|
@@ -317,18 +314,18 @@ function convertNonRootTSLintConfig(schema, projectRoot, projectType, projectTSL
|
|
|
317
314
|
rawRootESLintrcJson,
|
|
318
315
|
]);
|
|
319
316
|
const { codeRules, templateRules } = separateCodeAndTemplateRules(convertedProjectESLintConfig);
|
|
320
|
-
utils_2.updateObjPropAndRemoveDuplication({ rules: templateRules }, eslintPluginTemplateConfigRecommended, 'rules', false);
|
|
317
|
+
(0, utils_2.updateObjPropAndRemoveDuplication)({ rules: templateRules }, eslintPluginTemplateConfigRecommended, 'rules', false);
|
|
321
318
|
const convertedExtends = convertedProjectESLintConfig.extends;
|
|
322
319
|
delete convertedProjectESLintConfig.extends;
|
|
323
320
|
// Extend from the workspace's root config at the top level
|
|
324
|
-
const relativeOffestToRootESLintrcJson = `${utils_1.offsetFromRoot(tree.root.path)}.eslintrc.json`;
|
|
321
|
+
const relativeOffestToRootESLintrcJson = `${(0, utils_1.offsetFromRoot)(tree.root.path)}.eslintrc.json`;
|
|
325
322
|
convertedProjectESLintConfig.extends = relativeOffestToRootESLintrcJson;
|
|
326
323
|
convertedProjectESLintConfig.ignorePatterns = ['!**/*'];
|
|
327
324
|
convertedProjectESLintConfig.overrides = [
|
|
328
325
|
{
|
|
329
326
|
files: ['*.ts'],
|
|
330
327
|
parserOptions: {
|
|
331
|
-
project: utils_1.setESLintProjectBasedOnProjectType(projectRoot, projectType, true),
|
|
328
|
+
project: (0, utils_1.setESLintProjectBasedOnProjectType)(projectRoot, projectType, true),
|
|
332
329
|
createDefaultProgram: true,
|
|
333
330
|
},
|
|
334
331
|
extends: convertedExtends || undefined,
|
|
@@ -346,10 +343,10 @@ function convertNonRootTSLintConfig(schema, projectRoot, projectType, projectTSL
|
|
|
346
343
|
// All applied in the .ts overrides block so should no longer be at the root of the config
|
|
347
344
|
delete convertedProjectESLintConfig.rules;
|
|
348
345
|
delete convertedProjectESLintConfig.plugins;
|
|
349
|
-
return schematics_1.chain([
|
|
350
|
-
utils_2.ensureESLintPluginsAreInstalled(convertedProject.ensureESLintPlugins),
|
|
346
|
+
return (0, schematics_1.chain)([
|
|
347
|
+
(0, utils_2.ensureESLintPluginsAreInstalled)(convertedProject.ensureESLintPlugins),
|
|
351
348
|
// Create the .eslintrc.json file in the tree using the finalized config
|
|
352
|
-
utils_1.updateJsonInTree(core_1.join(core_1.normalize(projectRoot), '.eslintrc.json'), () => convertedProjectESLintConfig),
|
|
349
|
+
(0, utils_1.updateJsonInTree)((0, core_1.join)((0, core_1.normalize)(projectRoot), '.eslintrc.json'), () => convertedProjectESLintConfig),
|
|
353
350
|
// Delete the project's tslint.json, it's no longer needed
|
|
354
351
|
(host) => host.delete(projectTSLintJsonPath),
|
|
355
352
|
]);
|
|
@@ -364,11 +361,11 @@ function convertNonRootTSLintConfig(schema, projectRoot, projectType, projectTSL
|
|
|
364
361
|
* TSLint as a library.
|
|
365
362
|
*/
|
|
366
363
|
function removeExtendsFromProjectTSLintConfigBeforeConverting(tree, projectTSLintJsonPath) {
|
|
367
|
-
return utils_1.updateJsonInTree(projectTSLintJsonPath, (json) => {
|
|
364
|
+
return (0, utils_1.updateJsonInTree)(projectTSLintJsonPath, (json) => {
|
|
368
365
|
if (!json.extends) {
|
|
369
366
|
return json;
|
|
370
367
|
}
|
|
371
|
-
const extendsFromRoot = `${utils_1.offsetFromRoot(tree.root.path)}tslint.json`;
|
|
368
|
+
const extendsFromRoot = `${(0, utils_1.offsetFromRoot)(tree.root.path)}tslint.json`;
|
|
372
369
|
if (Array.isArray(json.extends) && json.extends.length) {
|
|
373
370
|
json.extends = json.extends.filter((ext) => ext !== extendsFromRoot);
|
|
374
371
|
}
|
|
@@ -474,17 +471,17 @@ function removeUndesiredRulesFromConfig(convertedConfig) {
|
|
|
474
471
|
}
|
|
475
472
|
function dedupeEnvAgainstConfigs(convertedConfig, otherConfigs) {
|
|
476
473
|
otherConfigs.forEach((againstConfig) => {
|
|
477
|
-
utils_2.updateObjPropAndRemoveDuplication(convertedConfig, againstConfig, 'env', true);
|
|
474
|
+
(0, utils_2.updateObjPropAndRemoveDuplication)(convertedConfig, againstConfig, 'env', true);
|
|
478
475
|
});
|
|
479
476
|
}
|
|
480
477
|
function dedupeRulesAgainstConfigs(convertedConfig, otherConfigs) {
|
|
481
478
|
otherConfigs.forEach((againstConfig) => {
|
|
482
|
-
utils_2.updateObjPropAndRemoveDuplication(convertedConfig, againstConfig, 'rules', false);
|
|
479
|
+
(0, utils_2.updateObjPropAndRemoveDuplication)(convertedConfig, againstConfig, 'rules', false);
|
|
483
480
|
});
|
|
484
481
|
}
|
|
485
482
|
function dedupePluginsAgainstConfigs(convertedConfig, otherConfigs) {
|
|
486
483
|
otherConfigs.forEach((againstConfig) => {
|
|
487
|
-
utils_2.updateArrPropAndRemoveDuplication(convertedConfig, againstConfig, 'plugins', true);
|
|
484
|
+
(0, utils_2.updateArrPropAndRemoveDuplication)(convertedConfig, againstConfig, 'plugins', true);
|
|
488
485
|
});
|
|
489
486
|
}
|
|
490
487
|
/**
|
|
@@ -99,12 +99,12 @@ function uninstallTSLintAndCodelyzer() {
|
|
|
99
99
|
if (json.devDependencies) {
|
|
100
100
|
delete json.devDependencies['tslint'];
|
|
101
101
|
delete json.devDependencies['codelyzer'];
|
|
102
|
-
json.devDependencies = utils_1.sortObjectByKeys(json.devDependencies);
|
|
102
|
+
json.devDependencies = (0, utils_1.sortObjectByKeys)(json.devDependencies);
|
|
103
103
|
}
|
|
104
104
|
if (json.dependencies) {
|
|
105
105
|
delete json.dependencies['tslint'];
|
|
106
106
|
delete json.dependencies['codelyzer'];
|
|
107
|
-
json.dependencies = utils_1.sortObjectByKeys(json.dependencies);
|
|
107
|
+
json.dependencies = (0, utils_1.sortObjectByKeys)(json.dependencies);
|
|
108
108
|
}
|
|
109
109
|
host.overwrite('package.json', JSON.stringify(json, null, 2));
|
|
110
110
|
context.addTask(new tasks_1.NodePackageInstallTask());
|
package/dist/library/index.js
CHANGED
|
@@ -8,19 +8,19 @@ function eslintRelatedChanges(options) {
|
|
|
8
8
|
* provided the interactive CLI prompt will throw
|
|
9
9
|
*/
|
|
10
10
|
const projectName = options.name;
|
|
11
|
-
return schematics_1.chain([
|
|
11
|
+
return (0, schematics_1.chain)([
|
|
12
12
|
// Update the lint builder and config in angular.json
|
|
13
|
-
utils_1.addESLintTargetToProject(projectName, 'lint'),
|
|
13
|
+
(0, utils_1.addESLintTargetToProject)(projectName, 'lint'),
|
|
14
14
|
// Create the ESLint config file for the project
|
|
15
|
-
utils_1.createESLintConfigForProject(projectName),
|
|
15
|
+
(0, utils_1.createESLintConfigForProject)(projectName),
|
|
16
16
|
// Delete the TSLint config file for the project
|
|
17
|
-
utils_1.removeTSLintJSONForProject(projectName),
|
|
17
|
+
(0, utils_1.removeTSLintJSONForProject)(projectName),
|
|
18
18
|
]);
|
|
19
19
|
}
|
|
20
20
|
function default_1(options) {
|
|
21
21
|
return (host, context) => {
|
|
22
|
-
return schematics_1.chain([
|
|
23
|
-
schematics_1.externalSchematic('@schematics/angular', 'library', options),
|
|
22
|
+
return (0, schematics_1.chain)([
|
|
23
|
+
(0, schematics_1.externalSchematic)('@schematics/angular', 'library', options),
|
|
24
24
|
eslintRelatedChanges(options),
|
|
25
25
|
])(host, context);
|
|
26
26
|
};
|
package/dist/library/schema.json
CHANGED
|
@@ -43,12 +43,6 @@
|
|
|
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
|
-
"lintFix": {
|
|
48
|
-
"type": "boolean",
|
|
49
|
-
"description": "Apply lint fixes after generating the library.",
|
|
50
|
-
"x-user-analytics": 15,
|
|
51
|
-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
|
|
52
46
|
}
|
|
53
47
|
},
|
|
54
48
|
"required": []
|
|
@@ -4,10 +4,8 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const dependencies_1 = require("../utils/dependencies");
|
|
6
6
|
const updatedAngularESLintVersion = '^12.0.0';
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const updatedTypeScriptESLintVersion = packageJSON.devDependencies['@typescript-eslint/experimental-utils'];
|
|
10
|
-
const updatedESLintVersion = packageJSON.devDependencies['eslint'];
|
|
7
|
+
const updatedTypeScriptESLintVersion = '4.28.2';
|
|
8
|
+
const updatedESLintVersion = '7.26.0';
|
|
11
9
|
function migrateToAccessibilityLabelHasAssociatedControlSchema(rule) {
|
|
12
10
|
if (!Array.isArray(rule) || rule.length !== 2)
|
|
13
11
|
return;
|
|
@@ -37,12 +35,12 @@ function migrateToAccessibilityLabelHasAssociatedControlName(rules) {
|
|
|
37
35
|
accessibilityLabelForRule;
|
|
38
36
|
}
|
|
39
37
|
function updateAccessibilityLabelFor() {
|
|
40
|
-
return schematics_1.chain([
|
|
41
|
-
utils_1.visitNotIgnoredFiles((filePath) => {
|
|
38
|
+
return (0, schematics_1.chain)([
|
|
39
|
+
(0, utils_1.visitNotIgnoredFiles)((filePath) => {
|
|
42
40
|
if (!filePath.endsWith('.eslintrc.json')) {
|
|
43
41
|
return;
|
|
44
42
|
}
|
|
45
|
-
return utils_1.updateJsonInTree(filePath.toString(), (json) => {
|
|
43
|
+
return (0, utils_1.updateJsonInTree)(filePath.toString(), (json) => {
|
|
46
44
|
migrateFromAccessibilityLabelFor(json);
|
|
47
45
|
return json;
|
|
48
46
|
});
|
|
@@ -58,12 +56,12 @@ function addEqeqeqIfNeeded(rules) {
|
|
|
58
56
|
rules['@angular-eslint/template/eqeqeq'] = 'error';
|
|
59
57
|
}
|
|
60
58
|
function addEqeqeq() {
|
|
61
|
-
return schematics_1.chain([
|
|
62
|
-
utils_1.visitNotIgnoredFiles((filePath) => {
|
|
59
|
+
return (0, schematics_1.chain)([
|
|
60
|
+
(0, utils_1.visitNotIgnoredFiles)((filePath) => {
|
|
63
61
|
if (!filePath.endsWith('.eslintrc.json')) {
|
|
64
62
|
return;
|
|
65
63
|
}
|
|
66
|
-
return utils_1.updateJsonInTree(filePath.toString(), (json) => {
|
|
64
|
+
return (0, utils_1.updateJsonInTree)(filePath.toString(), (json) => {
|
|
67
65
|
var _a;
|
|
68
66
|
addEqeqeqIfNeeded(json.rules);
|
|
69
67
|
((_a = json.overrides) !== null && _a !== void 0 ? _a : []).forEach((override) => addEqeqeqIfNeeded(override.rules));
|
|
@@ -73,8 +71,8 @@ function addEqeqeq() {
|
|
|
73
71
|
]);
|
|
74
72
|
}
|
|
75
73
|
function migration() {
|
|
76
|
-
return schematics_1.chain([
|
|
77
|
-
dependencies_1.updateDependencies([
|
|
74
|
+
return (0, schematics_1.chain)([
|
|
75
|
+
(0, dependencies_1.updateDependencies)([
|
|
78
76
|
{
|
|
79
77
|
packageName: '@angular-eslint/builder',
|
|
80
78
|
version: updatedAngularESLintVersion,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
4
|
+
const dependencies_1 = require("../utils/dependencies");
|
|
5
|
+
const updatedTypeScriptESLintVersion = '5.3.0';
|
|
6
|
+
const updatedESLintVersion = '8.1.0';
|
|
7
|
+
function migration() {
|
|
8
|
+
return (0, schematics_1.chain)([
|
|
9
|
+
(0, dependencies_1.updateDependencies)([
|
|
10
|
+
{
|
|
11
|
+
packageName: '@typescript-eslint/eslint-plugin',
|
|
12
|
+
version: updatedTypeScriptESLintVersion,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
packageName: '@typescript-eslint/experimental-utils',
|
|
16
|
+
version: updatedTypeScriptESLintVersion,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
packageName: '@typescript-eslint/parser',
|
|
20
|
+
version: updatedTypeScriptESLintVersion,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
packageName: 'eslint',
|
|
24
|
+
version: `^${updatedESLintVersion}`,
|
|
25
|
+
},
|
|
26
|
+
]),
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
exports.default = migration;
|
|
@@ -11,7 +11,7 @@ function updateIfExists(deps, depName, updatedVersion) {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
function updateRelevantDependencies(host, context) {
|
|
14
|
-
return utils_1.updateJsonInTree('package.json', (json) => {
|
|
14
|
+
return (0, utils_1.updateJsonInTree)('package.json', (json) => {
|
|
15
15
|
/**
|
|
16
16
|
* @angular-eslint
|
|
17
17
|
*/
|
|
@@ -42,12 +42,12 @@ function removeRuleFromESLintConfig(ruleName, config) {
|
|
|
42
42
|
}
|
|
43
43
|
function removeUsePipeDecoratorRule() {
|
|
44
44
|
const ruleName = '@angular-eslint/use-pipe-decorator';
|
|
45
|
-
return schematics_1.chain([
|
|
46
|
-
utils_1.visitNotIgnoredFiles((filePath) => {
|
|
45
|
+
return (0, schematics_1.chain)([
|
|
46
|
+
(0, utils_1.visitNotIgnoredFiles)((filePath) => {
|
|
47
47
|
if (!filePath.endsWith('.eslintrc.json')) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
return utils_1.updateJsonInTree(filePath.toString(), (json) => {
|
|
50
|
+
return (0, utils_1.updateJsonInTree)(filePath.toString(), (json) => {
|
|
51
51
|
removeRuleFromESLintConfig(ruleName, json);
|
|
52
52
|
return json;
|
|
53
53
|
});
|
|
@@ -55,6 +55,6 @@ function removeUsePipeDecoratorRule() {
|
|
|
55
55
|
]);
|
|
56
56
|
}
|
|
57
57
|
function default_1() {
|
|
58
|
-
return schematics_1.chain([updateRelevantDependencies, removeUsePipeDecoratorRule]);
|
|
58
|
+
return (0, schematics_1.chain)([updateRelevantDependencies, removeUsePipeDecoratorRule]);
|
|
59
59
|
}
|
|
60
60
|
exports.default = default_1;
|
|
@@ -10,7 +10,7 @@ function updateIfExists(deps, depName, updatedVersion) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
function updateRelevantDependencies(host, context) {
|
|
13
|
-
return utils_1.updateJsonInTree('package.json', (json) => {
|
|
13
|
+
return (0, utils_1.updateJsonInTree)('package.json', (json) => {
|
|
14
14
|
/**
|
|
15
15
|
* @angular-eslint
|
|
16
16
|
*/
|
|
@@ -46,12 +46,12 @@ function addRecommendedExtraExtendsWhereApplicable(config) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
function applyRecommendedExtraExtends() {
|
|
49
|
-
return schematics_1.chain([
|
|
50
|
-
utils_1.visitNotIgnoredFiles((filePath) => {
|
|
49
|
+
return (0, schematics_1.chain)([
|
|
50
|
+
(0, utils_1.visitNotIgnoredFiles)((filePath) => {
|
|
51
51
|
if (!filePath.endsWith('.eslintrc.json')) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
return utils_1.updateJsonInTree(filePath.toString(), (json) => {
|
|
54
|
+
return (0, utils_1.updateJsonInTree)(filePath.toString(), (json) => {
|
|
55
55
|
addRecommendedExtraExtendsWhereApplicable(json);
|
|
56
56
|
return json;
|
|
57
57
|
});
|
|
@@ -74,12 +74,12 @@ function updateComponentMaxInlineDeclarationsSchema({ overrides, rules, }) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
function updateComponentMaxInlineDeclarations() {
|
|
77
|
-
return schematics_1.chain([
|
|
78
|
-
utils_1.visitNotIgnoredFiles((filePath) => {
|
|
77
|
+
return (0, schematics_1.chain)([
|
|
78
|
+
(0, utils_1.visitNotIgnoredFiles)((filePath) => {
|
|
79
79
|
if (!filePath.endsWith('.eslintrc.json')) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
return utils_1.updateJsonInTree(filePath.toString(), (json) => {
|
|
82
|
+
return (0, utils_1.updateJsonInTree)(filePath.toString(), (json) => {
|
|
83
83
|
updateComponentMaxInlineDeclarationsSchema(json);
|
|
84
84
|
return json;
|
|
85
85
|
});
|
|
@@ -87,7 +87,7 @@ function updateComponentMaxInlineDeclarations() {
|
|
|
87
87
|
]);
|
|
88
88
|
}
|
|
89
89
|
function default_1() {
|
|
90
|
-
return schematics_1.chain([
|
|
90
|
+
return (0, schematics_1.chain)([
|
|
91
91
|
updateRelevantDependencies,
|
|
92
92
|
applyRecommendedExtraExtends,
|
|
93
93
|
updateComponentMaxInlineDeclarations,
|
|
@@ -10,7 +10,7 @@ function updateIfExists(deps, depName, updatedVersion) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
function updateRelevantDependencies(host, context) {
|
|
13
|
-
return utils_1.updateJsonInTree('package.json', (json) => {
|
|
13
|
+
return (0, utils_1.updateJsonInTree)('package.json', (json) => {
|
|
14
14
|
/**
|
|
15
15
|
* @angular-eslint
|
|
16
16
|
*/
|
|
@@ -23,6 +23,6 @@ function updateRelevantDependencies(host, context) {
|
|
|
23
23
|
})(host, context);
|
|
24
24
|
}
|
|
25
25
|
function default_1() {
|
|
26
|
-
return schematics_1.chain([updateRelevantDependencies]);
|
|
26
|
+
return (0, schematics_1.chain)([updateRelevantDependencies]);
|
|
27
27
|
}
|
|
28
28
|
exports.default = default_1;
|
|
@@ -5,8 +5,8 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
|
5
5
|
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
function updateDependencies(depsToUpdate) {
|
|
8
|
-
return schematics_1.chain([
|
|
9
|
-
utils_1.updateJsonInTree('package.json', (json) => {
|
|
8
|
+
return (0, schematics_1.chain)([
|
|
9
|
+
(0, utils_1.updateJsonInTree)('package.json', (json) => {
|
|
10
10
|
for (const { packageName, version } of depsToUpdate) {
|
|
11
11
|
updateIfExists(json, packageName, version);
|
|
12
12
|
}
|
package/dist/migrations.json
CHANGED
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
"version": "4.9.0",
|
|
21
21
|
"description": "Updates @angular-eslint to v12",
|
|
22
22
|
"factory": "./migrations/update-12-0-0/update-12-0-0"
|
|
23
|
+
},
|
|
24
|
+
"update-13-0-0": {
|
|
25
|
+
"version": "13.0.0-alpha.0",
|
|
26
|
+
"description": "Updates @angular-eslint to v13",
|
|
27
|
+
"factory": "./migrations/update-13-0-0/update-13-0-0"
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
}
|
package/dist/ng-add/index.js
CHANGED
|
@@ -45,7 +45,7 @@ function addAngularESLintPackages() {
|
|
|
45
45
|
json.devDependencies['@typescript-eslint/eslint-plugin'] =
|
|
46
46
|
typescriptESLintVersion;
|
|
47
47
|
json.devDependencies['@typescript-eslint/parser'] = typescriptESLintVersion;
|
|
48
|
-
json.devDependencies = utils_1.sortObjectByKeys(json.devDependencies);
|
|
48
|
+
json.devDependencies = (0, utils_1.sortObjectByKeys)(json.devDependencies);
|
|
49
49
|
host.overwrite('package.json', JSON.stringify(json, null, 2));
|
|
50
50
|
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
51
51
|
context.logger.info(`
|
|
@@ -58,7 +58,7 @@ Please see https://github.com/angular-eslint/angular-eslint for how to add ESLin
|
|
|
58
58
|
}
|
|
59
59
|
function applyESLintConfigIfSingleProjectWithNoExistingTSLint() {
|
|
60
60
|
return (host, context) => {
|
|
61
|
-
const angularJson = utils_1.readJsonInTree(host, 'angular.json');
|
|
61
|
+
const angularJson = (0, utils_1.readJsonInTree)(host, 'angular.json');
|
|
62
62
|
if (!angularJson || !angularJson.projects) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
@@ -68,7 +68,7 @@ function applyESLintConfigIfSingleProjectWithNoExistingTSLint() {
|
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
const singleProject = angularJson.projects[projectNames[0]];
|
|
71
|
-
const targetsConfig = utils_1.getTargetsConfigFromProject(singleProject);
|
|
71
|
+
const targetsConfig = (0, utils_1.getTargetsConfigFromProject)(singleProject);
|
|
72
72
|
// Only possible if malformed, safer to finish here
|
|
73
73
|
if (!targetsConfig) {
|
|
74
74
|
return;
|
|
@@ -82,9 +82,9 @@ We detected that you have a single project in your workspace and no existing lin
|
|
|
82
82
|
|
|
83
83
|
Please see https://github.com/angular-eslint/angular-eslint for more information.
|
|
84
84
|
`);
|
|
85
|
-
return schematics_1.chain([
|
|
86
|
-
schematics_1.schematic('add-eslint-to-project', {}),
|
|
87
|
-
utils_1.updateJsonInTree('angular.json', (json) => {
|
|
85
|
+
return (0, schematics_1.chain)([
|
|
86
|
+
(0, schematics_1.schematic)('add-eslint-to-project', {}),
|
|
87
|
+
(0, utils_1.updateJsonInTree)('angular.json', (json) => {
|
|
88
88
|
json.cli = json.cli || {};
|
|
89
89
|
json.cli.defaultCollection = '@angular-eslint/schematics';
|
|
90
90
|
return json;
|
|
@@ -94,7 +94,7 @@ Please see https://github.com/angular-eslint/angular-eslint for more information
|
|
|
94
94
|
}
|
|
95
95
|
function default_1() {
|
|
96
96
|
return (host, context) => {
|
|
97
|
-
return schematics_1.chain([
|
|
97
|
+
return (0, schematics_1.chain)([
|
|
98
98
|
addAngularESLintPackages(),
|
|
99
99
|
applyESLintConfigIfSingleProjectWithNoExistingTSLint(),
|
|
100
100
|
])(host, context);
|
package/dist/utils.js
CHANGED
|
@@ -19,12 +19,12 @@ function readJsonInTree(host, path) {
|
|
|
19
19
|
if (!host.exists(path)) {
|
|
20
20
|
throw new Error(`Cannot find ${path}`);
|
|
21
21
|
}
|
|
22
|
-
const contents = strip_json_comments_1.default(host.read(path).toString('utf-8'));
|
|
22
|
+
const contents = (0, strip_json_comments_1.default)(host.read(path).toString('utf-8'));
|
|
23
23
|
try {
|
|
24
24
|
return JSON.parse(contents);
|
|
25
25
|
}
|
|
26
26
|
catch (e) {
|
|
27
|
-
throw new Error(`Cannot parse ${path}: ${e.message}`);
|
|
27
|
+
throw new Error(`Cannot parse ${path}: ${e instanceof Error ? e.message : ''}`);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
exports.readJsonInTree = readJsonInTree;
|
|
@@ -103,7 +103,7 @@ function getProjectConfig(host, name) {
|
|
|
103
103
|
}
|
|
104
104
|
exports.getProjectConfig = getProjectConfig;
|
|
105
105
|
function offsetFromRoot(fullPathToSourceDir) {
|
|
106
|
-
const parts = core_1.normalize(fullPathToSourceDir).split('/');
|
|
106
|
+
const parts = (0, core_1.normalize)(fullPathToSourceDir).split('/');
|
|
107
107
|
let offset = '';
|
|
108
108
|
for (let i = 0; i < parts.length; ++i) {
|
|
109
109
|
offset += '../';
|
|
@@ -151,11 +151,11 @@ exports.addESLintTargetToProject = addESLintTargetToProject;
|
|
|
151
151
|
/**
|
|
152
152
|
* Utility to act on all files in a tree that are not ignored by git.
|
|
153
153
|
*/
|
|
154
|
-
function visitNotIgnoredFiles(visitor, dir = core_1.normalize('')) {
|
|
154
|
+
function visitNotIgnoredFiles(visitor, dir = (0, core_1.normalize)('')) {
|
|
155
155
|
return (host, context) => {
|
|
156
156
|
let ig;
|
|
157
157
|
if (host.exists('.gitignore')) {
|
|
158
|
-
ig = ignore_1.default();
|
|
158
|
+
ig = (0, ignore_1.default)();
|
|
159
159
|
ig.add(host.read('.gitignore').toString());
|
|
160
160
|
}
|
|
161
161
|
function visit(_dir) {
|
|
@@ -164,16 +164,16 @@ function visitNotIgnoredFiles(visitor, dir = core_1.normalize('')) {
|
|
|
164
164
|
}
|
|
165
165
|
const dirEntry = host.getDir(_dir);
|
|
166
166
|
dirEntry.subfiles.forEach((file) => {
|
|
167
|
-
if (ig === null || ig === void 0 ? void 0 : ig.ignores(core_1.join(_dir, file))) {
|
|
167
|
+
if (ig === null || ig === void 0 ? void 0 : ig.ignores((0, core_1.join)(_dir, file))) {
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
|
-
const maybeRule = visitor(core_1.join(_dir, file), host, context);
|
|
170
|
+
const maybeRule = visitor((0, core_1.join)(_dir, file), host, context);
|
|
171
171
|
if (maybeRule) {
|
|
172
|
-
schematics_1.callRule(maybeRule, host, context).subscribe();
|
|
172
|
+
(0, schematics_1.callRule)(maybeRule, host, context).subscribe();
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
175
|
dirEntry.subdirs.forEach((subdir) => {
|
|
176
|
-
visit(core_1.join(_dir, subdir));
|
|
176
|
+
visit((0, core_1.join)(_dir, subdir));
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
visit(dir);
|
|
@@ -288,7 +288,7 @@ function createESLintConfigForProject(projectName) {
|
|
|
288
288
|
if (projectRoot === '') {
|
|
289
289
|
return createRootESLintConfigFile(projectName);
|
|
290
290
|
}
|
|
291
|
-
return updateJsonInTree(core_1.join(core_1.normalize(projectRoot), '.eslintrc.json'), () => createProjectESLintConfig(tree.root.path, projectRoot, projectType, prefix, hasE2e));
|
|
291
|
+
return updateJsonInTree((0, core_1.join)((0, core_1.normalize)(projectRoot), '.eslintrc.json'), () => createProjectESLintConfig(tree.root.path, projectRoot, projectType, prefix, hasE2e));
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
exports.createESLintConfigForProject = createESLintConfigForProject;
|
|
@@ -296,7 +296,7 @@ function removeTSLintJSONForProject(projectName) {
|
|
|
296
296
|
return (tree) => {
|
|
297
297
|
const angularJSON = readJsonInTree(tree, 'angular.json');
|
|
298
298
|
const { root: projectRoot } = angularJSON.projects[projectName];
|
|
299
|
-
const tslintJsonPath = core_1.join(core_1.normalize(projectRoot || '/'), 'tslint.json');
|
|
299
|
+
const tslintJsonPath = (0, core_1.join)((0, core_1.normalize)(projectRoot || '/'), 'tslint.json');
|
|
300
300
|
if (tree.exists(tslintJsonPath)) {
|
|
301
301
|
tree.delete(tslintJsonPath);
|
|
302
302
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/schematics",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0-alpha.0",
|
|
4
4
|
"description": "Angular Schematics for angular-eslint",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,26 +18,34 @@
|
|
|
18
18
|
],
|
|
19
19
|
"schematics": "./dist/collection.json",
|
|
20
20
|
"ng-update": {
|
|
21
|
-
"migrations": "./dist/migrations.json"
|
|
21
|
+
"migrations": "./dist/migrations.json",
|
|
22
|
+
"packageGroup": [
|
|
23
|
+
"@angular-eslint/builder",
|
|
24
|
+
"@angular-eslint/bundled-angular-compiler",
|
|
25
|
+
"@angular-eslint/eslint-plugin",
|
|
26
|
+
"@angular-eslint/eslint-plugin-template",
|
|
27
|
+
"@angular-eslint/template-parser",
|
|
28
|
+
"@angular-eslint/utils"
|
|
29
|
+
]
|
|
22
30
|
},
|
|
23
31
|
"ng-add": {
|
|
24
32
|
"save": "devDependencies"
|
|
25
33
|
},
|
|
26
34
|
"dependencies": {
|
|
27
|
-
"@angular-eslint/eslint-plugin": "
|
|
28
|
-
"@angular-eslint/eslint-plugin-template": "
|
|
35
|
+
"@angular-eslint/eslint-plugin": "13.0.0-alpha.0",
|
|
36
|
+
"@angular-eslint/eslint-plugin-template": "13.0.0-alpha.0",
|
|
29
37
|
"ignore": "5.1.8",
|
|
30
38
|
"strip-json-comments": "3.1.1",
|
|
31
39
|
"tmp": "0.2.1"
|
|
32
40
|
},
|
|
33
41
|
"devDependencies": {
|
|
34
42
|
"@types/tmp": "0.2.2",
|
|
35
|
-
"@typescript-eslint/experimental-utils": "
|
|
36
|
-
"eslint": "
|
|
43
|
+
"@typescript-eslint/experimental-utils": "5.3.0",
|
|
44
|
+
"eslint": "8.1.0",
|
|
37
45
|
"tslint-to-eslint-config": "2.4.0"
|
|
38
46
|
},
|
|
39
47
|
"peerDependencies": {
|
|
40
|
-
"@angular/cli": ">=
|
|
48
|
+
"@angular/cli": ">= 13.0.0-rc.2 < 14.0.0"
|
|
41
49
|
},
|
|
42
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "3e9ea918032ff4f03d44cccfa873df36c370f7b9"
|
|
43
51
|
}
|