DEV Community

Loïc Coenen
Loïc Coenen

Posted on

3 1

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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →