Skip to content

Custom Prettier Resolution v2 #2820

Open
@jamesarosen

Description

@jamesarosen

Is your feature request related to a problem? Please describe.
In #232, prettier-vscode added support for a prettier.prettierPath configuration. This works great for things like monorepos where the node_modules/ directory (and thus the Prettier binary) might lie outside the current workspace.

This does not, however, solve the problem for Docker-centric workspaces. We use Docker extensively in development so developers have an easier time getting a standardized development environment running. Local files (e.g. ./app/, ./src/, etc.) are mounted into a running Docker container via docker-compose. This container has all the development dependencies needed, including specific versions of Unix, node, Ruby, etc.

Everything is configured so that this works from the command line:

$ docker compose exec app node_modules/.bin/prettier './**/*' --ignore-unknown

I tried to set prettier.prettierPath: "docker compose exec app node_modules/.bin/prettier", but that failed.

Describe the solution you'd like
I'd like to be able to specify an arbitrary executable (here docker) with arguments (here compose exec app node_modules/.bin/prettier") for VSCode-Prettier to run.

Describe alternatives you've considered
I've successfully used emeraldwalk.runonsave to solve this, but it doesn't have the Prettier-specific niceties.

Additional context
Possible downsides:

  • Use with Docker requires passing workspace-relative paths to the executable.
  • Use with Docker requires mounting files. That is outside the scope of Prettier-VSCode. If Docker containers have particularly complex configurations, project maintainers may have to write a wrapper around Prettier to munge paths or arguments.

Alternative solution: use a Visual Studio Code Dev Container to develop inside the Docker container, then run prettier-vscode normally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp-wantedNot something we plan on doing, but we will take a pull request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions