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 a CLI command to output the config that shall be used for a given file #794

Open
bradzacher opened this issue Nov 28, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@bradzacher
Copy link

Recently I made a change to Canva's dprint config so that we used dprint-plugin-ruff to format our python code. However I didn't realise that I had accidentally turned off all python formatting in the codebase with my change because I'd forgotten to add associations to the config.

When I ran the formatter with --verbose I saw dprint instantiate dprint-plugin-ruff and it looked like it formatted all of the files.
But it turned out that without associations dprint was only running isort (via dprint-plugin-exec) on the files.

It wasn't until a python dev let me know that their code had violated line length without being formatted did we realise my mistake.

It would be great if there was a way to dump the config for a specific file to help validate that everything is setup as expected. I'd expect such a command to resolve all associations and includes/excludes and dump just the expected configs for the plugins that will be run.

For example eslint has --print-config <file> which will do all of the config resolution and work until just before the lint run actually starts and then prints the config and exits.

@dsherret
Copy link
Member

There is already a dprint output-resolved-config sub command. Perhaps that could accept a file path as well and the returned config would be limited to only the plugins being formatted. I'm not sure if it should just be another arg or most likely a flag (not sure about a name).

By the way, what I always do to test that is just open a file, add some spaces, then re-run the formatter.

@dsherret dsherret added the enhancement New feature or request label Nov 28, 2023
@bradzacher
Copy link
Author

bradzacher commented Nov 28, 2023

Yeah in hindsight that's what I should have done. And is what I did to verify my fix actually fixed things.

I just ran dprint with verbose mode and saw it had python files and the format time was sane and I stopped there.

And because the codebase was already formatted there ofc weren't CI failures.

Now that I've correctly configured it I can see dprint outputs logs differently if two plugins are running on a file!

Yeah I tried using output-resolved-config but because the plugin is actually configured it shows up there. The issue was that it wasn't associated with python files. Tricky nuance to the config!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants