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

Support --stdin-path or something similar to properly ignore files formatted through stdin #365

Open
reese opened this issue Nov 19, 2022 · 1 comment

Comments

@reese
Copy link
Collaborator

reese commented Nov 19, 2022

This is more a feature request since I imagine other tools (e.g. VSCode extensions will need it, see the discussion in #354) will need it: currently, any tool formatting through stdin loses all ability to use .rubyfmtignore, but there are plenty of cases where reading from disk isn't convenient/possible, especially in VSCode extensions like the Ruby and Sorbet extensions.

Having something like --stdin-path from prettier would simplify this problem by basically telling rubyfmt to format file contents as if they were at the given path, and ignore them as needed. This prevents extensions from having to manually handle .rubyfmtignore paths.

So for example, if my .rubyfmtignore has foo.rb in it, doing

echo 'puts "hi"' | rubyfmt --stdin-path foo.rb
# => puts "hi"

produces no changes due to the file being ignored, but

echo 'puts "hi"' | rubyfmt --stdin-path bar.rb
# => puts("hi")

produces changes as expected.

@reese
Copy link
Collaborator Author

reese commented Dec 30, 2022

Hmm, so there's a bit of a snag on this, which is mainly that BurntSushi/ripgrep#829 is still kicking around, which affects exact use-case. We're also not the first Rust-based code formatter (see JohnnyMorganz/StyLua#377) to get bitten by this, so I think this will likely turn out to be non-trivial (i.e. it may require hand-rolling out ignore logic, which sounds not-fun).

Gonna put this on the backburner for a bit, but it's worth noting that this also means that some pretty basic ignore patterns are gonna be busted for users, so this makes the .rubyfmtignore and .gitignore checking a bit less useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant