From cbdcfb5b7e82eacb4d3c97e06e678d1169684030 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 16 Nov 2017 08:46:00 +0100 Subject: [PATCH] no-any: remove fixer, amend error message (#3486) --- src/rules/noAnyRule.ts | 6 ++---- test/rules/no-any/test.ts.fix | 11 ----------- test/rules/no-any/test.ts.lint | 2 +- 3 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 test/rules/no-any/test.ts.fix diff --git a/src/rules/noAnyRule.ts b/src/rules/noAnyRule.ts index 476f75ad21c..75a48aef6c4 100644 --- a/src/rules/noAnyRule.ts +++ b/src/rules/noAnyRule.ts @@ -34,9 +34,7 @@ export class Rule extends Lint.Rules.AbstractRule { }; /* tslint:enable:object-literal-sort-keys */ - public static FAILURE_STRING = "Type declaration of 'any' loses type-safety. " + - "Consider replacing it with a more precise type, the empty type ('{}'), " + - "or suppress this occurrence."; + public static FAILURE_STRING = "Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type."; public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { return this.applyWithFunction(sourceFile, walk); @@ -47,7 +45,7 @@ function walk(ctx: Lint.WalkContext) { return ts.forEachChild(ctx.sourceFile, function cb(node: ts.Node): void { if (node.kind === ts.SyntaxKind.AnyKeyword) { const start = node.end - 3; - return ctx.addFailure(start, node.end, Rule.FAILURE_STRING, new Lint.Replacement(start, 3, "{}")); + return ctx.addFailure(start, node.end, Rule.FAILURE_STRING); } return ts.forEachChild(node, cb); }); diff --git a/test/rules/no-any/test.ts.fix b/test/rules/no-any/test.ts.fix deleted file mode 100644 index 2e28a65aeca..00000000000 --- a/test/rules/no-any/test.ts.fix +++ /dev/null @@ -1,11 +0,0 @@ -var x: {}; // error - -function foo(a: {}) : {} { // 2 errors - return; -} - -let a: {} = 2, // error - b: {} = 4; // error - -let {a: c, b: d}: {c: {}, d: number} = {c: 99, d: 100}; // error - diff --git a/test/rules/no-any/test.ts.lint b/test/rules/no-any/test.ts.lint index b5b9b9c7c2c..5a1de903ef7 100644 --- a/test/rules/no-any/test.ts.lint +++ b/test/rules/no-any/test.ts.lint @@ -15,4 +15,4 @@ let a: any = 2, // error let {a: c, b: d}: {c: any, d: number} = {c: 99, d: 100}; // error ~~~ [0] -[0]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type, the empty type ('{}'), or suppress this occurrence. +[0]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type.