You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to this line, if I run npx sort-json client-generation.nswag nothing happens. Even though I have explicitly stated that I want to sort the JSON of that file.
In our case, the lint-staged tooling passes a list of files (based on configuration) to sort-json, but we found out some of them never get sorted, because they don't end in .json or .rc. In fact, we have no JSON files ending in .rc at all, but we have some JSON files with other extensions.
Was this added to support stuff like npx sort-json *? Because I think that kind of laziness shouldn't be supported in such a way.
One philosophy is that the user of the tool should not feed it invalid data. It's not that much harder to write a proper statement such as: npx sort-json $(ls *.{json,rc}) (bash example). Exmple: If you accidentally run sudo rm -rf /* instead of sudo rm -rf ./*, you can go and reinstall your OS, and hope you backed up your files.
Another philosophy is that if the tool can handle it, it must be forgiving. It might be an idea to not abort on an unparseable file, maybe write a warning to stderr. E.g. Skipping because it doesn't contain valid JSON and just continue with the next file. Example: If you run sudo rm -rf / most rm implementations will refuse.
Option two runs the risk of performing poorly in some situations, but only if the user doesn't obey the first philosophy and feeds it a large number of non-JSON files. I think either option is superior to the current implementation.
The text was updated successfully, but these errors were encountered:
sort-json/app/cmd.js
Line 21 in 90da9a3
Due to this line, if I run
npx sort-json client-generation.nswag
nothing happens. Even though I have explicitly stated that I want to sort the JSON of that file.In our case, the
lint-staged
tooling passes a list of files (based on configuration) tosort-json
, but we found out some of them never get sorted, because they don't end in.json
or.rc
. In fact, we have no JSON files ending in.rc
at all, but we have some JSON files with other extensions.Was this added to support stuff like
npx sort-json *
? Because I think that kind of laziness shouldn't be supported in such a way.npx sort-json $(ls *.{json,rc})
(bash example).Exmple: If you accidentally run
sudo rm -rf /*
instead ofsudo rm -rf ./*
, you can go and reinstall your OS, and hope you backed up your files.Example: If you run
sudo rm -rf /
mostrm
implementations will refuse.Option two runs the risk of performing poorly in some situations, but only if the user doesn't obey the first philosophy and feeds it a large number of non-JSON files. I think either option is superior to the current implementation.
The text was updated successfully, but these errors were encountered: