@angular-eslint/builder 22.1.1-alpha.13 → 22.1.1-alpha.15

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 +1 @@
1
- {"version":3,"file":"lint.impl.d.ts","sourceRoot":"","sources":["../src/lint.impl.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;;AAMvC,wBA0NE"}
1
+ {"version":3,"file":"lint.impl.d.ts","sourceRoot":"","sources":["../src/lint.impl.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;;AAavC,wBAqOE"}
package/dist/lint.impl.js CHANGED
@@ -2,8 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const architect_1 = require("@angular-devkit/architect");
4
4
  const fs_1 = require("fs");
5
+ const node_module_1 = require("node:module");
5
6
  const path_1 = require("path");
7
+ const angular_version_compat_1 = require("./utils/angular-version-compat");
6
8
  const eslint_utils_1 = require("./utils/eslint-utils");
9
+ const report_angular_version_compat_1 = require("./utils/report-angular-version-compat");
10
+ const requireFromModule = (0, node_module_1.createRequire)(__filename);
11
+ const { version: builderVersion } = requireFromModule('../package.json');
7
12
  exports.default = (0, architect_1.createBuilder)(async (options, context) => {
8
13
  try {
9
14
  const systemRoot = context.workspaceRoot;
@@ -28,6 +33,12 @@ exports.default = (0, architect_1.createBuilder)(async (options, context) => {
28
33
  if (printInfo) {
29
34
  console.info(`\nLinting ${JSON.stringify(projectName)}...`);
30
35
  }
36
+ const expectedMajor = (0, angular_version_compat_1.parseMajorVersion)(builderVersion);
37
+ if (expectedMajor !== null) {
38
+ (0, report_angular_version_compat_1.reportAngularVersionCompatibility)(systemRoot, expectedMajor, (message) => {
39
+ context.logger.warn(message);
40
+ });
41
+ }
31
42
  const eslintConfigPath = options.eslintConfig
32
43
  ? (0, path_1.resolve)(systemRoot, options.eslintConfig)
33
44
  : undefined;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Shared helpers for reporting Angular major mismatches without using a
3
+ * package-manager peer on `@angular/cli`.
4
+ */
5
+ export declare const ANGULAR_PACKAGES_TO_CHECK: readonly ["@angular/core", "@angular/cli"];
6
+ export interface PackageJsonLike {
7
+ dependencies?: Record<string, string>;
8
+ devDependencies?: Record<string, string>;
9
+ peerDependencies?: Record<string, string>;
10
+ version?: string;
11
+ }
12
+ export interface AngularVersionMismatch {
13
+ packageName: string;
14
+ specifier: string;
15
+ foundMajor: number;
16
+ }
17
+ /**
18
+ * Best-effort major from a semver version or range (`^22.1.0`, `~21.2.0`,
19
+ * `>= 22.0.0 < 23.0.0`, `22.1.0`).
20
+ */
21
+ export declare function parseMajorVersion(specifier: string | undefined | null): number | null;
22
+ export declare function findDeclaredDependency(pkg: PackageJsonLike, name: string): string | undefined;
23
+ export declare function findAngularVersionMismatches(workspacePackageJson: PackageJsonLike, expectedMajor: number, installedMajors?: Partial<Record<string, number | null>>): AngularVersionMismatch[];
24
+ export declare function hasDetectableAngularVersion(workspacePackageJson: PackageJsonLike, installedMajors?: Partial<Record<string, number | null>>): boolean;
25
+ export declare function formatAngularVersionMismatchMessage(expectedMajor: number, mismatches: AngularVersionMismatch[]): string;
26
+ export declare function formatAngularVersionMatchMessage(expectedMajor: number): string;
27
+ //# sourceMappingURL=angular-version-compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angular-version-compat.d.ts","sourceRoot":"","sources":["../../src/utils/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,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;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;AAED,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,sBAAsB,EAAE,GACnC,MAAM,CAcR;AAED,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,GACpB,MAAM,CAER"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ /**
3
+ * Shared helpers for reporting Angular major mismatches without using a
4
+ * package-manager peer on `@angular/cli`.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ANGULAR_PACKAGES_TO_CHECK = void 0;
8
+ exports.parseMajorVersion = parseMajorVersion;
9
+ exports.findDeclaredDependency = findDeclaredDependency;
10
+ exports.findAngularVersionMismatches = findAngularVersionMismatches;
11
+ exports.hasDetectableAngularVersion = hasDetectableAngularVersion;
12
+ exports.formatAngularVersionMismatchMessage = formatAngularVersionMismatchMessage;
13
+ exports.formatAngularVersionMatchMessage = formatAngularVersionMatchMessage;
14
+ exports.ANGULAR_PACKAGES_TO_CHECK = [
15
+ '@angular/core',
16
+ '@angular/cli',
17
+ ];
18
+ /**
19
+ * Best-effort major from a semver version or range (`^22.1.0`, `~21.2.0`,
20
+ * `>= 22.0.0 < 23.0.0`, `22.1.0`).
21
+ */
22
+ function parseMajorVersion(specifier) {
23
+ if (!specifier) {
24
+ return null;
25
+ }
26
+ const trimmed = specifier.trim();
27
+ if (!trimmed ||
28
+ trimmed === '*' ||
29
+ trimmed === 'latest' ||
30
+ /^(workspace|catalog|file|link|portal|git|http|https):/i.test(trimmed)) {
31
+ return null;
32
+ }
33
+ const match = trimmed.match(/(\d+)/);
34
+ if (!match) {
35
+ return null;
36
+ }
37
+ const major = Number(match[1]);
38
+ // 0.x (including the e2e publish version `0.0.0-e2e`) is not an
39
+ // Angular-aligned major; treat it as undetectable rather than v0.
40
+ if (major === 0) {
41
+ return null;
42
+ }
43
+ return major;
44
+ }
45
+ function findDeclaredDependency(pkg, name) {
46
+ return (pkg.dependencies?.[name] ??
47
+ pkg.devDependencies?.[name] ??
48
+ pkg.peerDependencies?.[name]);
49
+ }
50
+ function findAngularVersionMismatches(workspacePackageJson, expectedMajor, installedMajors) {
51
+ const mismatches = [];
52
+ for (const name of exports.ANGULAR_PACKAGES_TO_CHECK) {
53
+ const declared = findDeclaredDependency(workspacePackageJson, name);
54
+ const installedMajor = installedMajors?.[name];
55
+ const major = installedMajor ?? parseMajorVersion(declared);
56
+ if (major == null || major === expectedMajor) {
57
+ continue;
58
+ }
59
+ mismatches.push({
60
+ packageName: name,
61
+ specifier: declared ?? `v${major}`,
62
+ foundMajor: major,
63
+ });
64
+ }
65
+ return mismatches;
66
+ }
67
+ function hasDetectableAngularVersion(workspacePackageJson, installedMajors) {
68
+ return exports.ANGULAR_PACKAGES_TO_CHECK.some((name) => {
69
+ const installed = installedMajors?.[name];
70
+ if (installed != null) {
71
+ return true;
72
+ }
73
+ return (parseMajorVersion(findDeclaredDependency(workspacePackageJson, name)) !==
74
+ null);
75
+ });
76
+ }
77
+ function formatAngularVersionMismatchMessage(expectedMajor, mismatches) {
78
+ const details = mismatches
79
+ .map((mismatch) => ` - ${mismatch.packageName}@${mismatch.specifier} (v${mismatch.foundMajor})`)
80
+ .join('\n');
81
+ return `
82
+ angular-eslint v${expectedMajor} is intended for Angular v${expectedMajor}.
83
+ This workspace is using a different Angular major:
84
+ ${details}
85
+
86
+ See https://github.com/angular-eslint/angular-eslint/blob/main/docs/ANGULAR_VERSION_SUPPORT.md
87
+ `.trim();
88
+ }
89
+ function formatAngularVersionMatchMessage(expectedMajor) {
90
+ return `angular-eslint v${expectedMajor} matches this workspace's Angular v${expectedMajor}.`;
91
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Warn when the workspace Angular major does not match this builder's major.
3
+ * Does not fail the lint; package managers should not be the compatibility UI.
4
+ */
5
+ export declare function reportAngularVersionCompatibility(workspaceRoot: string, expectedMajor: number, warn: (message: string) => void): void;
6
+ //# sourceMappingURL=report-angular-version-compat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report-angular-version-compat.d.ts","sourceRoot":"","sources":["../../src/utils/report-angular-version-compat.ts"],"names":[],"mappings":"AA6CA;;;GAGG;AACH,wBAAgB,iCAAiC,CAC/C,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAC9B,IAAI,CAeN"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reportAngularVersionCompatibility = reportAngularVersionCompatibility;
4
+ const node_fs_1 = require("node:fs");
5
+ const node_path_1 = require("node:path");
6
+ const angular_version_compat_1 = require("./angular-version-compat");
7
+ function readWorkspacePackageJson(workspaceRoot) {
8
+ try {
9
+ return JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(workspaceRoot, 'package.json'), 'utf8'));
10
+ }
11
+ catch {
12
+ return {};
13
+ }
14
+ }
15
+ /**
16
+ * Read an installed package version from this workspace only (no walk-up
17
+ * into parent node_modules, which would lie in monorepo tests and nested
18
+ * workspaces).
19
+ */
20
+ function readInstalledMajor(workspaceRoot, packageName) {
21
+ try {
22
+ const pkgJsonPath = (0, node_path_1.join)(workspaceRoot, 'node_modules', ...packageName.split('/'), 'package.json');
23
+ const pkg = JSON.parse((0, node_fs_1.readFileSync)(pkgJsonPath, 'utf8'));
24
+ return (0, angular_version_compat_1.parseMajorVersion)(pkg.version);
25
+ }
26
+ catch {
27
+ return null;
28
+ }
29
+ }
30
+ /**
31
+ * Warn when the workspace Angular major does not match this builder's major.
32
+ * Does not fail the lint; package managers should not be the compatibility UI.
33
+ */
34
+ function reportAngularVersionCompatibility(workspaceRoot, expectedMajor, warn) {
35
+ const workspacePackageJson = readWorkspacePackageJson(workspaceRoot);
36
+ const installedMajors = {};
37
+ for (const name of angular_version_compat_1.ANGULAR_PACKAGES_TO_CHECK) {
38
+ installedMajors[name] = readInstalledMajor(workspaceRoot, name);
39
+ }
40
+ const mismatches = (0, angular_version_compat_1.findAngularVersionMismatches)(workspacePackageJson, expectedMajor, installedMajors);
41
+ if (mismatches.length === 0) {
42
+ return;
43
+ }
44
+ warn((0, angular_version_compat_1.formatAngularVersionMismatchMessage)(expectedMajor, mismatches));
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/builder",
3
- "version": "22.1.1-alpha.13",
3
+ "version": "22.1.1-alpha.15",
4
4
  "description": "Angular CLI builder for ESLint",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -24,7 +24,6 @@
24
24
  "@angular-devkit/core": ">= 22.0.0 < 23.0.0"
25
25
  },
26
26
  "peerDependencies": {
27
- "@angular/cli": ">= 22.0.0 < 23.0.0",
28
27
  "eslint": "^9.0.0 || ^10.0.0",
29
28
  "typescript": "*"
30
29
  },