From 21f6f58cbe94c6252951f223eae7363d30a89e70 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Wed, 22 Jan 2020 13:21:22 +0800 Subject: [PATCH] ESLint: enable all TS rules that require running compiler --- .eslintrc.yml | 38 +++++++++++++++++++++----------------- src/tsconfig.json | 3 +-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 20772a46bf..ea679a5859 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -424,6 +424,9 @@ rules: overrides: - files: '**/*.ts' parser: '@typescript-eslint/parser' + parserOptions: + tsconfigRootDir: './src/' + project: ['tsconfig.json'] plugins: - '@typescript-eslint' rules: @@ -447,7 +450,7 @@ overrides: # https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules '@typescript-eslint/adjacent-overload-signatures': error '@typescript-eslint/array-type': [error, { default: generic }] - '@typescript-eslint/await-thenable': off # TODO error + '@typescript-eslint/await-thenable': error '@typescript-eslint/ban-ts-ignore': error '@typescript-eslint/ban-types': error '@typescript-eslint/consistent-type-assertions': @@ -462,39 +465,40 @@ overrides: '@typescript-eslint/no-explicit-any': off # TODO error '@typescript-eslint/no-extra-non-null-assertion': error '@typescript-eslint/no-extraneous-class': off # TODO consider - '@typescript-eslint/no-floating-promises': off # TODO error + '@typescript-eslint/no-floating-promises': error '@typescript-eslint/no-for-in-array': error - '@typescript-eslint/no-implied-eval': off # TODO error + '@typescript-eslint/no-implied-eval': error '@typescript-eslint/no-inferrable-types': [error, { ignoreParameters: true, ignoreProperties: true }] '@typescript-eslint/no-misused-new': error - '@typescript-eslint/no-misused-promises': off # TODO error + '@typescript-eslint/no-misused-promises': error '@typescript-eslint/no-namespace': error - '@typescript-eslint/no-non-null-assertion': off # TODO error + '@typescript-eslint/no-non-null-assertion': error '@typescript-eslint/no-parameter-properties': error '@typescript-eslint/no-require-imports': error '@typescript-eslint/no-this-alias': error - '@typescript-eslint/no-throw-literal': off # TODO error + '@typescript-eslint/no-throw-literal': error '@typescript-eslint/no-type-alias': off # TODO consider - '@typescript-eslint/no-unnecessary-condition': off # TODO error - '@typescript-eslint/no-unnecessary-qualifier': off # TODO error + '@typescript-eslint/no-unnecessary-condition': error + '@typescript-eslint/no-unnecessary-qualifier': error '@typescript-eslint/no-unnecessary-type-arguments': off # TODO error - '@typescript-eslint/no-unnecessary-type-assertion': off # TODO error + '@typescript-eslint/no-unnecessary-type-assertion': error '@typescript-eslint/no-unused-vars-experimental': off '@typescript-eslint/no-var-requires': error '@typescript-eslint/prefer-for-of': off # TODO switch to error after TS migration '@typescript-eslint/prefer-function-type': error '@typescript-eslint/prefer-includes': off # TODO switch to error after IE11 drop '@typescript-eslint/prefer-namespace-keyword': error - '@typescript-eslint/prefer-nullish-coalescing': off # TODO error + '@typescript-eslint/prefer-nullish-coalescing': error '@typescript-eslint/prefer-optional-chain': error - '@typescript-eslint/prefer-readonly': off # TODO error - '@typescript-eslint/prefer-regexp-exec': off # TODO error + '@typescript-eslint/prefer-readonly': error + '@typescript-eslint/prefer-regexp-exec': error '@typescript-eslint/prefer-string-starts-ends-with': off # TODO switch to error after IE11 drop '@typescript-eslint/promise-function-async': off - '@typescript-eslint/require-array-sort-compare': off # TODO error - '@typescript-eslint/restrict-plus-operands': off # TODO [error, { checkCompoundAssignments: true }] - '@typescript-eslint/restrict-template-expressions': off # TODO error + '@typescript-eslint/require-array-sort-compare': error + '@typescript-eslint/restrict-plus-operands': + [error, { checkCompoundAssignments: true }] + '@typescript-eslint/restrict-template-expressions': error '@typescript-eslint/strict-boolean-expressions': off # TODO consider '@typescript-eslint/triple-slash-reference': error '@typescript-eslint/typedef': off @@ -520,8 +524,8 @@ overrides: '@typescript-eslint/no-unused-vars': [error, { vars: all, args: all, argsIgnorePattern: '^_' }] '@typescript-eslint/no-useless-constructor': error - '@typescript-eslint/require-await': off # TODO - '@typescript-eslint/return-await': off # TODO + '@typescript-eslint/require-await': error + '@typescript-eslint/return-await': error # Disable for JS, Flow and TS '@typescript-eslint/no-magic-numbers': off diff --git a/src/tsconfig.json b/src/tsconfig.json index 07994c2495..422f48c77c 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -11,6 +11,5 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true - }, - "files": ["index.d.ts"] + } }