---
extends:
  - tslint:latest
  - tslint-eslint-rules
  - tslint-consistent-codestyle
  - tslint-no-unused-expression-chai
  - tslint-sonarts
  - tslint-strict-error-throw

rules:

  # --------------------------------------
  # Rules from tslint-consistent-codestyle
  # --------------------------------------
  naming-convention:
    severity: warning       # change to error later
    options:
      - type: default
        format: strictCamelCase
        leadingUnderscore: forbid
        trailingUnderscore: forbid
      - type: variable
        modifiers:
          - const
        format:
          - strictCamelCase
          - UPPER_CASE
      - type: functionVariable
        modifiers:
          - const
        format: strictCamelCase
      - type: parameter
        modifiers: unused
        leadingUnderscore: allow
      - type: method
        filter: "^toJSON$"
        format:
      - type: property
        modifiers:
          - public
          - static
          - const
        format: UPPER_CASE
      - type: member
        leadingUnderscore: allow
      - type: type
        format: StrictPascalCase
      - type: enumMember
        format:
          - StrictPascalCase
          - UPPER_CASE
  no-collapsible-if: true
  no-static-this: true
  no-unused: true
  no-var-before-return: true
  prefer-const-enum: true
  prefer-while: true

  # --------------------------------------
  # TSLint rules
  # --------------------------------------
  arrow-return-shorthand: true
  await-promise:
    options:
      - Bluebird
      - PromiseLike
  ban:
    severity: warning
    options:
      - name:
          - chai
          - assert
        message: Use 'expect' rather then 'assert'

  cyclomatic-complexity: false    # use cognitive-complexity
  deprecation:
    severity: warning
  interface-name: false
  max-classes-per-file: false
  max-file-line-count:
    options:
      - 500
  member-access: false
  no-angle-bracket-type-assertion: false
  no-floating-promises: true
  no-for-in-array: true
  no-invalid-this: true
  no-irregular-whitespace: true
  no-null-keyword: true
  no-parameter-reassignment:
    severity: warning              # change to error later
  no-require-imports: true
  no-submodule-imports:
    options:
      - lodash
      - "@henson/database"
  no-switch-case-fall-through: true
  no-unnecessary-callback-wrapper: true
  no-unnecessary-class: true
  no-unsafe-any:
    severity: warning               # change to error later
  no-unused-expression: false       # already use no-unused-expression-chai
  no-var-requires: false            # already use no-require-imports
  object-literal-sort-keys: false
  ordered-imports: false
  prefer-const: true
  prefer-readonly: true
  quotemark:
    options:
      - single
  radix: false                      # not common mistake: default 10 is the most common case
  trailing-comma:
    options:
      - multiline:
        - arrays: always
        - objects: always
      - singleline: never
  typedef:
    options:
      - call-signature
  variable-name:
    options:
      - ban-keywords
      - check-format
      - allow-leading-underscore
  whitespace:
    options:
      - check-branch
      - check-decl
      - check-operator
      - check-module
      - check-separator
      - check-rest-spread
      - check-type
      - check-type-operator
      - check-preblock

  # --------------------------------------
  # Rules from tslint-eslint-rules
  # --------------------------------------
  handle-callback-err:
    options:
      - "^(err|error|anySpecificError)$"
  no-control-regex: true
  no-duplicate-case: true
  no-empty-character-class: true
  no-ex-assign: true
  no-extra-boolean-cast: true
  no-extra-semi: false              # not common mistake
  no-implicit-dependencies:
    options:
      - optional
      - dev
  no-inner-declarations:
    options:
      - functions
  no-invalid-regexp: true
  no-regex-spaces: true
  no-unexpected-multiline: true
  ter-no-self-compare: true
  valid-typeof: true

  # Below rules are not implemented in tslint-eslint-rules yet:
  #
  # // "max-depth": [ true, 5 ],
  # // "max-statements": [true, 10, {"ignoreTopLevelFunctions": true}],
  # // "no-path-concat": true,
  # // "no-warning-comments": true,
  # // "prefer-template": true,
  # // "no-param-reassign": [true, {
  # //     "props": false
  # // }],

  # --------------------------------------
  # Rules from tslint-sonarts
  # --------------------------------------
  cognitive-complexity:
    severity: error
    options:
      - 38                             # target: 15
  no-big-function:
    severity: error
    options:
      - 120
  no-commented-code:
    severity: warning                  # Make it warning for easy debugging (temporary disable some lines of code)
  no-duplicate-string: false           # In some cases, string is more readable then constant variable
  no-hardcoded-credentials: false
  no-identical-functions:
    severity: warning
  no-invalid-await: false              # use await-promise
  no-redundant-boolean: false
  no-small-switch: false
  parameters-max-number:
    severity: warning                  # change to error later

  # --------------------------------------
  # Rules from tslint-strict-error-throw
  # --------------------------------------
  strict-error-throw:
    severity: warning                  # change to error later
