vim-syntastic / syntastic

Syntax checking hacks for vim
Do What The F*ck You Want To Public License
11.3k stars 1.14k forks source link

TypeScript no-unused-variable rule not working #2011

Closed ajcrites closed 7 years ago

ajcrites commented 7 years ago

This applies to an ionic 2 project if that makes a difference.

When using syntastic, it seems like the no-unused-variable rule does not work. I can have an unused variable in a file, but it will not be reported from vim at all.

If I run tslint on the file directly, it doesn't report an error either but I do get a warning:

Warning: The 'no-unused-variable' rule requires type checking

I can use tslint --type-check --project tsconfig.json but that's not per-file. I understand that the limitation there is on tslint itself rather than syntastic. ionic-app-scripts lint does report this on a per-file basis.

Is there any way to get Sytnastic to report on unused variables?

lcd047 commented 7 years ago

I can use tslint --type-check --project tsconfig.json but that's not per-file.

You can set g:syntastic_typescript_tslint_fname to an empty string to disable passing filenames. You can also enable debugging (cf. :h syntastic-debug) to see the command line constructed by syntastic.

Is there any way to get Sytnastic to report on unused variables?

Only if you can configure tslint with the syntastic_typescript_tslint_* variables to report it. Syntastic itself doesn't know, nor particularly cares, about TypeScript, or about the contents of your files. What syntastic does is run linters, parse their output, and show you the results in a window.

ajcrites commented 7 years ago

@lcd047 do you know if there is a way for me to have it run an arbitrary command as a linter? For example, yarn lint in my case will report this error, but It seems like the linters you can set for Syntastic are just one word.

lcd047 commented 7 years ago

if there is a way for me to have it run an arbitrary command as a linter?

No, linters have to be supported explicitly. It wouldn't make sense any other way: syntastic needs to parse the linters' output, and thus it has to be aware of the format used by said linters to print errors.

the linters you can set for Syntastic are just one word.

No, they can be essentially anything. An example for JavaScript is flow status. But yarn is not (yet) supported.

nuke-ellington commented 7 years ago

@ajcrites did you find a way to solve this type checking issue on a per file basis? I'm having a hard time getting tslint to work with Syntastic as well.

ajcrites commented 7 years ago

@nuke-ellington unfortunately not. I use https://github.com/Quramy/tsuquyomi with Syntastic. It works pretty well in general, but this particular issue is still there so I just run a separate linter to check for that specifically.