Skip to content

Commit

Permalink
Improve linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 4, 2022
1 parent e782f4f commit 5d06392
Showing 1 changed file with 226 additions and 0 deletions.
226 changes: 226 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,213 @@ overrides:
# - The module itself, in `*.test-d.ts`
n/no-missing-import: 0

## Comments
'@typescript-eslint/ban-ts-comment': 2
'@typescript-eslint/prefer-ts-expect-error': 2
'@typescript-eslint/ban-tslint-comment': 2

## Declarations
# Enforce declaring types of parameters.
# Use type inference otherwise, including for callbacks (arrow functions).
'@typescript-eslint/typedef':
- 2
- parameter: true
propertyDeclaration: true
'@typescript-eslint/no-inferrable-types': 2

## Assignments
'@typescript-eslint/no-dynamic-delete': 2

## Naming
'@typescript-eslint/naming-convention':
- 2
- selector: default
# Variables of classes are titleized
format: [camelCase, PascalCase]
leadingUnderscore: forbid
trailingUnderscore: forbid
- selector: variable
format: [camelCase, PascalCase, UPPER_CASE]
leadingUnderscore: forbid
trailingUnderscore: forbid
- selector: typeLike
format: [PascalCase]
leadingUnderscore: forbid
trailingUnderscore: forbid

# ## Typecasting
'@typescript-eslint/no-base-to-string': 2
# `${...}` is useful in validation error messages where input might be
# unknown or of many different types
'@typescript-eslint/restrict-template-expressions': 0

## Tests
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 2
'@typescript-eslint/no-unnecessary-condition':
- 2
- allowConstantLoopConditions: true
'@typescript-eslint/strict-boolean-expressions': 2
# Application-specific ordering is more relevant than type-specific
'@typescript-eslint/sort-type-constituents': 0
'@typescript-eslint/prefer-nullish-coalescing':
- 2
- ignoreTernaryTests: false
ignoreConditionalTests: false
ignoreMixedLogicalExpressions: false

## Structures
'@typescript-eslint/prefer-for-of': 2
'@typescript-eslint/no-for-in-array': 2

## Switch
'@typescript-eslint/switch-exhaustiveness-check': 2

## Functions
'@typescript-eslint/method-signature-style': 2
'@typescript-eslint/prefer-function-type': 2
# Prefer inferring return types instead
'@typescript-eslint/explicit-function-return-type': 0
'@typescript-eslint/explicit-module-boundary-types': 0
'@typescript-eslint/adjacent-overload-signatures': 2
# Overloading functions is a more readable alternative to generic types
# in some cases
'@typescript-eslint/unified-signatures': 0

## Objects
'@typescript-eslint/consistent-type-definitions': 2
'@typescript-eslint/consistent-indexed-object-style':
- 2
- index-signature
'@typescript-eslint/no-empty-interface': 2
# Application-specific ordering is more relevant than type-specific
'@typescript-eslint/member-ordering': 0
'@typescript-eslint/prefer-optional-chain': 2

## Classes
'@typescript-eslint/unbound-method': 2
'@typescript-eslint/no-this-alias': 2
'@typescript-eslint/prefer-return-this-type': 2
'@typescript-eslint/explicit-member-accessibility':
- 2
- accessibility: no-public
'@typescript-eslint/prefer-readonly': 2
'@typescript-eslint/class-literal-property-style':
- 2
- fields
'@typescript-eslint/parameter-properties': 2
'@typescript-eslint/no-unsafe-declaration-merging': 2
'@typescript-eslint/no-extraneous-class':
- 2
- allowEmpty: true
allowWithDecorator: true
allowConstructorOnly: true
'@typescript-eslint/no-misused-new': 2

## Arrays
'@typescript-eslint/array-type': 2
'@typescript-eslint/prefer-includes': 2
'@typescript-eslint/prefer-reduce-type-parameter': 2
'@typescript-eslint/require-array-sort-compare':
- 2
- ignoreStringArrays: true

## Strings
'@typescript-eslint/restrict-plus-operands': 2
'@typescript-eslint/prefer-string-starts-ends-with': 2

## RegExps
'@typescript-eslint/prefer-regexp-exec': 2

## Async
'@typescript-eslint/await-thenable': 2
'@typescript-eslint/no-misused-promises': 2
'@typescript-eslint/promise-function-async': 2
'@typescript-eslint/no-floating-promises': 2

## Modules
'@typescript-eslint/consistent-type-exports':
- 2
- fixMixedExportsWithInlineTypeSpecifier: true
'@typescript-eslint/consistent-type-imports':
- 2
- fixStyle: inline-type-imports
'@typescript-eslint/no-require-imports': 2
'@typescript-eslint/no-var-requires': 2
'@typescript-eslint/no-useless-empty-export': 2
'@typescript-eslint/triple-slash-reference':
- 2
- lib: never
path: never
types: never

## Forbid
'@typescript-eslint/ban-types':
- 2
- extendDefaults: true
types:
# `{}` is useful as `{ ... } & {}` is reduced to `{ ... }`, unlike
# `{ ... } & object`
'{}': false

## Type declaration
# `type` is useful
'@typescript-eslint/no-type-alias': 0
'@typescript-eslint/no-redundant-type-constituents': 2

## Base types
'@typescript-eslint/no-explicit-any':
- 2
- fixToUnknown: true
'@typescript-eslint/no-unsafe-assignment': 2
'@typescript-eslint/no-unsafe-member-access': 2
'@typescript-eslint/no-unsafe-argument': 2
'@typescript-eslint/no-unsafe-call': 2
'@typescript-eslint/no-unsafe-return': 2

## Undefined/null/void
# `value!` assertions are useful, e.g. when accessing an array element
# that we know is not out-of-bound
'@typescript-eslint/no-non-null-assertion': 0
'@typescript-eslint/non-nullable-type-assertion-style': 2
'@typescript-eslint/no-confusing-non-null-assertion': 2
'@typescript-eslint/no-extra-non-null-assertion': 2
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 2
'@typescript-eslint/no-non-null-asserted-optional-chain': 2
'@typescript-eslint/no-invalid-void-type':
- 2
- allowAsThisParameter: true
'@typescript-eslint/no-confusing-void-expression':
- 2
- ignoreArrowShorthand: true
ignoreVoidOperator: true
'@typescript-eslint/no-meaningless-void-operator': 2

## Enums
'@typescript-eslint/prefer-enum-initializers': 2
'@typescript-eslint/prefer-literal-enum-member': 2
'@typescript-eslint/no-duplicate-enum-values': 2
'@typescript-eslint/no-unnecessary-qualifier': 2

## Readonly
'@typescript-eslint/prefer-as-const': 2
# This rule seems to be buggy and produce false positives
'@typescript-eslint/prefer-readonly-parameter-types': 0

## Generic
'@typescript-eslint/consistent-generic-constructors': 2
'@typescript-eslint/no-unnecessary-type-arguments': 2
'@typescript-eslint/no-unnecessary-type-constraint': 2

## Type assertions
'@typescript-eslint/consistent-type-assertions': 2
'@typescript-eslint/no-unnecessary-type-assertion': 2

## Namespaces
'@typescript-eslint/no-namespace':
- 2
- allowDefinitionFiles: false
'@typescript-eslint/prefer-namespace-keyword': 2

# CommonJS files
- files: ['**/*.{cjs,cts}']
rules:
Expand Down Expand Up @@ -1418,6 +1625,16 @@ overrides:
'@typescript-eslint/no-empty-function': 0
'@typescript-eslint/no-restricted-imports': 0

# Documentation and examples sometimes used unused variables
'@typescript-eslint/no-unused-vars': 0

# Documentation and examples might be using `any`
'@typescript-eslint/no-unsafe-assignment': 0
'@typescript-eslint/no-unsafe-member-access': 0
'@typescript-eslint/no-unsafe-argument': 0
'@typescript-eslint/no-unsafe-call': 0
'@typescript-eslint/no-unsafe-return': 0

# `eslint-config-markdown` does not work with `parserOptions.project`, which
# removes some rules
- files: ['**/*.md/*.ts']
Expand Down Expand Up @@ -1668,6 +1885,15 @@ overrides:
# Often tested as an invalid input
unicorn/no-null: 0

# @ts-expect-error is useful in type tests
'@typescript-eslint/ban-ts-comment':
- 2
- ts-expect-error: 0

# Allow using `expectType<void>(...)`
'@typescript-eslint/no-invalid-void-type': 0
'@typescript-eslint/no-confusing-void-expression': 0

# Files that are sibling to a `*.js` or `*.ts`
- files: ['**/*.{test.{js,cjs,mjs,ts,cts,mts},d.ts,test-d.ts}']
rules:
Expand Down

0 comments on commit 5d06392

Please sign in to comment.