Skip to content

Commit

Permalink
Add TypeScript ESLint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrearden committed Jul 8, 2020
1 parent 61883e1 commit 99e063e
Show file tree
Hide file tree
Showing 4 changed files with 5,994 additions and 1 deletion.
144 changes: 144 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,150 @@ rules:
yield-star-spacing: off

overrides:
- files: '**/*.ts'
parser: '@typescript-eslint/parser'
parserOptions:
project: ['tsconfig.json']
plugins:
- '@typescript-eslint'
extends:
- plugin:import/typescript
rules:
flowtype/no-types-missing-file-annotation: off

##########################################################################
# `@typescript-eslint/eslint-plugin` rule list based on `v3.5.x`
##########################################################################

# Supported Rules
# 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': error
'@typescript-eslint/ban-ts-comment': [error, { 'ts-expect-error': false }]
'@typescript-eslint/ban-tslint-comment': error
'@typescript-eslint/ban-types': error
'@typescript-eslint/class-literal-property-style': off
'@typescript-eslint/consistent-type-assertions':
[error, { assertionStyle: as, objectLiteralTypeAssertions: never }]
'@typescript-eslint/consistent-type-definitions': off # TODO consider
'@typescript-eslint/explicit-function-return-type': off # TODO consider
'@typescript-eslint/explicit-member-accessibility': off # TODO consider
'@typescript-eslint/explicit-module-boundary-types': off # TODO consider
'@typescript-eslint/member-ordering': off # TODO consider
'@typescript-eslint/method-signature-style': error
'@typescript-eslint/naming-convention': off # TODO consider
'@typescript-eslint/no-base-to-string': error
'@typescript-eslint/no-confusing-non-null-assertion': error
'@typescript-eslint/no-dynamic-delete': off
'@typescript-eslint/no-empty-interface': error
'@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': error
'@typescript-eslint/no-for-in-array': 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': error
'@typescript-eslint/no-namespace': error
'@typescript-eslint/no-non-null-asserted-optional-chain': error
'@typescript-eslint/no-non-null-assertion': error
'@typescript-eslint/no-parameter-properties': error
'@typescript-eslint/no-invalid-void-type': error
'@typescript-eslint/no-require-imports': error
'@typescript-eslint/no-this-alias': error
'@typescript-eslint/no-throw-literal': error
'@typescript-eslint/no-type-alias': off # TODO consider
'@typescript-eslint/no-unnecessary-boolean-literal-compare': error
'@typescript-eslint/no-unnecessary-condition': error
'@typescript-eslint/no-unnecessary-qualifier': error
'@typescript-eslint/no-unnecessary-type-arguments': error
'@typescript-eslint/no-unnecessary-type-assertion': error
'@typescript-eslint/no-unsafe-assignment': off # TODO consider
'@typescript-eslint/no-unsafe-call': off # TODO consider
'@typescript-eslint/no-unsafe-member-access': off # TODO consider
'@typescript-eslint/no-unsafe-return': off # TODO consider
'@typescript-eslint/no-unused-vars-experimental': off
'@typescript-eslint/no-var-requires': error
'@typescript-eslint/prefer-as-const': off # TODO consider
'@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': error
'@typescript-eslint/prefer-optional-chain': error
'@typescript-eslint/prefer-readonly': error
'@typescript-eslint/prefer-readonly-parameter-types': off # TODO consider
'@typescript-eslint/prefer-reduce-type-parameter': error
'@typescript-eslint/prefer-regexp-exec': error
'@typescript-eslint/prefer-ts-expect-error': 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': 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/switch-exhaustiveness-check': error
'@typescript-eslint/triple-slash-reference': error
'@typescript-eslint/typedef': off
'@typescript-eslint/unbound-method': off # TODO consider
'@typescript-eslint/unified-signatures': error

# Extension Rules
# https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#extension-rules

# Disable conflicting ESLint rules and enable TS-compatible ones
default-param-last: off
dot-notation: off
lines-between-class-members: off
no-array-constructor: off
no-dupe-class-members: off
no-empty-function: off
no-invalid-this: off
no-loss-of-precision: off
no-unused-expressions: off
no-unused-vars: off
no-useless-constructor: off
require-await: off
no-return-await: off
'@typescript-eslint/default-param-last': error
'@typescript-eslint/dot-notation': error
'@typescript-eslint/lines-between-class-members':
[error, always, { exceptAfterSingleLine: true }]
'@typescript-eslint/no-array-constructor': error
'@typescript-eslint/no-dupe-class-members': error
'@typescript-eslint/no-empty-function': error
'@typescript-eslint/no-invalid-this': error
'@typescript-eslint/no-loss-of-precision': error
'@typescript-eslint/no-unused-expressions': error
'@typescript-eslint/no-unused-vars':
[error, { vars: all, args: all, argsIgnorePattern: '^_' }]
'@typescript-eslint/no-useless-constructor': error
'@typescript-eslint/require-await': error
'@typescript-eslint/return-await': error

# Disable for JS, Flow and TS
'@typescript-eslint/init-declarations': off
'@typescript-eslint/no-magic-numbers': off
'@typescript-eslint/no-use-before-define': off

# Bellow rules are disabled because coflicts with Prettier, see:
# https://github.com/prettier/eslint-config-prettier/blob/master/%40typescript-eslint.js
'@typescript-eslint/quotes': off
'@typescript-eslint/brace-style': off
'@typescript-eslint/comma-spacing': off
'@typescript-eslint/func-call-spacing': off
'@typescript-eslint/indent': off
'@typescript-eslint/keyword-spacing': off
'@typescript-eslint/member-delimiter-style': off
'@typescript-eslint/no-extra-parens': off
'@typescript-eslint/no-extra-semi': off
'@typescript-eslint/semi': off
'@typescript-eslint/space-before-function-paren': off
'@typescript-eslint/type-annotation-spacing': off
- files: 'resources/**'
parserOptions:
sourceType: script
Expand Down
Loading

0 comments on commit 99e063e

Please sign in to comment.