Skip to content

Latest commit

 

History

History
70 lines (61 loc) · 3.98 KB

migrating-from-tslint.md

File metadata and controls

70 lines (61 loc) · 3.98 KB

Migrating from TSLint

TSLint is now deprecate. This guide is intended to help those who are using tslint-immutable to migrate their settings and projects to use eslint-plugin-functional.

Configuration File

The ESLint version of tslint.json (the configuration file) is .eslintrc. See ESLint's docs for more information on this file.

Out of the box, ESLint does not understand TypeScript. To get ESLint to understand it we need to change the default parser to one that understands it. This is where @typescript-eslint comes in. In the config file, we can specify the parser to be used with the "parser" key. Any extra parser configuration can then be specified under the "parserOptions" key. In order for the parser to have access to type information, it needs access to your tsconfig.json; you'll need to specify this under "parserOptions" -> "project".

Example config

{
  "root": true,
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 10,
    "project": "./tsconfig.json",
    "sourceType": "module"
  },
  "plugins": [
    "functional"
  ],
  "env": {
    "es6": true
  },
  "extends": [
    "plugin:functional/recommended"
  ],
  "rules": {
    // These rules will be applied to all linted file.
  },
  "overrides": [
    {
      "files": ["*.ts", "*.tsx"],
      "rules": {
        // These rules will only be applied to ts file.
      }
    }
  ]
}

Rules

Below is a table mapping the eslint-plugin-functional rules to their tslint-immutable equivalents.

eslint-plugin-functional Rule Equivalent tslint-immutable Rules
functional/prefer-readonly-type readonly-keyword & readonly-array
functional/no-let no-let
functional/immutable-data no-object-mutation, no-array-mutation & no-delete
functional/no-method-signature no-method-signature
functional/no-this-expression no-this
functional/no-class no-class
functional/no-mixed-type no-mixed-interface
functional/no-expression-statement no-expression-statement
functional/no-conditional-statement no-if-statement
functional/no-loop-statement no-loop-statement
functional/no-return-void -
functional/no-throw-statement no-throw
functional/no-try-statement no-try
functional/no-promise-reject no-reject
functional/functional-parameters -