Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 04b9bfd

Browse files
CaerusKaruThomasBurleson
authored andcommitted
build: enforce that deprecated APIs have a deletion target
* Equivalent commit to angular/components#9931
1 parent ba38451 commit 04b9bfd

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

tools/tslint-rules/deletionTargetRule.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ export class Rule extends Lint.Rules.AbstractRule {
1414
return this.applyWithFunction(sourceFile, (ctx: Lint.WalkContext<any>) => {
1515
utils.forEachComment(ctx.sourceFile, (file, {pos, end}) => {
1616
const commentText = file.substring(pos, end);
17-
18-
if (commentText.indexOf('@deletion-target') === -1) {
19-
return;
20-
}
21-
22-
const version = commentText.match(/\d+\.\d+\.\d+/);
23-
24-
if (!version) {
25-
ctx.addFailure(pos, end, '@deletion-target must have a version.');
26-
} else if (this._hasExpired(packageVersion, version[0])) {
27-
ctx.addFailure(pos, end, `Deletion target at ${version[0]} is due to be deleted. ` +
28-
`Current version is ${packageVersion}.`);
17+
const hasDeletionTarget = commentText.indexOf('@deletion-target') > -1;
18+
19+
if (!hasDeletionTarget && commentText.indexOf('@deprecated') > -1) {
20+
ctx.addFailure(pos, end, '@deprecated marker has to have a @deletion-target.');
21+
} if (hasDeletionTarget) {
22+
const version = commentText.match(/\d+\.\d+\.\d+/);
23+
24+
if (!version) {
25+
ctx.addFailure(pos, end, '@deletion-target must have a version.');
26+
} else if (this._hasExpired(packageVersion, version[0])) {
27+
ctx.addFailure(pos, end, `Deletion target at ${version[0]} is due to be deleted. ` +
28+
`Current version is ${packageVersion}.`);
29+
}
2930
}
3031
});
3132
});

0 commit comments

Comments
 (0)