Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to `--fix` through stdin without getting errors? #1048

Closed
gerardabello opened this issue Jan 23, 2018 · 2 comments

Comments

@gerardabello
Copy link

commented Jan 23, 2018

I want to format a string of code that might contain non-fixable errors. If I want the formatted output through stdin I get both the code and the non-fixable errors, so it is difficult to extract the formatted code from there.

Is there any way to ignore non-fixable errors when using --fix through stdin?

Thanks

@bcomnes

This comment has been minimized.

Copy link
Member

commented Jan 27, 2018

Editor plugins do this by dealing with errors when try spawn a process to try and perform the fix.

@feross

This comment has been minimized.

Copy link
Member

commented Feb 17, 2018

@gerardabello The "fixed" code goes to stdout, while the error messages go to stderr, so you can filter out just what you need.

Concrete example:

echo 'var x = 4;' | standard --stdin --fix > out.txt

Now "out.txt" contains the fixed file. The unfixable errors still get printed to stderr and appear in the terminal.

@lock lock bot locked as resolved and limited conversation to collaborators May 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
3 participants
You can’t perform that action at this time.