Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Accept input from stdin? #1590

Closed
prashcr opened this issue Oct 2, 2016 · 15 comments
Closed

Accept input from stdin? #1590

prashcr opened this issue Oct 2, 2016 · 15 comments

Comments

@prashcr
Copy link

prashcr commented Oct 2, 2016

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.
dense-analysis/ale#20

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

@prashcr
Copy link
Author

prashcr commented Oct 4, 2016

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.

@adidahiya
Copy link
Contributor

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

@prashcr
Copy link
Author

prashcr commented Oct 5, 2016

Thanks!

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

On Tue, Oct 4, 2016 at 9:53 PM, Adi Dahiya notifications@github.com 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
#1590 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHKn0lASX6zcHpmWT5sjBC5zqdR-zcrJks5qwlo9gaJpZM4KMD7t
.

@rjmunro
Copy link

rjmunro commented Dec 20, 2016

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.

@ianks
Copy link

ianks commented Jan 26, 2017

@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.

@prashcr
Copy link
Author

prashcr commented Jan 27, 2017

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

@tusharmath
Copy link

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

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

@ajafff
Copy link
Contributor

ajafff commented Mar 30, 2017

@tusharmath for your example you could simply use xargs:

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

@tusharmath
Copy link

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

@ExplodingCabbage
Copy link

ExplodingCabbage commented Jul 15, 2017

@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.

@w0rp
Copy link

w0rp commented Oct 14, 2017

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.

@sinisterstumble
Copy link

This would be really helpful 👍

@w0rp
Copy link

w0rp commented Mar 21, 2018

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.

@JoshuaKGoldberg
Copy link
Contributor

💀 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!

@JoshuaKGoldberg
Copy link
Contributor

🤖 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! 👋

@palantir palantir locked and limited conversation to collaborators Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants