Repository navigation
fix: format explicit paths outside the --config file's directory with its unanchored patterns - #1314
Merged
Merged
Conversation
…rectory with only its unanchored patterns
--config file's directory with only its unanchored patterns--config file's directory with only its unanchored patterns
--config file's directory with only its unanchored patterns--config file's directory with its unanchored patterns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes dprint/dprint-plugin-markdown#287
Since #1257, a local
--configfile's patterns are relative to the config file's directory. That left--stdinwith an absolute path broken for anyone pointing-cat a config in another directory (ex. a personal config used by an editor integration):The file was outside the config file's directory, so it was treated as not matched and the input was echoed back unformatted, even with no
includesin the config.dprint fmt -c ... ~/a.mdformatted the same file.Behavior
For a config file specified via
--configand an explicitly specified file outside its directory (the--stdinpath or afmt/checkpath arg):includes**/*.md,***.md,dist(no slash)src/**/*.md,./sub,../otherThe same applies to
excludes, pluginassociations, and thefilesof plugin configoverrides.This only affects explicitly specified paths.
dprint fmt -c sub/dprint.jsonwith no path args still only walkssub/.Breaking change
A
fmt/checkpath arg outside the--configfile's directory previously had all of the config's patterns re-anchored at the path's root directory, so"includes": ["src/**/*.md"]in/config/dprint.jsonmatched/src/file.md. That predates #1257 and contradicted it. Anchored patterns now stay relative to the config file's directory, so that include no longer matches/src/file.md.Changes
ResolvedConfighas a new optionalanchored_patterns_base_path. When a--configfile is rebased at the root directory of an outside path, it keeps the config file's directory, andnew_config_glob_patternbases the patterns that match at any depth at the root and the anchored ones at the config file's directory.stdin_fmtrebases the config the same wayfmtdoes for a path arg, using the same definition of "outside" (outside the highest directory the includes are based at).Not changed:
--stdin.Known limitations
./**/*.mdis anchored, so a config using that form still doesn't match an outside file.**/*.mddoes.../include, a file within the ancestor directory the include is based at but outside the config file's directory doesn't get the any-depth patterns applied (ex./a/config/dprint.jsonwith"includes": ["../other/**/*.txt", "**/*.txt"]doesn't match/a/sibling/file.txt).--stdinand path args agree on this.Testing
--stdinwith a file outside the--configfile's directory: no includes,--excludesstill applying, any-depth vs anchored includes and excludes, and a../include.fmtpath args to check both agree.