Support overrides for dotfiles (#6194)
parent
8812792e93
commit
448328270d
|
@ -75,5 +75,11 @@ function function1<T>() {
|
|||
}
|
||||
```
|
||||
|
||||
#### Config: Match dotfiles in config overrides ([#6194] by [@duailibe])
|
||||
|
||||
When using [`overrides`](https://prettier.io/docs/en/configuration.html#configuration-overrides) in the config file, Prettier was not matching dotfiles (files that start with `.`). This was fixed in 1.18.1
|
||||
|
||||
[#6190]: https://github.com/prettier/prettier/pull/6190
|
||||
[#6194]: https://github.com/prettier/prettier/pull/6194
|
||||
[@duailibe]: https://github.com/duailibe
|
||||
[@sosukesuzuki]: https://github.com/sosukesuzuki
|
||||
|
|
|
@ -158,7 +158,7 @@ function mergeOverrides(configResult, filePath) {
|
|||
function pathMatchesGlobs(filePath, patterns, excludedPatterns) {
|
||||
const patternList = [].concat(patterns);
|
||||
const excludedPatternList = [].concat(excludedPatterns || []);
|
||||
const opts = { matchBase: true };
|
||||
const opts = { matchBase: true, dot: true };
|
||||
|
||||
return (
|
||||
patternList.some(pattern => minimatch(filePath, pattern, opts)) &&
|
||||
|
|
|
@ -232,6 +232,15 @@ test("API clearConfigCache", () => {
|
|||
expect(() => prettier.clearConfigCache()).not.toThrowError();
|
||||
});
|
||||
|
||||
test("API resolveConfig overrides work with dotfiles", () => {
|
||||
const folder = path.join(__dirname, "../cli/config/dot-overrides");
|
||||
return expect(
|
||||
prettier.resolveConfig(path.join(folder, ".foo.json"))
|
||||
).resolves.toMatchObject({
|
||||
tabWidth: 4
|
||||
});
|
||||
});
|
||||
|
||||
test("API resolveConfig.sync overrides work with absolute paths", () => {
|
||||
// Absolute path
|
||||
const file = path.join(__dirname, "../cli/config/filepath/subfolder/file.js");
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"tabWidth": 2,
|
||||
overrides: [
|
||||
{
|
||||
"files": "*.json",
|
||||
"options": {
|
||||
"tabWidth": 4
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue