Closed ConradIrwin closed 4 years ago
There's no need for extra flag as it's enough to run prettier-standard from different cwd.
I'm not sure how to do it in Ale, but usally it's configured with something like cwd
or dir
option, or with command like cd CWD && prettier-standard
@sheerun I don't observe that behaviour at the moment; but it's quite possible I am doing something wrong. For example, it seems like if I am in the same directory as a javascript file and a .prettierrc, the configuration will only be picked up if I name the file directly:
$ cd $(mktemp -d)
$ echo '{"printWidth":10}' > .prettierrc
$ echo 'console.log(1,2,3)' | prettier-standard --stdin
console.log(1, 2, 3)
$ echo 'console.log(1,2,3)' > a.js && prettier-standard a.js && cat a.js
console.log(
1,
2,
3
)
I would expect the same output from both commands.
okay, let's implement it for sake of consistency with eslint and prettier, instead of fixing cwd
Thank you for contributing. One thing missing from prettier-standard is linting stdin input . Maybe you could consider implementing it as well if you'll find time :) (--stdin --lint
currently is not supported)
released as 16.1.0
Thanks @sheerun!
Before this change users who passed --stdin could not customize the configuration of prettier-standard.
After this change, --stdin-filepath can be used to load configuration as though the --stdin input came from a given file.
This is necessary for editor plugins like ale [1] to provide configuration. They cannot call prettier-standard on the actual file as it is managed by the editor.
An alternative workaround would be to allow passing a path to a config file directly, but this approach is both consistent with prettier, and backwards compatible in the face of any changes to how configuration files are resolved.
[1] https://github.com/dense-analysis/ale