Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 1, 2025

Description

Enables running Prettier through arbitrary executables (Docker, wrapper scripts) via new prettier.customExecutable setting. Addresses Docker-centric development where Prettier runs inside containers.

Implementation:

  • PrettierExecutableInstance: New class implementing PrettierInstance interface. Executes Prettier via spawn with stdin/stdout, supports all CLI operations (format, file-info, support-info, config resolution). Single-quote shell escaping on all dynamic arguments.

  • ModuleResolverNode: Added getCustomExecutableInstance method. Custom executable checked first in resolution chain, instance caching maintained.

  • Configuration: prettier.customExecutable setting in package.json. Optional ${prettier} placeholder for Prettier path. Restricted in untrusted workspaces.

  • Localization: English, Chinese Simplified, Chinese Traditional strings added.

Usage:

// Docker
{
  "prettier.customExecutable": "docker compose exec -T app node_modules/.bin/prettier"
}

// With placeholder
{
  "prettier.customExecutable": "docker exec container ${prettier}",
  "prettier.prettierPath": "/app/node_modules/.bin/prettier"
}

Security:

  • All dynamic arguments (paths, options) escaped via single-quote method
  • CodeQL scan passes with 0 alerts
  • Custom executable itself is trusted user configuration

Test fixture in test-fixtures/custom-executable/ with wrapper script example.

Related Issue

Fixes #232

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/Build changes

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the code style of this project (npm run lint passes)
  • I have run npm run prettier to format my code
  • I have added/updated tests that prove my fix or feature works
  • All new and existing tests pass (npm test)
  • I have updated the CHANGELOG.md with a summary of my changes

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com//advisories
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Custom Prettier Resolution v2</issue_title>
<issue_description>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.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
Copilot AI and others added 6 commits December 1, 2025 22:38
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for custom Prettier configuration in Docker environments Add custom executable support for Docker-based Prettier workflows Dec 1, 2025
Copilot AI requested a review from ntotten December 1, 2025 22:58
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.

Custom Prettier Resolution v2 Custom Prettier Resolution

2 participants