@angular-eslint/schematics 22.3.1-alpha.7 → 22.3.1-alpha.8
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.
|
@@ -24,4 +24,16 @@ export declare function findAngularVersionMismatches(workspacePackageJson: Packa
|
|
|
24
24
|
export declare function hasDetectableAngularVersion(workspacePackageJson: PackageJsonLike, installedMajors?: Partial<Record<string, number | null>>): boolean;
|
|
25
25
|
export declare function formatAngularVersionMismatchMessage(expectedMajor: number, mismatches: AngularVersionMismatch[]): string;
|
|
26
26
|
export declare function formatAngularVersionMatchMessage(expectedMajor: number): string;
|
|
27
|
+
/**
|
|
28
|
+
* The Angular major that the user should install angular-eslint for, based on
|
|
29
|
+
* the mismatches found. `@angular/core` is the source of truth for the
|
|
30
|
+
* workspace's Angular version, so prefer it over `@angular/cli`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getRecommendedAngularMajor(mismatches: AngularVersionMismatch[]): number | null;
|
|
33
|
+
/**
|
|
34
|
+
* Error shown by `ng add` when the workspace Angular major does not match the
|
|
35
|
+
* angular-eslint major being added. Unlike the warning used by `ng lint`, this
|
|
36
|
+
* stops the schematic and tells the user exactly what to rerun.
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatAngularVersionMismatchError(expectedMajor: number, mismatches: AngularVersionMismatch[]): string;
|
|
27
39
|
//# sourceMappingURL=angular-version-compat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-version-compat.d.ts","sourceRoot":"","sources":["../src/angular-version-compat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,yBAAyB,4CAG5B,CAAC;AAEX,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,gBAAgB,CAAC,EAAE,MA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AAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GACnC,MAAM,GAAG,IAAI,CAwBf;AAED,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAMpB;AAED,wBAAgB,4BAA4B,CAC1C,oBAAoB,EAAE,eAAe,EACrC,aAAa,EAAE,MAAM,EACrB,eAAe,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,GACvD,sBAAsB,EAAE,CAgB1B;AAED,wBAAgB,2BAA2B,CACzC,oBAAoB,EAAE,eAAe,EACrC,eAAe,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,GACvD,OAAO,CAWT;AAsBD,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,sBAAsB,EAAE,GACnC,MAAM,CAMR;AAED,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,GACpB,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,sBAAsB,EAAE,GACnC,MAAM,GAAG,IAAI,CAKf;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,sBAAsB,EAAE,GACnC,MAAM,CAgBR"}
|
|
@@ -11,6 +11,8 @@ exports.findAngularVersionMismatches = findAngularVersionMismatches;
|
|
|
11
11
|
exports.hasDetectableAngularVersion = hasDetectableAngularVersion;
|
|
12
12
|
exports.formatAngularVersionMismatchMessage = formatAngularVersionMismatchMessage;
|
|
13
13
|
exports.formatAngularVersionMatchMessage = formatAngularVersionMatchMessage;
|
|
14
|
+
exports.getRecommendedAngularMajor = getRecommendedAngularMajor;
|
|
15
|
+
exports.formatAngularVersionMismatchError = formatAngularVersionMismatchError;
|
|
14
16
|
exports.ANGULAR_PACKAGES_TO_CHECK = [
|
|
15
17
|
'@angular/core',
|
|
16
18
|
'@angular/cli',
|
|
@@ -74,7 +76,8 @@ function hasDetectableAngularVersion(workspacePackageJson, installedMajors) {
|
|
|
74
76
|
null);
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
|
-
|
|
79
|
+
const ANGULAR_VERSION_SUPPORT_DOCS_URL = 'https://github.com/angular-eslint/angular-eslint/blob/main/docs/ANGULAR_VERSION_SUPPORT.md';
|
|
80
|
+
function formatAngularVersionMismatchDetails(expectedMajor, mismatches) {
|
|
78
81
|
const details = mismatches
|
|
79
82
|
.map((mismatch) => ` - ${mismatch.packageName}@${mismatch.specifier} (v${mismatch.foundMajor})`)
|
|
80
83
|
.join('\n');
|
|
@@ -82,10 +85,45 @@ function formatAngularVersionMismatchMessage(expectedMajor, mismatches) {
|
|
|
82
85
|
angular-eslint v${expectedMajor} is intended for Angular v${expectedMajor}.
|
|
83
86
|
This workspace is using a different Angular major:
|
|
84
87
|
${details}
|
|
88
|
+
`.trim();
|
|
89
|
+
}
|
|
90
|
+
function formatAngularVersionMismatchMessage(expectedMajor, mismatches) {
|
|
91
|
+
return `
|
|
92
|
+
${formatAngularVersionMismatchDetails(expectedMajor, mismatches)}
|
|
85
93
|
|
|
86
|
-
See
|
|
94
|
+
See ${ANGULAR_VERSION_SUPPORT_DOCS_URL}
|
|
87
95
|
`.trim();
|
|
88
96
|
}
|
|
89
97
|
function formatAngularVersionMatchMessage(expectedMajor) {
|
|
90
98
|
return `angular-eslint v${expectedMajor} matches this workspace's Angular v${expectedMajor}.`;
|
|
91
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The Angular major that the user should install angular-eslint for, based on
|
|
102
|
+
* the mismatches found. `@angular/core` is the source of truth for the
|
|
103
|
+
* workspace's Angular version, so prefer it over `@angular/cli`.
|
|
104
|
+
*/
|
|
105
|
+
function getRecommendedAngularMajor(mismatches) {
|
|
106
|
+
const core = mismatches.find((mismatch) => mismatch.packageName === '@angular/core');
|
|
107
|
+
return core?.foundMajor ?? mismatches[0]?.foundMajor ?? null;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Error shown by `ng add` when the workspace Angular major does not match the
|
|
111
|
+
* angular-eslint major being added. Unlike the warning used by `ng lint`, this
|
|
112
|
+
* stops the schematic and tells the user exactly what to rerun.
|
|
113
|
+
*/
|
|
114
|
+
function formatAngularVersionMismatchError(expectedMajor, mismatches) {
|
|
115
|
+
const major = getRecommendedAngularMajor(mismatches) ?? '<your Angular major>';
|
|
116
|
+
return `
|
|
117
|
+
${formatAngularVersionMismatchDetails(expectedMajor, mismatches)}
|
|
118
|
+
|
|
119
|
+
\`ng add\` installs the latest angular-eslint by default, which does not match this workspace.
|
|
120
|
+
Rerun the command with the Angular major of this workspace:
|
|
121
|
+
|
|
122
|
+
ng add angular-eslint@${major}
|
|
123
|
+
|
|
124
|
+
If you added @angular-eslint/schematics directly, rerun \`ng add @angular-eslint/schematics@${major}\` instead.
|
|
125
|
+
The mismatched package that \`ng add\` just installed will be replaced when you rerun it.
|
|
126
|
+
|
|
127
|
+
See ${ANGULAR_VERSION_SUPPORT_DOCS_URL}
|
|
128
|
+
`.trim();
|
|
129
|
+
}
|
package/dist/ng-add/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { Rule } from '@angular-devkit/schematics';
|
|
2
2
|
import type { Schema } from './schema';
|
|
3
|
+
/**
|
|
4
|
+
* Entry point for the ng-add schematic.
|
|
5
|
+
*
|
|
6
|
+
* @param options Configuration options passed to the schematic.
|
|
7
|
+
*/
|
|
3
8
|
export default function (options: Schema): Rule;
|
|
4
9
|
//# 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;
|
|
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;AAO/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA0NvC;;;;GAIG;AACH,MAAM,CAAC,OAAO,WAAW,OAAO,EAAE,MAAM,GAAG,IAAI,CAc9C"}
|
package/dist/ng-add/index.js
CHANGED
|
@@ -137,29 +137,38 @@ Please see https://github.com/angular-eslint/angular-eslint for more information
|
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
|
-
*
|
|
140
|
+
* `ng add` always resolves to the `latest` angular-eslint unless the user
|
|
141
|
+
* pins a major (the Angular CLI only consults `peerDependencies` when picking
|
|
142
|
+
* a version, and we intentionally do not declare a peer on `@angular/cli`, see
|
|
143
|
+
* docs/ANGULAR_VERSION_SUPPORT.md). So when the workspace is on a different
|
|
144
|
+
* Angular major we fail fast, before touching any files, and tell the user
|
|
145
|
+
* exactly which command to rerun.
|
|
141
146
|
*
|
|
142
|
-
*
|
|
147
|
+
* `ng lint` and `ng update` migrations only warn on the same mismatch.
|
|
143
148
|
*/
|
|
144
|
-
function
|
|
149
|
+
function assertAngularVersionCompatibility(workspacePackageJson, context) {
|
|
145
150
|
const expectedMajor = (0, angular_version_compat_1.parseMajorVersion)(packageJSON.version);
|
|
146
151
|
if (expectedMajor == null) {
|
|
147
152
|
return;
|
|
148
153
|
}
|
|
149
154
|
const mismatches = (0, angular_version_compat_1.findAngularVersionMismatches)(workspacePackageJson, expectedMajor);
|
|
150
155
|
if (mismatches.length > 0) {
|
|
151
|
-
|
|
152
|
-
return;
|
|
156
|
+
throw new schematics_1.SchematicsException((0, angular_version_compat_1.formatAngularVersionMismatchError)(expectedMajor, mismatches));
|
|
153
157
|
}
|
|
154
158
|
if ((0, angular_version_compat_1.hasDetectableAngularVersion)(workspacePackageJson)) {
|
|
155
159
|
context.logger.info((0, angular_version_compat_1.formatAngularVersionMatchMessage)(expectedMajor));
|
|
156
160
|
}
|
|
157
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Entry point for the ng-add schematic.
|
|
164
|
+
*
|
|
165
|
+
* @param options Configuration options passed to the schematic.
|
|
166
|
+
*/
|
|
158
167
|
function default_1(options) {
|
|
159
168
|
return (host, context) => {
|
|
160
169
|
const workspacePackageJSON = host.read('package.json').toString('utf-8');
|
|
161
170
|
const json = JSON.parse(workspacePackageJSON);
|
|
162
|
-
|
|
171
|
+
assertAngularVersionCompatibility(json, context);
|
|
163
172
|
return (0, schematics_1.chain)([
|
|
164
173
|
addAngularESLintPackages(json, options),
|
|
165
174
|
applyESLintConfigIfSingleProjectWithNoExistingTSLint(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/schematics",
|
|
3
|
-
"version": "22.3.1-alpha.
|
|
3
|
+
"version": "22.3.1-alpha.8",
|
|
4
4
|
"description": "Angular Schematics for angular-eslint",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@angular-devkit/core": ">= 22.0.0 < 23.0.0",
|
|
41
41
|
"@angular-devkit/schematics": ">= 22.0.0 < 23.0.0",
|
|
42
|
-
"@angular-eslint/eslint-plugin": "22.3.1-alpha.
|
|
43
|
-
"@angular-eslint/eslint-plugin-template": "22.3.1-alpha.
|
|
42
|
+
"@angular-eslint/eslint-plugin": "22.3.1-alpha.8",
|
|
43
|
+
"@angular-eslint/eslint-plugin-template": "22.3.1-alpha.8",
|
|
44
44
|
"ignore": "7.0.8",
|
|
45
45
|
"semver": "7.8.5",
|
|
46
46
|
"strip-json-comments": "3.1.1"
|