Skip to content

fix: accept npm: specifiers in the --plugins CLI flag - #1319

Merged
dsherret merged 4 commits into
mainfrom
fix/plugins-flag-npm-specifiers
Oct 10, 2026
Merged

dsherret merged 4 commits into
mainfrom
fix/plugins-flag-npm-specifiers

Conversation

@dsherret

Copy link
Copy Markdown
Member

Repro: dprint check --plugins npm:@dprint/[email protected] failed with "npm:@dprint/[email protected] was specified as a plugin, but it doesn't look like one. Plugins must have a .wasm or .json extension."

The check in validate_plugin_args_when_no_files exists to catch dprint fmt --plugins <url> <file> where the user forgot --, but it only accepted .wasm/.json (optionally with a checksum suffix), so npm: specifiers, which don't need an extension, were rejected before ever reaching parse_plugin_source_reference.

Change:

  • anything starting with npm: now passes the "looks like a plugin" check (extracted into a looks_like_plugin helper)
  • the error message now reads "...Plugins must have a .wasm or .json extension, or be an npm: specifier."
  • --plugins help text and website/src/config.md mention npm: specifiers
  • tests: updated the two message assertions, added one showing --plugins npm:@dprint/[email protected] with no files parses, and one showing npm: followed by a file-looking arg still gets the "Maybe you meant to add two dashes" hint

The config resolution already goes through parse_plugin_source_reference, so no further changes were needed for npm: to work end to end.

Verification:

  • cargo test -p dprint passes (apart from the pre-existing umask-dependent extract_tarball_preserves_exec_bits_via_env_set_permissions), cargo clippy -p dprint clean
  • release build: DPRINT_CACHE_DIR=<scratch> ./target/release/dprint output-resolved-config --plugins npm:@dprint/[email protected] downloads the plugin and outputs the json config; dprint check --plugins npm:@dprint/[email protected] now runs the plugin

@dsherret
dsherret merged commit 8cb0208 into main Oct 10, 2026
17 checks passed
@dsherret
dsherret deleted the fix/plugins-flag-npm-specifiers branch October 10, 2026 19:20
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.

1 participant