From 1b0097b277e10300312cf925699eeba5457e0f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Thu, 26 Sep 2019 11:23:06 -0700 Subject: [PATCH] feat(typescript): allow generic names starting with "K" We accept only generic type names starting with "T" but so metimes, accepting "K" also makes sense. This is the case when using the TypeScript keyword `keyof`: ```ts type StateToWidgets = { [KParameter in keyof IndexUiState]: Array; }; ``` See https://www.typescriptlang.org/docs/handbook/release-n otes/typescript-2-1.html#example --- rules/typescript.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rules/typescript.js b/rules/typescript.js index 98ba1ecf..5a8e1ce7 100644 --- a/rules/typescript.js +++ b/rules/typescript.js @@ -17,7 +17,10 @@ module.exports = { ], '@typescript-eslint/explicit-function-return-type': ['off'], '@typescript-eslint/explicit-member-accessibility': ['error'], - '@typescript-eslint/generic-type-naming': ['error', '^T[A-Z][a-zA-Z]+$'], + '@typescript-eslint/generic-type-naming': [ + 'error', + '^(T|K)[A-Z][a-zA-Z]+$', + ], '@typescript-eslint/indent': ['off'], '@typescript-eslint/interface-name-prefix': ['error', 'never'], '@typescript-eslint/member-delimiter-style': ['off'],