Skip to main content

ESLint with Typescript

ยท One min read

ESLint can be used alongside Typescript to enforce coding standards.

With Typescriptโ€‹

To use ESLint in a Typescript project:

npm i -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin

Paste the following configuration in a .eslintrc.js file:

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
}

You can also add a .eslintignore file:

node_modules
dist
build
coverage

For further configuration (Prettier, Airbnb, Standard JS, plugins) see the typescript-eslint repo.