I've got to say this is what I would have expected and wanted to happen. I'd say it is wise to not run tools designed to edit files on files you don't have a backup for (like Git) without doing a dry-run or a small scope experiment first.
How were you not expecting this? Did you not bother to read anything before installing and running this command on a sensitive codebase?
But most formatters I'm used to absolutely don't do this. For example, `rustfmt` will read input from stdin if no argument is given. It can traverse modules in a project, but it won't start modifying everything under your CWD.
Most unix tools will either wait for some stdin or dump some kind of help when no argument is given. Hell, according to this tool's docs, even `prettier` seems to expect an argument:
> Running oxfmt without arguments formats the current directory (*equivalent to prettier --write .*)
I'm not familiar with prettier, so I may be wrong, but from the above, I understand that prettier doesn't start rewriting files if no argument is given?Looking up prettier's docs, they have this to say:
> --write
This rewrites all processed files in place. *This is comparable to the eslint --fix* workflow.
So eslint also doesn't automatically overwrite everything?So yeah, I can't say this is expected behaviour, even if it's documented.
Try git reset --hard, that should work.
It is bad ux.
A power user can just pass the right params. Besides, it is not that hard to support "--yolo" parameter for that use case
`oxfmt` should have done the same and `oxfmt .`, with the desired dir ".", should have been the required usage.
I don't expect `rm` with no argument to trash everything in my CWD. Which it doesn't, see sibling's comment.
I do not feel that new devs should not learn these things the hard way
So maybe we should call it JavaScript style? Modern JS style? Do we have a good name for it?
Also, does anyone know when and why “K&R style” [5] started being used to refer to Java style? Meaning K&R statement block style (“Egyptian braces” [6]) being used for all braces and single statement blocks getting treated the same as multi-statement blocks. Setting aside the eternal indentation question.
1: https://en.wikipedia.org/wiki/Indentation_style#Java
2: https://www.oracle.com/java/technologies/javase/codeconventi...
3: https://www.oracle.com/java/technologies/javase/codeconventi...
4: https://prettier.io/docs/options#tab-width
5: https://ia903407.us.archive.org/35/items/the-ansi-c-programm...
6: https://en.wikipedia.org/wiki/Indentation_style#Egyptian_bra...
Let this be a warning: running oxfmt without any arguments recursively scans directory tree from the current directory for all *.js and *.ts files and silently reformats them.
Thanks to that, I got a few of my Allman-formatted JavaScript files I care about messed up with no option to format them back from K&R style.