DEV Community

Loïc Coenen
Loïc Coenen

Posted on

Migrating from TSLint to ESLint

I knew our codebase had some dirt and I myself had forgotten a lot of unused imports while refactoring. I realize with horrors that we were not using no-unused-import in our linter - TSLint.

I tried to activate it, but it turns out the rule have been deprecated, de-deprecated and re-deprecated. Indeed, the whole tool will be abandonned and everybody is invited to migrate to ESLint, with whom they aim to merge, mimicking Typescript orientation of staying the closest possible to Javascript and its ecosystem.

So far, so good - the multiplication (one could even say invasion) of different tools is a real pain for any javascript developer. Whatever your stack is, you probably already try to integrate two tools together, only to realize it was conflicting with another part library you already using. The liquid, "micro-" aspect of Javascript is a pleasure sometime, but can also be a real pain.

So, let's install ESlint and the typescript plugin using using npm install --save-dev eslint typescript-eslint/eslint-plugin

We are using ES6 and prettier, so here's what our .eslintrc looks like:

{
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 2018,
    sourceType: 'module',
  },
  plugins: ['@typescript-eslint'],
  env: {
    browser: true,
    node: true,
        es6: true
  },
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
        'prettier',
        'prettier/@typescript-eslint'
  ],
    rules:  {
        '@typescript-eslint/explicit-function-return-type': 0
    }
}

That's it. Now, you just have to fix the 808 errors that ESLint just spitted at you.

=== See also ===

https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin

Latest comments (0)