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

Config resolution in stdin mode #21

Open
43081j opened this issue Jan 27, 2025 · 3 comments
Open

Config resolution in stdin mode #21

43081j opened this issue Jan 27, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@43081j
Copy link
Contributor

43081j commented Jan 27, 2025

When we run the CLI with stdin, it currently doesn't do any of the logic for config file resolution.

However, it is possible to specify a --stdin-filepath, in which case we should do the same resolution as runGlobs does.

There are tests in prettier that we need to move over which will fail until this is possible. That, or we decide we don't want to support such a thing and don't take those tests.

cc @fabiospampinato

@fabiospampinato
Copy link
Collaborator

I didn't know that, the internal logic has to be reworked a bit then, PR welcome, even just for porting the failing tests over if not for fully fixing it.

@fabiospampinato fabiospampinato added the bug Something isn't working label Jan 27, 2025
@fabiospampinato
Copy link
Collaborator

Or maybe more than a bit, I wonder what the cleanest way to map this onto the normal path would be 🤔

@43081j
Copy link
Contributor Author

43081j commented Jan 27, 2025

I had a look at this more earlier and it seems both manual config and auto config resolution need to be supported if we want to match prettier

So if we specify --config-path, we should directly resolve that and pull the options in

But in addition to that, we should discover config files, probably using cwd as the root. Though if --stdin-filepath isn't set, maybe we should skip this?

43081j added a commit to 43081j/prettier-cli that referenced this issue Feb 15, 2025
Copies the tests from prettier.

Notable changes:

- A failed plugin load throws an uncaught exception before this change.
  This catches it and logs an error to stderr
- A `snapshot-diff` package was being used to create a `git diff` like
  diff as a jest snapshot. We can pick the unique lines out instead of
using this

Skipped tests:

- `--help {option}` is not supported in prettier CLI
- `--config-path` with stdin is not yet supported (see prettier#21)

Notable hiccups:

- Parsing argv seems to fall over on things like `--plugin=--foo--`, so
  the test has been changed for now to use `--plugin=totally-invalid`
43081j added a commit to 43081j/prettier-cli that referenced this issue Feb 18, 2025
Copies the `plugin-option` tests from prettier.

Note that these will need updating once prettier#39 and prettier#21 are fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants