Skip to content

Commit

Permalink
Show rule deprecation warning only once (palantir#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
IllusionMH authored and nchen63 committed Oct 30, 2016
1 parent 255a657 commit 591d39f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ruleLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {IDisabledInterval, IRule} from "./language/rule/rule";

const moduleDirectory = path.dirname(module.filename);
const CORE_RULES_DIRECTORY = path.resolve(moduleDirectory, ".", "rules");
const shownDeprecations: string[] = [];

export interface IEnableDisablePosition {
isEnabled: boolean;
Expand All @@ -49,8 +50,9 @@ export function loadRules(ruleConfiguration: {[name: string]: any},
const disabledIntervals = buildDisabledIntervalsFromSwitches(ruleSpecificList, allList);
rules.push(new Rule(ruleName, ruleValue, disabledIntervals));

if (Rule.metadata && Rule.metadata.deprecationMessage) {
if (Rule.metadata && Rule.metadata.deprecationMessage && shownDeprecations.indexOf(Rule.metadata.ruleName) === -1) {
console.warn(`${Rule.metadata.ruleName} is deprecated. ${Rule.metadata.deprecationMessage}`);
shownDeprecations.push(Rule.metadata.ruleName);
}
}
}
Expand Down

0 comments on commit 591d39f

Please sign in to comment.