Skip to content

Linting TypeScript

When I started using TypeScript some time ago I identified one thing that I am missing from the vanilla JavaScript territory — linting. Having Prettier take care of stylistic aspects of my codebase and ESLint catching potential errors — that’s the way how I tend to live my life. Despite the fact that ESLint can help me with formatting flaws I much prefer using Prettier for it. I consider its restricted configuration options and opinionated rules to be its best features. Support for TypeScript comes out of the box — formatting sorted. To detect potential errors we have a few options in TypeScript ecosystem.

You may be wondering why I made one of the poll options “Don’t lint at all”. Since I started learning TypeScript I was relying on the fantastic code analysis tools that Visual Studio Code has built-in. I kept relying on it until I wanted to add linting as a required step of my build process. The majority of TypeScript developers that I managed to reach prefer using TSLint over ESLint. The recently published TypeScript Roadmap for January - June 2019 may change this superiority in the near future.

TypeScript <3 ESLint

After the TypeScript core team shared their plan to invest in ESLint integration, “The future of TypeScript on ESLint” has been published and the typescript-eslint monorepo released. It contains the whole set of tooling which enables ESLint to support TypeScript.

Once again, we are very excited to welcome the TypeScript community into the ESLint community and look forward to seeing how James and the typescript-eslint team make ESLint the best choice for linting TypeScript code.

Looking for a quick copy / paste .eslintrc.js config file for lazy people? I’ve got your back :-*

yarn add -D eslint @typescript-eslint/parser prettier eslint-plugin-prettier eslint-config-prettier
module.exports = {
  parser: "@typescript-eslint/parser",
  extends: ["eslint:recommended", "plugin:prettier/recommended"]
};
comments powered by Disqus