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

build: enforce that deprecated APIs have a deletion target #614

Merged
merged 1 commit into from
Feb 17, 2018
Merged
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
25 changes: 13 additions & 12 deletions tools/tslint-rules/deletionTargetRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ export class Rule extends Lint.Rules.AbstractRule {
return this.applyWithFunction(sourceFile, (ctx: Lint.WalkContext<any>) => {
utils.forEachComment(ctx.sourceFile, (file, {pos, end}) => {
const commentText = file.substring(pos, end);

if (commentText.indexOf('@deletion-target') === -1) {
return;
}

const version = commentText.match(/\d+\.\d+\.\d+/);

if (!version) {
ctx.addFailure(pos, end, '@deletion-target must have a version.');
} else if (this._hasExpired(packageVersion, version[0])) {
ctx.addFailure(pos, end, `Deletion target at ${version[0]} is due to be deleted. ` +
`Current version is ${packageVersion}.`);
const hasDeletionTarget = commentText.indexOf('@deletion-target') > -1;

if (!hasDeletionTarget && commentText.indexOf('@deprecated') > -1) {
ctx.addFailure(pos, end, '@deprecated marker has to have a @deletion-target.');
} if (hasDeletionTarget) {
const version = commentText.match(/\d+\.\d+\.\d+/);

if (!version) {
ctx.addFailure(pos, end, '@deletion-target must have a version.');
} else if (this._hasExpired(packageVersion, version[0])) {
ctx.addFailure(pos, end, `Deletion target at ${version[0]} is due to be deleted. ` +
`Current version is ${packageVersion}.`);
}
}
});
});
Expand Down