Enabling Eslint in typescript files

In the webstorm eslint configuration, there is a field called "Additional eslint parameters". In this I added:

--ext .ts 

from the eslint documentation , which should allow eslint to work with a custom file extension, in this case .ts files. It does nothing. Is my syntax wrong? In any case, to include Eslint in .ts files, possibly from a .eslintrc file?

+5
source share
1 answer

--ext allows you to use custom javascript extensions, you cannot force ESLint to work in languages ​​other than JavaScript, passing it another extension.

You can use typescript-eslint-parser to enable ESLint for Typescript - it allows you to build a syntax tree from Typescript code that can be passed to ESLint for casting.

But I would suggest using Typescript linters to test Typescript code. For example, you can try TSLint .

Update : from 2017.1.3 WebStorm supports ESLint + typescript -eslint-parser; you just need to install the typescript plugin and typescript-eslint-parser and modify the ESLint configuration accordingly:

 "parser": "typescript-eslint-parser", "plugins": ["typescript"] 
+8
source

All Articles