"not include"s are ignored when paths are passed via CLI
bradzacher opened this issue · comments
Version: 0.43.1
#474 added support for respecting excludes
when passing files via the CLI.
However dprint also supports "not includes" thanks to its gitignore syntax support.
When you pass paths via the CLI dprint will not consider the "not includes" and will format files that should be excluded.
Example setup:
{
"typescript": {},
"includes": [
"src/**/*.ts",
"!src/not-included.ts"
],
"excludes": [
"src/excluded.ts"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.88.6.wasm"
]
}
With three (empty) TS files src/included.ts
, src/excluded.ts
and src/not-included.ts
.
Running dprint output-format-times
gives this output:
0ms - /Users/bjz/temp/playground/src/included.ts
However running dprint output-format-times "**/*.ts"
gives this output:
0ms - /Users/bjz/temp/playground/src/not-included.ts
0ms - /Users/bjz/temp/playground/src/included.ts
Similarly running dprint output-format-times src/included.ts src/not-included.ts src/excluded.ts
:
0ms - /Users/bjz/temp/playground/src/not-included.ts
0ms - /Users/bjz/temp/playground/src/included.ts
For the most part this is fine - however we've encountered this a number of times when people run things from the CLI. For example people will run somefolder/**/*.java
to format all their project before committing (some people find this the easiest way to ensure things are formatted rather than faffing around with git commands) and this will cause dprint to format files it shouldn't.
The same thing happens with our other tooling such as lint-staged
et al which will explicitly pass the touched paths causing dprint to format files it shouldn't.
Fixed in 0.43.2