From cc5d609b48886d7c346aac0ef777b1e745e03eec Mon Sep 17 00:00:00 2001 From: Maksim Ivanov Date: Thu, 1 Dec 2022 20:34:49 +0500 Subject: [PATCH] feat(eslint-config-angular): add strict rules as experimental sub-package (#225) --- packages/eslint-config-angular/.npmignore | 2 ++ packages/eslint-config-angular/README.md | 4 +++ .../experimental/index.js | 29 +++++++++++++++++++ .../function-return-type/index.js | 21 ++++++++++++++ packages/eslint-config-angular/package.json | 13 --------- .../eslint-config-angular/recommended/base.js | 3 ++ 6 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 packages/eslint-config-angular/.npmignore create mode 100644 packages/eslint-config-angular/experimental/index.js create mode 100644 packages/eslint-config-angular/function-return-type/index.js diff --git a/packages/eslint-config-angular/.npmignore b/packages/eslint-config-angular/.npmignore new file mode 100644 index 0000000..6ff9e2f --- /dev/null +++ b/packages/eslint-config-angular/.npmignore @@ -0,0 +1,2 @@ +**/test/** +CHANGELOG.md diff --git a/packages/eslint-config-angular/README.md b/packages/eslint-config-angular/README.md index 88d9a5e..6066ae5 100644 --- a/packages/eslint-config-angular/README.md +++ b/packages/eslint-config-angular/README.md @@ -37,6 +37,10 @@ You can also include `optional` configurations, however, you are responsible for '@tinkoff/eslint-config-angular/line-statements', '@tinkoff/eslint-config-angular/member-ordering', '@tinkoff/eslint-config-angular/decorator-position', + '@tinkoff/eslint-config-angular/function-return-type', + + // experimental strict rules + '@tinkoff/eslint-config-angular/experimental', ], } ``` diff --git a/packages/eslint-config-angular/experimental/index.js b/packages/eslint-config-angular/experimental/index.js new file mode 100644 index 0000000..1cceab0 --- /dev/null +++ b/packages/eslint-config-angular/experimental/index.js @@ -0,0 +1,29 @@ +module.exports = { + overrides: [ + { + files: ['*.ts'], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + rules: { + '@typescript-eslint/ban-types': 'error', + '@typescript-eslint/no-base-to-string': 'error', + '@typescript-eslint/no-unnecessary-type-constraint': 'error', + '@typescript-eslint/prefer-includes': 'error', + '@typescript-eslint/no-for-in-array': 'error', + '@typescript-eslint/no-unnecessary-type-assertion': 'error', + '@typescript-eslint/prefer-nullish-coalescing': 'error', + '@typescript-eslint/prefer-optional-chain': 'error', + '@typescript-eslint/no-use-before-define': [ + 'error', + { + functions: false, + classes: false, + variables: true, + enums: true, + typedefs: true, + }, + ], + }, + }, + ], +}; diff --git a/packages/eslint-config-angular/function-return-type/index.js b/packages/eslint-config-angular/function-return-type/index.js new file mode 100644 index 0000000..d603858 --- /dev/null +++ b/packages/eslint-config-angular/function-return-type/index.js @@ -0,0 +1,21 @@ +module.exports = { + overrides: [ + { + files: ['*.ts'], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + rules: { + '@typescript-eslint/explicit-function-return-type': [ + 'error', + { + allowExpressions: true, + allowTypedFunctionExpressions: true, + allowHigherOrderFunctions: true, + allowDirectConstAssertionInArrowFunctions: true, + allowConciseArrowFunctionExpressionsStartingWithVoid: true, + }, + ], + }, + }, + ], +}; diff --git a/packages/eslint-config-angular/package.json b/packages/eslint-config-angular/package.json index 6fcac4b..018f5b5 100644 --- a/packages/eslint-config-angular/package.json +++ b/packages/eslint-config-angular/package.json @@ -8,19 +8,6 @@ "eslintconfig", "eslint-config" ], - "files": [ - "html", - "imports", - "line-statements", - "member-ordering", - "promise", - "file-progress", - "decorator-position", - "recommended", - "rxjs", - "index.js", - "README.md" - ], "scripts": {}, "main": "index.js", "author": { diff --git a/packages/eslint-config-angular/recommended/base.js b/packages/eslint-config-angular/recommended/base.js index ad67eca..42f3671 100644 --- a/packages/eslint-config-angular/recommended/base.js +++ b/packages/eslint-config-angular/recommended/base.js @@ -43,5 +43,8 @@ module.exports = { }, ], eqeqeq: ['error', 'always'], + 'no-useless-concat': 'error', + 'prefer-template': 'error', + curly: ['error', 'all'], }, };