From 1cf2a499850251df86a9bf6aba3e147540353a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJamesHenry=E2=80=9D?= Date: Thu, 23 May 2024 16:25:26 +0400 Subject: [PATCH 1/4] feat(eslint-plugin)!: remove no-host-metadata-property from recommended, deprecate it --- .../src/configs/recommended.json | 1 - .../src/rules/no-host-metadata-property.ts | 6 +- tools/scripts/apply-canary-version.ts | 92 ++++++++++++------- 3 files changed, 64 insertions(+), 35 deletions(-) diff --git a/packages/eslint-plugin/src/configs/recommended.json b/packages/eslint-plugin/src/configs/recommended.json index 556705939..04af8c3f8 100644 --- a/packages/eslint-plugin/src/configs/recommended.json +++ b/packages/eslint-plugin/src/configs/recommended.json @@ -6,7 +6,6 @@ "@angular-eslint/contextual-lifecycle": "error", "@angular-eslint/directive-class-suffix": "error", "@angular-eslint/no-empty-lifecycle-method": "error", - "@angular-eslint/no-host-metadata-property": "error", "@angular-eslint/no-input-rename": "error", "@angular-eslint/no-inputs-metadata-property": "error", "@angular-eslint/no-output-native": "error", diff --git a/packages/eslint-plugin/src/rules/no-host-metadata-property.ts b/packages/eslint-plugin/src/rules/no-host-metadata-property.ts index fc0a1bd48..03734e415 100644 --- a/packages/eslint-plugin/src/rules/no-host-metadata-property.ts +++ b/packages/eslint-plugin/src/rules/no-host-metadata-property.ts @@ -14,9 +14,9 @@ export default createESLintRule({ name: RULE_NAME, meta: { type: 'suggestion', + deprecated: true, docs: { - description: `Disallows usage of the \`${METADATA_PROPERTY_NAME}\` metadata property. See more at ${STYLE_GUIDE_LINK}`, - recommended: 'recommended', + description: `Disallows usage of the \`${METADATA_PROPERTY_NAME}\` metadata property. NOTE: This used to be recommended by the Angular Team, but now they recommend the exact opposite: https://github.com/angular/angular/issues/54284`, }, schema: [ { @@ -31,7 +31,7 @@ export default createESLintRule({ }, ], messages: { - noHostMetadataProperty: `Use @${ASTUtils.AngularInnerClassDecorators.HostBinding} or @${ASTUtils.AngularInnerClassDecorators.HostListener} rather than the \`${METADATA_PROPERTY_NAME}\` metadata property (${STYLE_GUIDE_LINK})`, + noHostMetadataProperty: `Use @${ASTUtils.AngularInnerClassDecorators.HostBinding} or @${ASTUtils.AngularInnerClassDecorators.HostListener} rather than the \`${METADATA_PROPERTY_NAME}\` metadata property`, }, }, defaultOptions: [DEFAULT_OPTIONS], diff --git a/tools/scripts/apply-canary-version.ts b/tools/scripts/apply-canary-version.ts index 8923e5a43..bead19a29 100644 --- a/tools/scripts/apply-canary-version.ts +++ b/tools/scripts/apply-canary-version.ts @@ -1,21 +1,37 @@ +import { workspaceRoot } from '@nx/devkit'; import execa from 'execa'; import semver from 'semver'; +// We are either releasing a canary version of the latest major version, or one for the next major. +const overrideMajorVersion = process.env.OVERRIDE_MAJOR_VERSION; + const preid = 'alpha'; -const distTag = 'canary'; + +let distTag = 'canary'; +if (overrideMajorVersion) { + console.log( + `Overriding canary major version base to v${overrideMajorVersion}`, + ); + distTag = `rc-v${overrideMajorVersion}`; +} (async function main() { const currentLatestVersion = execa .sync('npm', ['view', '@angular-eslint/eslint-plugin@latest', 'version']) - .stdout?.trim(); + .stdout.trim(); - const currentCanaryVersion = execa - .sync('npm', [ - 'view', - `@angular-eslint/eslint-plugin@${distTag}`, - 'version', - ]) - .stdout?.trim(); + let currentCanaryVersion = null; + try { + currentCanaryVersion = execa + .sync('npm', [ + 'view', + `@angular-eslint/eslint-plugin@${distTag}`, + 'version', + ]) + .stdout.trim(); + } catch { + // (ignored - currentCanaryVersion can be null) + } console.log('\nResolved current versions: ', { currentLatestVersion, @@ -24,32 +40,45 @@ const distTag = 'canary'; let nextCanaryVersion: string | null; - if (semver.gte(currentLatestVersion, currentCanaryVersion)) { - console.log( - '\nLatest version is greater than or equal to the current canary version, starting new prerelease base...', - ); - // Determine next minor version above the currentLatestVersion - nextCanaryVersion = semver.inc( - currentLatestVersion, - 'prerelease', - undefined, - preid, - ); + if (overrideMajorVersion) { + nextCanaryVersion = currentCanaryVersion + ? semver.inc(currentCanaryVersion, 'prerelease', undefined, preid) + : semver.inc(currentLatestVersion, 'premajor', undefined, preid); } else { - console.log( - '\nLatest version is less than the current canary version, incrementing the existing prerelease base...', - ); - // Determine next prerelease version above the currentCanaryVersion - nextCanaryVersion = semver.inc( - currentCanaryVersion, - 'prerelease', - undefined, - preid, - ); + if (!currentCanaryVersion) { + throw new Error( + 'An unexpected error occurred, no current canary version could be read from the npm registry', + ); + } + + if (semver.gte(currentLatestVersion, currentCanaryVersion)) { + console.log( + '\nLatest version is greater than or equal to the current canary version, starting new prerelease base...', + ); + // Determine next minor version above the currentLatestVersion + nextCanaryVersion = semver.inc( + currentLatestVersion, + 'prerelease', + undefined, + preid, + ); + } else { + console.log( + '\nLatest version is less than the current canary version, incrementing the existing prerelease base...', + ); + // Determine next prerelease version above the currentCanaryVersion + nextCanaryVersion = semver.inc( + currentCanaryVersion, + 'prerelease', + undefined, + preid, + ); + } } if (!nextCanaryVersion) { console.log(`Error: Unable to determine next canary version`); + // eslint-disable-next-line no-process-exit process.exit(1); } @@ -59,7 +88,8 @@ const distTag = 'canary'; console.log(`\n> ${command}\n`); - execa.sync('yarn', command.split(' '), { + execa.sync('npx', command.split(' '), { stdio: 'inherit', + cwd: workspaceRoot, }); })(); From 346efa2649b70a70aeac377fece5ad6f01c2266b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJamesHenry=E2=80=9D?= Date: Thu, 23 May 2024 16:27:24 +0400 Subject: [PATCH 2/4] chore: remove unused --- packages/eslint-plugin/src/rules/no-host-metadata-property.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/eslint-plugin/src/rules/no-host-metadata-property.ts b/packages/eslint-plugin/src/rules/no-host-metadata-property.ts index 03734e415..cf2bbc1d0 100644 --- a/packages/eslint-plugin/src/rules/no-host-metadata-property.ts +++ b/packages/eslint-plugin/src/rules/no-host-metadata-property.ts @@ -8,7 +8,6 @@ export type MessageIds = 'noHostMetadataProperty'; export const RULE_NAME = 'no-host-metadata-property'; const DEFAULT_OPTIONS: Options[0] = { allowStatic: false }; const METADATA_PROPERTY_NAME = 'host'; -const STYLE_GUIDE_LINK = 'https://angular.io/styleguide#style-06-03'; export default createESLintRule({ name: RULE_NAME, From 892da1e82acb422abab8ccc70d61da190448763c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJamesHenry=E2=80=9D?= Date: Thu, 23 May 2024 16:33:44 +0400 Subject: [PATCH 3/4] chore: update rule docs --- .../eslint-plugin/docs/rules/no-host-metadata-property.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/no-host-metadata-property.md b/packages/eslint-plugin/docs/rules/no-host-metadata-property.md index 4507f2709..e21ccc479 100644 --- a/packages/eslint-plugin/docs/rules/no-host-metadata-property.md +++ b/packages/eslint-plugin/docs/rules/no-host-metadata-property.md @@ -15,7 +15,11 @@ # `@angular-eslint/no-host-metadata-property` -Disallows usage of the `host` metadata property. See more at https://angular.io/styleguide#style-06-03 +## ⚠️ THIS RULE IS DEPRECATED + +--- + +Disallows usage of the `host` metadata property. NOTE: This used to be recommended by the Angular Team, but now they recommend the exact opposite: https://github.com/angular/angular/issues/54284 - Type: suggestion From fb6ea41bd9e2da26a7c4c5fd624a3f5e2c94d9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJamesHenry=E2=80=9D?= Date: Thu, 23 May 2024 16:37:22 +0400 Subject: [PATCH 4/4] chore: update rule lists --- packages/eslint-plugin/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 66eee309f..f45cb055f 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -51,7 +51,6 @@ | [`no-duplicates-in-metadata-arrays`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-duplicates-in-metadata-arrays.md) | Ensures that metadata arrays do not contain duplicate entries. | | | | | [`no-empty-lifecycle-method`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-empty-lifecycle-method.md) | Disallows declaring empty lifecycle methods | :white_check_mark: | | :bulb: | | [`no-forward-ref`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-forward-ref.md) | Disallows usage of `forwardRef` references for DI | | | | -| [`no-host-metadata-property`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-host-metadata-property.md) | Disallows usage of the `host` metadata property. See more at https://angular.io/styleguide#style-06-03 | :white_check_mark: | | | | [`no-input-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-input-prefix.md) | Ensures that input bindings, including aliases, are not named or prefixed by the configured disallowed prefixes | | | | | [`no-input-rename`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-input-rename.md) | Ensures that input bindings are not aliased | :white_check_mark: | :wrench: | :bulb: | | [`no-inputs-metadata-property`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-inputs-metadata-property.md) | Disallows usage of the `inputs` metadata property. See more at https://angular.io/styleguide#style-05-12 | :white_check_mark: | | | @@ -88,6 +87,7 @@ | Rule | Replaced by | | --- | --- | +| [`no-host-metadata-property`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-host-metadata-property.md) | | | [`prefer-standalone-component`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone-component.md) | [`prefer-standalone`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone.md) | | [`sort-ngmodule-metadata-arrays`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/sort-ngmodule-metadata-arrays.md) | |