From 02c4c9fa7a6897400daba1dc3d935f0ee1c05308 Mon Sep 17 00:00:00 2001 From: rrogowski Date: Tue, 11 Dec 2018 12:55:41 -0500 Subject: [PATCH 01/60] Fix callable-types should handle `new(): T` just like `(): T` (#4352) * callable-types handle new(): T * make FormatterConstructor comply with new callable-types rule bugfix * fix lint * avoid code duplication * lint and test fixes * ignore callable-types instead of trying to fix * edit comment * link to issue --- src/language/formatter/formatter.ts | 5 +++++ src/rules/callableTypesRule.ts | 5 +++-- test/rules/callable-types/test.ts.fix | 4 +++- test/rules/callable-types/test.ts.lint | 9 +++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/language/formatter/formatter.ts b/src/language/formatter/formatter.ts index 24a0fde1ddf..a13a92cd2fa 100644 --- a/src/language/formatter/formatter.ts +++ b/src/language/formatter/formatter.ts @@ -46,7 +46,12 @@ export interface IFormatterMetadata { export type ConsumerType = "human" | "machine"; +// See https://github.com/palantir/tslint/issues/4364 +// TODO: Enable the `callable-types` rule below. Currently, it +// produces a lint error in several locations complaining about the +// `no-inferred-empty-object-type` rule. export interface FormatterConstructor { + // tslint:disable-next-line:callable-types new (): IFormatter; } diff --git a/src/rules/callableTypesRule.ts b/src/rules/callableTypesRule.ts index 152df3340b1..e24f5aab1c3 100644 --- a/src/rules/callableTypesRule.ts +++ b/src/rules/callableTypesRule.ts @@ -18,6 +18,7 @@ import { getChildOfKind, isCallSignatureDeclaration, + isConstructSignatureDeclaration, isIdentifier, isInterfaceDeclaration, isTypeLiteralNode, @@ -58,7 +59,7 @@ function walk(ctx: Lint.WalkContext) { ) { const member = node.members[0]; if ( - isCallSignatureDeclaration(member) && + (isConstructSignatureDeclaration(member) || isCallSignatureDeclaration(member)) && // avoid bad parse member.type !== undefined ) { @@ -96,7 +97,7 @@ function noSupertype(node: ts.InterfaceDeclaration): boolean { } function renderSuggestion( - call: ts.CallSignatureDeclaration, + call: ts.CallSignatureDeclaration | ts.ConstructSignatureDeclaration, parent: ts.InterfaceDeclaration | ts.TypeLiteralNode, sourceFile: ts.SourceFile, ): string { diff --git a/test/rules/callable-types/test.ts.fix b/test/rules/callable-types/test.ts.fix index e82feeb5cf7..350ce4ca699 100644 --- a/test/rules/callable-types/test.ts.fix +++ b/test/rules/callable-types/test.ts.fix @@ -26,7 +26,9 @@ interface K { } // handle modifiers -export type I = () => void; +export type I0 = () => void; + +export type I1 = new () => void; export type T = () => void diff --git a/test/rules/callable-types/test.ts.lint b/test/rules/callable-types/test.ts.lint index 7f9c3719aa8..fc36bcb058f 100644 --- a/test/rules/callable-types/test.ts.lint +++ b/test/rules/callable-types/test.ts.lint @@ -54,9 +54,14 @@ interface K { } // handle modifiers -export interface I { +export interface I0 { (): void; - ~~~~~~~~~ [interface % ('type I = () => void;')] + ~~~~~~~~~ [interface % ('type I0 = () => void;')] +} + +export interface I1 { + new (): void; + ~~~~~~~~~~~~~ [interface % ('type I1 = new () => void;')] } export type T = { From 6b0af8fabb4bc98338d8912a693f5f851812dfff Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Tue, 11 Dec 2018 17:13:23 -0500 Subject: [PATCH 02/60] Use 2018 for copyright (#4367) --- docs/_includes/footer.html | 2 +- scripts/buildDocs.ts | 2 +- src/configs/latest.ts | 2 +- src/configs/recommended.ts | 2 +- src/error.ts | 2 +- src/formatters/checkstyleFormatter.ts | 2 +- src/formatters/junitFormatter.ts | 2 +- src/formatters/msbuildFormatter.ts | 2 +- src/formatters/vsoFormatter.ts | 2 +- src/language/rule/typedRule.ts | 2 +- src/language/walker/programAwareRuleWalker.ts | 2 +- src/rules/arrayTypeRule.ts | 2 +- src/rules/arrowParensRule.ts | 2 +- src/rules/cyclomaticComplexityRule.ts | 2 +- src/rules/deprecationRule.ts | 2 +- src/rules/fileHeaderRule.ts | 2 +- src/rules/importBlacklistRule.ts | 2 +- src/rules/linebreakStyleRule.ts | 2 +- src/rules/maxClassesPerFileRule.ts | 2 +- src/rules/newParensRule.ts | 2 +- src/rules/noAngleBracketTypeAssertionRule.ts | 2 +- src/rules/noDefaultExportRule.ts | 2 +- src/rules/noFloatingPromisesRule.ts | 2 +- src/rules/noForInArrayRule.ts | 2 +- src/rules/noInferredEmptyObjectTypeRule.ts | 2 +- src/rules/noInvalidThisRule.ts | 2 +- src/rules/noMagicNumbersRule.ts | 2 +- src/rules/noMergeableNamespaceRule.ts | 2 +- src/rules/noNamespaceRule.ts | 2 +- src/rules/noReferenceRule.ts | 2 +- src/rules/noStringThrowRule.ts | 2 +- src/rules/noUnnecessaryTypeAssertionRule.ts | 2 +- src/rules/noUnsafeFinallyRule.ts | 2 +- src/rules/noVoidExpressionRule.ts | 2 +- src/rules/objectLiteralKeyQuotesRule.ts | 2 +- src/rules/objectLiteralShorthandRule.ts | 2 +- src/rules/oneVariablePerDeclarationRule.ts | 2 +- src/rules/orderedImportsRule.ts | 2 +- src/rules/preferForOfRule.ts | 2 +- src/rules/promiseFunctionAsyncRule.ts | 2 +- src/rules/restrictPlusOperandsRule.ts | 2 +- src/rules/spaceBeforeFunctionParenRule.ts | 2 +- src/rules/strictBooleanExpressionsRule.ts | 2 +- src/test.ts | 2 +- src/utils.ts | 2 +- src/verify/lines.ts | 2 +- src/verify/lintError.ts | 2 +- src/verify/parse.ts | 2 +- test/configurationTests.ts | 2 +- test/executable/executableTests.ts | 2 +- test/formatters/checkstyleFormatterTests.ts | 2 +- test/formatters/junitFormatterTests.ts | 2 +- test/rule-tester/linesTests.ts | 2 +- test/rule-tester/parseTests.ts | 2 +- test/rule-tester/testData.ts | 2 +- test/ruleTestRunner.ts | 2 +- test/utilsTests.ts | 2 +- 57 files changed, 57 insertions(+), 57 deletions(-) diff --git a/docs/_includes/footer.html b/docs/_includes/footer.html index 5f8dfce81df..e5e2121c862 100644 --- a/docs/_includes/footer.html +++ b/docs/_includes/footer.html @@ -2,7 +2,7 @@