Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling Eslint on typescript files

On webstorm eslint setting, there is an "extra eslint options" field. In this, I added:

--ext .ts

from the eslint documentation which is supposed to allow eslint to work on custom file extension, in this case .ts files. This does nothing. Is my syntax wrong ? Anyway to enable Eslint on .ts files, maybe from the .eslintrc file ?

like image 470
Robert Brax Avatar asked Apr 28 '16 09:04

Robert Brax


1 Answers

--ext allows using custom javascript extensions, you can't force ESLint to work for languages other than JavaScript by passing a different file extension to it.

You can try using typescript-eslint-parser to enable ESLint for Typescript - it allows building a syntax tree from typescript code that can be passed to ESLint for linting.

But I'd suggest using Typescript linters for inspecting TypeScript code. You can try TSLint, for example.

Update: since 2017.1.3, WebStorm supports ESLint + typescript-eslint-parser; you just need to install both typescript plugin and typescript-eslint-parser and modify your ESLint config accordingly:

"parser": "typescript-eslint-parser",
"plugins": ["typescript"]
like image 155
lena Avatar answered Sep 30 '22 03:09

lena