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

Add --stdin-filepath #92

Merged
merged 1 commit into from Dec 3, 2019
Merged

Conversation

ConradIrwin
Copy link
Contributor

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

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
@sheerun
Copy link
Owner

sheerun commented Dec 3, 2019

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

@ConradIrwin
Copy link
Contributor Author

ConradIrwin commented Dec 3, 2019

@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.

@sheerun
Copy link
Owner

sheerun commented Dec 3, 2019

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)

@sheerun sheerun merged commit f36c145 into sheerun:master Dec 3, 2019
@sheerun
Copy link
Owner

sheerun commented Dec 3, 2019

released as 16.1.0

@ConradIrwin
Copy link
Contributor Author

Thanks @sheerun!

This was referenced Jun 6, 2021
This was referenced Jun 6, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants