From 9aee06cf4c47e38b5959d45f28bad6499b605352 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Fri, 15 Nov 2019 19:26:00 +0200 Subject: [PATCH] fix(eslint-plugin): [indent] handle empty generic declarations (#1211) Co-authored-by: Brad Zacher --- packages/eslint-plugin/src/rules/indent.ts | 4 ++++ packages/eslint-plugin/tests/rules/indent/indent.test.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/packages/eslint-plugin/src/rules/indent.ts b/packages/eslint-plugin/src/rules/indent.ts index 571767d5e00..46ac924f4c7 100644 --- a/packages/eslint-plugin/src/rules/indent.ts +++ b/packages/eslint-plugin/src/rules/indent.ts @@ -444,6 +444,10 @@ export default util.createRule({ }, TSTypeParameterDeclaration(node: TSESTree.TSTypeParameterDeclaration) { + if (!node.params.length) { + return; + } + const [name, ...attributes] = node.params; // JSX is about the closest we can get because the angle brackets diff --git a/packages/eslint-plugin/tests/rules/indent/indent.test.ts b/packages/eslint-plugin/tests/rules/indent/indent.test.ts index f49be833005..fca5629655b 100644 --- a/packages/eslint-plugin/tests/rules/indent/indent.test.ts +++ b/packages/eslint-plugin/tests/rules/indent/indent.test.ts @@ -770,6 +770,11 @@ const div: JQuery = $('
') }, // https://github.com/typescript-eslint/typescript-eslint/issues/441 `const;`, + + // https://github.com/typescript-eslint/typescript-eslint/issues/1115 + { + code: `const foo = function<> (): void {}`, + }, ], invalid: [ ...individualNodeTests.invalid,