Skip to content

feat(eslint-plugin)!: remove no-host-metadata-property from recommended, deprecate it #1839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/eslint-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: | | |
Expand Down Expand Up @@ -88,6 +87,7 @@
<!-- prettier-ignore-start -->
| 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) | |
<!-- prettier-ignore-end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin/src/configs/recommended.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions packages/eslint-plugin/src/rules/no-host-metadata-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ 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<Options, MessageIds>({
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: [
{
Expand All @@ -31,7 +30,7 @@ export default createESLintRule<Options, MessageIds>({
},
],
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],
Expand Down
92 changes: 61 additions & 31 deletions tools/scripts/apply-canary-version.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
}

Expand All @@ -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,
});
})();