Fix: ensure --stdin flag works when stdin is piped asynchronously #10393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the purpose of this pull request? (put an "X" next to item)
[x] Bug fix
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
N/A
Please show your full configuration:
N/A
What did you do? Please include the actual source code causing the issue.
This issue is simplest to reproduce with bash:
(I originally encountered this issue when using
curl
to fetch a JS file and pipe it toeslint --stdin
.)What did you expect to happen?
I expected ESLint to read stdin until the end (resulting in two lines of input), and then lint those two lines.
What actually happened? Please include the actual, raw output from ESLint.
An error was thrown:
Based on nodejs/node#7439, this probably only occurs on macOS.
What changes did you make? (Give an overview)
This updates
bin/eslint.js
to avoid accessing theprocess.stdin
getter, which seems to change the state of file descriptor 0.Is there anything you'd like reviewers to focus on?
Should this be filed as a Node bug instead? Based on nodejs/node#7439, it seems to at least partially be working as intended, but the behavior is somewhat surprising.