Tslint: Accept input from stdin?

Created on 2 Oct 2016  ยท  15Comments  ยท  Source: palantir/tslint

I'm trying to get tslint working with a vim linter, however to do this I need to be able to pass input via stdin.
https://github.com/w0rp/ale/issues/20

To my knowledge, all major JS linters support this feature (jshint, eslint, jscs).

P3 Accepting PRs Feature Request ๐ŸŒน R.I.P. ๐ŸŒน

Most helpful comment

I'm going to give this a go. I'll create a pull request with the first thing I can think of at some point, and keep editing it until everything actually works.

All 15 comments

Ended up using a bash wrapper that buffers stdin to a temp file.

Would still be great if it supported stdin out of the box and I wouldn't mind helping out with that.

we'd accept a PR for this, but it might get a little complex due to the interactions with the compiler APIs.

Thanks!

Will try to get something in over the next month or two.

On Tue, Oct 4, 2016 at 9:53 PM, Adi Dahiya [email protected] wrote:

we'd accept a PR for this, but it might get a little complex due to the
interactions with the compiler APIs.

โ€”
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/palantir/tslint/issues/1590#issuecomment-251393957,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHKn0lASX6zcHpmWT5sjBC5zqdR-zcrJks5qwlo9gaJpZM4KMD7t
.

I thought that it was working, as when I typed tslint - < filename.ts I didn't get any errors, but it looks like the accpetance of - as a filename is a bug.

@prashcr This would be such an excellent feature! I am currently trying to configure https://github.com/sbdchd/neoformat to use tslint and am stumbling across some problems which this would solve.

@ianks I agree!
Unfortunately I've been busy as of late, but I still see myself working on this sometime soon.

@adidahiya Do you think we can add a special flag to take input via stdin? For Eg:

$ git diff --name-only | tslint --fix --stdin

@tusharmath for your example you could simply use xargs:

git diff --name-only | xargs tslint --fix

@ajafff Thanks a ton! You saved me a day :P BTW what's the use case of stdin in that case?

@tusharmath one use case (surely not the only one) is linting the output of git show :somefile (which outputs the staged form of :somefile) in a commit hook, so that if I've staged a linting error, then fixed it but not staged the fix, the hook will still fail when I try to commit. This is really how all good linting commit hooks should behave, but I figure that properly implementing this behaviour isn't possible at present with TSLint without doing funky stuff with temporary files or similar.

I would like to add that in addition to supporting --stdin, a --stdin-filename option should be supported, like in ESLint. This allows linter plugins to pass the contents of text buffers in place of filenames, so you can spot errors before a file is saved.

You essentially replace tslint whatever.ts with tslint --stdin --stdin-filename whatever.ts and send the contents of the buffer to TSLint via stdin.

This would be really helpful :+1:

I'm going to give this a go. I'll create a pull request with the first thing I can think of at some point, and keep editing it until everything actually works.

๐Ÿ’€ _It's time!_ ๐Ÿ’€

TSLint is being deprecated and no longer accepting pull requests for major new changes or features. See #4534. ๐Ÿ˜ฑ

If you'd like to see this change implemented, you have two choices:

  • Recommended: Check if this is available in ESLint + typescript-eslint โœ…
  • _Not Recommended: Fork TSLint locally_ ๐Ÿคทโ€โ™‚๏ธ

๐Ÿ‘‹ It was a pleasure open sourcing with you!

_If you believe this message was posted here in error, please comment so we can re-open the issue!_

๐Ÿค– Beep boop! ๐Ÿ‘‰ TSLint is deprecated ๐Ÿ‘ˆ _(#4534)_ and you should switch to typescript-eslint! ๐Ÿค–

๐Ÿ”’ This issue is being locked to prevent further unnecessary discussions. Thank you! ๐Ÿ‘‹

Was this page helpful?
0 / 5 - 0 ratings