mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor: add override keyword to members implementing abstract declarations (#42512)
In combination with the TS `noImplicitOverride` compatibility changes, we also want to follow the best-practice of adding `override` to members which are implemented as part of abstract classes. This commit fixes all instances which will be flagged as part of the custom `no-implicit-override-abstract` TSLint rule. PR Close #42512
This commit is contained in:
committed by
Andrew Kushnir
parent
04642e7985
commit
b5ab7aff43
@@ -13,10 +13,10 @@ const exampleData = 'this is example data' as const;
|
||||
|
||||
/** A simple usage of the BaseModule to illustrate the workings built into the abstract class. */
|
||||
class ConcreteBaseModule extends BaseModule<typeof exampleData> {
|
||||
async retrieveData() {
|
||||
override async retrieveData() {
|
||||
return exampleData;
|
||||
}
|
||||
async printToTerminal() {}
|
||||
override async printToTerminal() {}
|
||||
}
|
||||
|
||||
describe('BaseModule', () => {
|
||||
|
||||
@@ -25,7 +25,7 @@ type CiData = {
|
||||
}[];
|
||||
|
||||
export class CiModule extends BaseModule<CiData> {
|
||||
async retrieveData() {
|
||||
override async retrieveData() {
|
||||
const gitRepoWithApi = {api: this.git.github, ...this.git.remoteConfig};
|
||||
const releaseTrains = await fetchActiveReleaseTrains(gitRepoWithApi);
|
||||
|
||||
@@ -52,7 +52,7 @@ export class CiModule extends BaseModule<CiData> {
|
||||
return await Promise.all(ciResultPromises);
|
||||
}
|
||||
|
||||
async printToTerminal() {
|
||||
override async printToTerminal() {
|
||||
const data = await this.data;
|
||||
const minLabelLength = Math.max(...data.map(result => result.label.length));
|
||||
info.group(bold(`CI`));
|
||||
|
||||
@@ -23,7 +23,7 @@ export interface G3StatsData {
|
||||
}
|
||||
|
||||
export class G3Module extends BaseModule<G3StatsData|void> {
|
||||
async retrieveData() {
|
||||
override async retrieveData() {
|
||||
const toCopyToG3 = this.getG3FileIncludeAndExcludeLists();
|
||||
const latestSha = this.getLatestShas();
|
||||
|
||||
@@ -35,7 +35,7 @@ export class G3Module extends BaseModule<G3StatsData|void> {
|
||||
latestSha.g3, latestSha.master, toCopyToG3.include, toCopyToG3.exclude);
|
||||
}
|
||||
|
||||
async printToTerminal() {
|
||||
override async printToTerminal() {
|
||||
const stats = await this.data;
|
||||
if (!stats) {
|
||||
return;
|
||||
|
||||
@@ -45,7 +45,7 @@ type GithubQueryResult = {
|
||||
const MAX_RETURNED_ISSUES = 20;
|
||||
|
||||
export class GithubQueriesModule extends BaseModule<GithubQueryResults|void> {
|
||||
async retrieveData() {
|
||||
override async retrieveData() {
|
||||
// Non-null assertion is used here as the check for undefined immediately follows to confirm the
|
||||
// assertion. Typescript's type filtering does not seem to work as needed to understand
|
||||
// whether githubQueries is undefined or not.
|
||||
@@ -95,7 +95,7 @@ export class GithubQueriesModule extends BaseModule<GithubQueryResults|void> {
|
||||
return graphqlQuery;
|
||||
}
|
||||
|
||||
async printToTerminal() {
|
||||
override async printToTerminal() {
|
||||
const queryResults = await this.data;
|
||||
if (!queryResults) {
|
||||
return;
|
||||
|
||||
@@ -45,11 +45,11 @@ export const services: ServiceConfig[] = [
|
||||
];
|
||||
|
||||
export class ServicesModule extends BaseModule<StatusCheckResult[]> {
|
||||
async retrieveData() {
|
||||
override async retrieveData() {
|
||||
return Promise.all(services.map(service => this.getStatusFromStandardApi(service)));
|
||||
}
|
||||
|
||||
async printToTerminal() {
|
||||
override async printToTerminal() {
|
||||
const statuses = await this.data;
|
||||
const serviceNameMinLength = Math.max(...statuses.map(service => service.name.length));
|
||||
info.group(bold('Service Statuses'));
|
||||
|
||||
@@ -16,13 +16,13 @@ import {Formatter} from './base-formatter';
|
||||
* Formatter for running buildifier against bazel related files.
|
||||
*/
|
||||
export class Buildifier extends Formatter {
|
||||
name = 'buildifier';
|
||||
override name = 'buildifier';
|
||||
|
||||
binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/buildifier');
|
||||
override binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/buildifier');
|
||||
|
||||
defaultFileMatcher = ['**/*.bzl', '**/BUILD.bazel', '**/WORKSPACE', '**/BUILD'];
|
||||
override defaultFileMatcher = ['**/*.bzl', '**/BUILD.bazel', '**/WORKSPACE', '**/BUILD'];
|
||||
|
||||
actions = {
|
||||
override actions = {
|
||||
check: {
|
||||
commandFlags: `${BAZEL_WARNING_FLAG} --lint=warn --mode=check --format=json`,
|
||||
callback:
|
||||
|
||||
@@ -16,13 +16,13 @@ import {Formatter} from './base-formatter';
|
||||
* Formatter for running clang-format against Typescript and Javascript files
|
||||
*/
|
||||
export class ClangFormat extends Formatter {
|
||||
name = 'clang-format';
|
||||
override name = 'clang-format';
|
||||
|
||||
binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/clang-format');
|
||||
override binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/clang-format');
|
||||
|
||||
defaultFileMatcher = ['**/*.{t,j}s'];
|
||||
override defaultFileMatcher = ['**/*.{t,j}s'];
|
||||
|
||||
actions = {
|
||||
override actions = {
|
||||
check: {
|
||||
commandFlags: `--Werror -n -style=file`,
|
||||
callback:
|
||||
|
||||
@@ -17,11 +17,11 @@ import {Formatter} from './base-formatter';
|
||||
* Formatter for running prettier against Typescript and Javascript files.
|
||||
*/
|
||||
export class Prettier extends Formatter {
|
||||
name = 'prettier';
|
||||
override name = 'prettier';
|
||||
|
||||
binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/prettier');
|
||||
override binaryFilePath = join(this.git.baseDir, 'node_modules/.bin/prettier');
|
||||
|
||||
defaultFileMatcher = ['**/*.{t,j}s'];
|
||||
override defaultFileMatcher = ['**/*.{t,j}s'];
|
||||
|
||||
/**
|
||||
* The configuration path of the prettier config, obtained during construction to prevent needing
|
||||
@@ -30,7 +30,7 @@ export class Prettier extends Formatter {
|
||||
private configPath =
|
||||
this.config['prettier'] ? exec(`${this.binaryFilePath} --find-config-path .`).trim() : '';
|
||||
|
||||
actions = {
|
||||
override actions = {
|
||||
check: {
|
||||
commandFlags: `--config ${this.configPath} --check`,
|
||||
callback:
|
||||
|
||||
@@ -44,7 +44,7 @@ export class GithubApiMergeStrategy extends MergeStrategy {
|
||||
super(git);
|
||||
}
|
||||
|
||||
async merge(pullRequest: PullRequest): Promise<PullRequestFailure|null> {
|
||||
override async merge(pullRequest: PullRequest): Promise<PullRequestFailure|null> {
|
||||
const {githubTargetBranch, prNumber, targetBranches, requiredBaseSha, needsCommitMessageFixup} =
|
||||
pullRequest;
|
||||
// If the pull request does not have its base branch set to any determined target
|
||||
|
||||
@@ -31,7 +31,7 @@ export class AutosquashMergeStrategy extends MergeStrategy {
|
||||
* specific to the pull request merge.
|
||||
* @returns A pull request failure or null in case of success.
|
||||
*/
|
||||
async merge(pullRequest: PullRequest): Promise<PullRequestFailure|null> {
|
||||
override async merge(pullRequest: PullRequest): Promise<PullRequestFailure|null> {
|
||||
const {prNumber, targetBranches, requiredBaseSha, needsCommitMessageFixup, githubTargetBranch} =
|
||||
pullRequest;
|
||||
// In case a required base is specified for this pull request, check if the pull
|
||||
|
||||
@@ -21,13 +21,13 @@ import {packageJsonPath} from '../constants';
|
||||
export class ConfigureNextAsMajorAction extends ReleaseAction {
|
||||
private _newVersion = semver.parse(`${this.active.next.version.major + 1}.0.0-next.0`)!;
|
||||
|
||||
async getDescription() {
|
||||
override async getDescription() {
|
||||
const {branchName} = this.active.next;
|
||||
const newVersion = this._newVersion;
|
||||
return `Configure the "${branchName}" branch to be released as major (v${newVersion}).`;
|
||||
}
|
||||
|
||||
async perform() {
|
||||
override async perform() {
|
||||
const {branchName} = this.active.next;
|
||||
const newVersion = this._newVersion;
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@ export class CutLongTermSupportPatchAction extends ReleaseAction {
|
||||
/** Promise resolving an object describing long-term support branches. */
|
||||
ltsBranches = fetchLongTermSupportBranchesFromNpm(this.config);
|
||||
|
||||
async getDescription() {
|
||||
override async getDescription() {
|
||||
const {active} = await this.ltsBranches;
|
||||
return `Cut a new release for an active LTS branch (${active.length} active).`;
|
||||
}
|
||||
|
||||
async perform() {
|
||||
override async perform() {
|
||||
const ltsBranch = await this._promptForTargetLtsBranch();
|
||||
const newVersion = semverInc(ltsBranch.version, 'patch');
|
||||
const {pullRequest: {id}, releaseNotes} =
|
||||
|
||||
@@ -18,13 +18,13 @@ import {ReleaseAction} from '../actions';
|
||||
export class CutNewPatchAction extends ReleaseAction {
|
||||
private _newVersion = semverInc(this.active.latest.version, 'patch');
|
||||
|
||||
async getDescription() {
|
||||
override async getDescription() {
|
||||
const {branchName} = this.active.latest;
|
||||
const newVersion = this._newVersion;
|
||||
return `Cut a new patch release for the "${branchName}" branch (v${newVersion}).`;
|
||||
}
|
||||
|
||||
async perform() {
|
||||
override async perform() {
|
||||
const {branchName} = this.active.latest;
|
||||
const newVersion = this._newVersion;
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@ export class CutNextPrereleaseAction extends ReleaseAction {
|
||||
/** Promise resolving with the new version if a NPM next pre-release is cut. */
|
||||
private _newVersion: Promise<semver.SemVer> = this._computeNewVersion();
|
||||
|
||||
async getDescription() {
|
||||
override async getDescription() {
|
||||
const {branchName} = this._getActivePrereleaseTrain();
|
||||
const newVersion = await this._newVersion;
|
||||
return `Cut a new next pre-release for the "${branchName}" branch (v${newVersion}).`;
|
||||
}
|
||||
|
||||
async perform() {
|
||||
override async perform() {
|
||||
const releaseTrain = this._getActivePrereleaseTrain();
|
||||
const {branchName} = releaseTrain;
|
||||
const newVersion = await this._newVersion;
|
||||
|
||||
@@ -17,12 +17,12 @@ import {ReleaseAction} from '../actions';
|
||||
export class CutReleaseCandidateAction extends ReleaseAction {
|
||||
private _newVersion = semverInc(this.active.releaseCandidate!.version, 'prerelease', 'rc');
|
||||
|
||||
async getDescription() {
|
||||
override async getDescription() {
|
||||
const newVersion = this._newVersion;
|
||||
return `Cut a first release-candidate for the feature-freeze branch (v${newVersion}).`;
|
||||
}
|
||||
|
||||
async perform() {
|
||||
override async perform() {
|
||||
const {branchName} = this.active.releaseCandidate!;
|
||||
const newVersion = this._newVersion;
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ import {invokeSetNpmDistCommand, invokeYarnInstallCommand} from '../external-com
|
||||
export class CutStableAction extends ReleaseAction {
|
||||
private _newVersion = this._computeNewVersion();
|
||||
|
||||
async getDescription() {
|
||||
override async getDescription() {
|
||||
const newVersion = this._newVersion;
|
||||
return `Cut a stable release for the release-candidate branch (v${newVersion}).`;
|
||||
}
|
||||
|
||||
async perform() {
|
||||
override async perform() {
|
||||
const {branchName} = this.active.releaseCandidate!;
|
||||
const newVersion = this._newVersion;
|
||||
const isNewMajor = this.active.releaseCandidate?.isMajor;
|
||||
|
||||
@@ -24,13 +24,13 @@ import {changelogPath, packageJsonPath} from '../constants';
|
||||
export class MoveNextIntoFeatureFreezeAction extends ReleaseAction {
|
||||
private _newVersion = computeNewPrereleaseVersionForNext(this.active, this.config);
|
||||
|
||||
async getDescription() {
|
||||
override async getDescription() {
|
||||
const {branchName} = this.active.next;
|
||||
const newVersion = await this._newVersion;
|
||||
return `Move the "${branchName}" branch into feature-freeze phase (v${newVersion}).`;
|
||||
}
|
||||
|
||||
async perform() {
|
||||
override async perform() {
|
||||
const newVersion = await this._newVersion;
|
||||
const newBranch = `${newVersion.major}.${newVersion.minor}.x`;
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ import {invokeSetNpmDistCommand, invokeYarnInstallCommand} from '../external-com
|
||||
* @see {CutStableAction#perform} for more details.
|
||||
*/
|
||||
export class TagRecentMajorAsLatest extends ReleaseAction {
|
||||
async getDescription() {
|
||||
override async getDescription() {
|
||||
return `Tag recently published major v${this.active.latest.version} as "next" in NPM.`;
|
||||
}
|
||||
|
||||
async perform() {
|
||||
override async perform() {
|
||||
await this.checkoutUpstreamBranch(this.active.latest.branchName);
|
||||
await invokeYarnInstallCommand(this.projectDir);
|
||||
await invokeSetNpmDistCommand('latest', this.active.latest.version);
|
||||
|
||||
@@ -143,11 +143,11 @@ describe('common release action logic', () => {
|
||||
* release action class. This allows us to add unit tests.
|
||||
*/
|
||||
class TestAction extends ReleaseAction {
|
||||
async getDescription() {
|
||||
override async getDescription() {
|
||||
return 'Test action';
|
||||
}
|
||||
|
||||
async perform() {
|
||||
override async perform() {
|
||||
throw Error('Not implemented.');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user