Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit e95cead

Browse files
Josh GoldbergHamletDRC
authored andcommitted
#405, #400 Deprecated duplicate rules
closes #400. closes #405
1 parent 590653f commit e95cead

12 files changed

+82
-11
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Large diffs are not rendered by default.

src/functionNameRule.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ export class Rule extends Lint.Rules.AbstractRule {
3131
commonWeaknessEnumeration: '398, 710'
3232
};
3333

34+
private static isWarningShown: boolean = false;
35+
3436
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
37+
if (Rule.isWarningShown === false) {
38+
console.warn('Warning: function-name rule is deprecated. Replace your usage with the TSLint variable-name rule.');
39+
Rule.isWarningShown = true;
40+
}
3541
return this.applyWithWalker(new FunctionNameRuleWalker(sourceFile, this.getOptions()));
3642
}
3743
}

src/missingJsdocRule.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ export class Rule extends Lint.Rules.AbstractRule {
2626

2727
public static FAILURE_STRING: string = 'File missing JSDoc comment at the top-level: ';
2828

29+
private static isWarningShown: boolean = false;
30+
2931
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
32+
if (Rule.isWarningShown === false) {
33+
console.warn('Warning: missing-jsdoc rule is deprecated. Replace your usage with the TSLint file-header rule.');
34+
Rule.isWarningShown = true;
35+
}
3036
return this.applyWithWalker(new MissingJSDocWalker(sourceFile, this.getOptions()));
3137
}
3238
}

src/noDuplicateCaseRule.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ export class Rule extends Lint.Rules.AbstractRule {
2626

2727
public static FAILURE_STRING: string = 'Duplicate case found in switch statement: ';
2828

29+
private static isWarningShown: boolean = false;
30+
2931
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
32+
if (Rule.isWarningShown === false) {
33+
console.warn('Warning: no-duplicate-case rule is deprecated. ' +
34+
'Replace your usage with the TSLint no-duplicate-switch-case rule.');
35+
Rule.isWarningShown = true;
36+
}
3037
return this.applyWithWalker(new NoDuplicateCaseRuleWalker(sourceFile, this.getOptions()));
3138
}
3239

src/noEmptyInterfacesRule.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ export class Rule extends Lint.Rules.AbstractRule {
2727

2828
public static FAILURE_STRING: string = 'Do not declare empty interfaces: ';
2929

30+
private static isWarningShown: boolean = false;
31+
3032
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
33+
if (Rule.isWarningShown === false) {
34+
console.warn('Warning: no-empty-interfaces rule is deprecated. Replace your usage with the TSLint no-empty-interface rule.');
35+
Rule.isWarningShown = true;
36+
}
3137
return this.applyWithWalker(new NoEmptyInterfacesRuleWalker(sourceFile, this.getOptions()));
3238
}
3339

src/noReservedKeywordsRule.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ export class Rule extends Lint.Rules.AbstractRule {
5050
'from', 'of'
5151
];
5252

53+
private static isWarningShown: boolean = false;
54+
5355
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
56+
if (Rule.isWarningShown === false) {
57+
console.warn('Warning: no-reserved-keywords rule is deprecated. Replace your usage with the TSLint variable-name rule.');
58+
Rule.isWarningShown = true;
59+
}
5460
const walker: Lint.RuleWalker = new BannedTermWalker(
5561
sourceFile,
5662
this.getOptions(),

src/noUnnecessaryFieldInitializationRule.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ export class Rule extends Lint.Rules.AbstractRule {
2828
commonWeaknessEnumeration: '398, 710'
2929
};
3030

31+
private static isWarningShown: boolean = false;
32+
3133
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
34+
if (Rule.isWarningShown === false) {
35+
console.warn('Warning: no-unnecessary-field-initialization rule is deprecated. ' +
36+
'Replace your usage with the TSLint no-unnecessary-initializer rule.');
37+
Rule.isWarningShown = true;
38+
}
3239
return this.applyWithWalker(new UnnecessaryFieldInitializationRuleWalker(sourceFile, this.getOptions()));
3340
}
3441
}

src/preferArrayLiteralRule.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ export class Rule extends Lint.Rules.AbstractRule {
2828
public static GENERICS_FAILURE_STRING: string = 'Replace generic-typed Array with array literal: ';
2929
public static CONSTRUCTOR_FAILURE_STRING: string = 'Replace Array constructor with an array literal: ';
3030

31+
private static isWarningShown: boolean = false;
32+
3133
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
34+
if (Rule.isWarningShown === false) {
35+
console.warn('Warning: prefer-array-literal rule is deprecated. Replace your usage with the TSLint array-type rule.');
36+
Rule.isWarningShown = true;
37+
}
3238
return this.applyWithWalker(new NoGenericArrayWalker(sourceFile, this.getOptions()));
3339
}
3440
}

src/preferTypeCastRule.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ export class Rule extends Lint.Rules.AbstractRule {
2727
commonWeaknessEnumeration: '398, 710'
2828
};
2929

30+
private static isWarningShown: boolean = false;
31+
3032
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
33+
if (Rule.isWarningShown === false) {
34+
console.warn('Warning: prefer-type-cast rule is deprecated. ' +
35+
'Replace your usage with the TSLint no-angle-bracket-type-assertion rule.');
36+
Rule.isWarningShown = true;
37+
}
3138
return this.applyWithWalker(new PreferTypeCastRuleWalker(sourceFile, this.getOptions()));
3239
}
3340
}

src/promiseMustCompleteRule.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ export class Rule extends Lint.Rules.AbstractRule {
2828

2929
public static FAILURE_STRING: string = 'A Promise was found that appears to not have resolve or reject invoked on all code paths';
3030

31+
private static isWarningShown: boolean = false;
32+
3133
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
34+
if (Rule.isWarningShown === false) {
35+
console.warn('Warning: promise-must-complete rule is deprecated. ' +
36+
'Replace your usage with the TSLint no-floating-promises rule.');
37+
Rule.isWarningShown = true;
38+
}
3239
return this.applyWithWalker(new PromiseAnalyzer(sourceFile, this.getOptions()));
3340
}
3441
}

src/reactTsxCurlySpacingRule.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ export class Rule extends Lint.Rules.AbstractRule {
2323
group: 'Whitespace'
2424
};
2525

26+
private static isWarningShown: boolean = false;
27+
2628
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
29+
if (Rule.isWarningShown === false) {
30+
console.warn('Warning: react-tsx-curly-spacing rule is deprecated. ' +
31+
'Replace your usage with the tslint-react jsx-curly-spacing rule.');
32+
Rule.isWarningShown = true;
33+
}
2734
return this.applyWithWalker(new TsxCurlySpacingWalker(sourceFile, this.getOptions()));
2835
}
2936
}

src/validTypeofRule.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ export class Rule extends Lint.Rules.AbstractRule {
2727

2828
public static VALID_TERMS: string[] = [ 'undefined', 'object', 'boolean', 'number', 'string', 'function', 'symbol' ];
2929

30+
private static isWarningShown: boolean = false;
31+
3032
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
33+
if (Rule.isWarningShown === false) {
34+
console.warn('Warning: valid-typeof rule is deprecated. Replace your usage with the TSLint typeof-compare rule.');
35+
Rule.isWarningShown = true;
36+
}
3137
return this.applyWithWalker(new ValidTypeofRuleWalker(sourceFile, this.getOptions()));
3238
}
3339

0 commit comments

Comments
 (0)