From 60d2ad1b3990ead90aacee36064b9b3fd879b1c2 Mon Sep 17 00:00:00 2001 From: Yannick Croissant Date: Mon, 1 Jun 2020 13:49:17 +0200 Subject: [PATCH] feat(typescript): add support for @typescript-eslint/eslint-plugin 3.x (#125) --- base.js | 2 +- rules/base.js | 3 +++ rules/typescript.js | 33 +++++++++++++++++++++++---------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/base.js b/base.js index bc1cfe1f..d570c7ef 100644 --- a/base.js +++ b/base.js @@ -22,6 +22,6 @@ module.exports = { ], plugins: ['eslint-comments', 'import', 'prettier'], settings: { - 'import/extensions': ['.js'], + 'import/extensions': ['.js', '.jsx', '.ts', '.tsx'], }, }; diff --git a/rules/base.js b/rules/base.js index 8f1ff09b..5366f383 100644 --- a/rules/base.js +++ b/rules/base.js @@ -277,6 +277,9 @@ module.exports = { 'ignorePackages', { js: 'never', + jsx: 'never', + ts: 'never', + tsx: 'never', }, ], diff --git a/rules/typescript.js b/rules/typescript.js index 5a8e1ce7..80ad9f09 100644 --- a/rules/typescript.js +++ b/rules/typescript.js @@ -5,9 +5,28 @@ module.exports = { '@typescript-eslint/adjacent-overload-signatures': ['error'], '@typescript-eslint/array-type': ['error', { default: 'array-simple' }], '@typescript-eslint/ban-types': ['error'], - '@typescript-eslint/ban-ts-ignore': ['off'], - '@typescript-eslint/camelcase': ['error'], - '@typescript-eslint/class-name-casing': ['error'], + '@typescript-eslint/ban-ts-comment': ['off'], + '@typescript-eslint/naming-convention': [ + 'error', + { + selector: 'variable', + format: ['camelCase', 'PascalCase', 'UPPER_CASE'], + leadingUnderscore: 'allow', + }, + { + selector: 'typeParameter', + format: ['PascalCase'], + prefix: ['T', 'K'], + }, + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '^I[A-Z]', + match: false, + }, + }, + ], '@typescript-eslint/consistent-type-assertions': [ 'error', { @@ -17,14 +36,8 @@ module.exports = { ], '@typescript-eslint/explicit-function-return-type': ['off'], '@typescript-eslint/explicit-member-accessibility': ['error'], - '@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'], - '@typescript-eslint/member-naming': ['off'], '@typescript-eslint/member-ordering': [ 'error', { @@ -59,7 +72,7 @@ module.exports = { '@typescript-eslint/no-var-requires': ['off'], '@typescript-eslint/prefer-for-of': ['off'], '@typescript-eslint/prefer-function-type': ['error'], - '@typescript-eslint/prefer-interface': ['off'], + '@typescript-eslint/consistent-type-definitions': ['off'], '@typescript-eslint/prefer-namespace-keyword': ['error'], '@typescript-eslint/promise-function-async': ['off'], '@typescript-eslint/restrict-plus-operands': ['off'],