fix: inherit the ancestor config in a main config with `"inherit": true` by dsherret · Pull Request #1340 · dprint/dprint · GitHub
Skip to content

fix: inherit the ancestor config in a main config with "inherit": true - #1340

Merged
dsherret merged 5 commits into
mainfrom
fix-main-config-inherit
Oct 11, 2026
Merged

dsherret merged 5 commits into
mainfrom
fix-main-config-inherit

Conversation

@dsherret

@dsherret dsherret commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

A config file with "inherit": true was only merged with its ancestor config when it was discovered as a descendant of the config file the CLI started with. When it was the main config (the one found from the cwd), inherit was ignored, so running dprint fmt in ./sub-project used different configuration than running it in the root directory, and dprint install there didn't install the inherited plugins. The language server already inherited in this case.

This makes "inherit": true work one way everywhere (CLI, editor service, and language server), all going through the same code:

  1. A local config file that specifies "inherit": true always inherits from the closest config file in the ancestor directories of that file (which may also inherit). It's an error when there isn't one.
  2. It's an error for the global config file to specify "inherit": true, and the global config file is never inherited from.
  3. A remote or npm config file that specifies "inherit": true has no ancestor directories, so the property is ignored with a warning (shown on the first download, like the includes one).

This applies to the main config file, a config file specified via --config, a config file in a descendant directory, a config file found for a path outside the cwd, and a config file pulled in via extends.

Behaviour changes

  • The main config file now inherits. Previously only config files in descendant directories did in the CLI.
  • A config file with "inherit": true and no config file in an ancestor directory is now an error. Previously this was silently ignored.
  • The global config file is never inherited from. Previously the language server inherited from it when using the global config, and the CLI did for a descendant config file of a directory that was using the global config.
  • A local config file specified via --config inherits from the ancestor directories of that file, including with --config-discovery=false. Previously it was used on its own in the language server and never inherited in the CLI.
  • A config file in a descendant directory inherits from the config file in its own ancestor directories. This is only different from before when --config is used, where it previously inherited from the specified config file.
  • "inherit": true in a local config file that's extended now has that file inherit from the config file in its ancestor directories, at a lower precedence than what the file extends. Previously inherit was left as an unknown property. A circular inherit this makes possible is an error.

When the global config file gets used (no config file in the directory) is unchanged.

Notes

  • dprint add and dprint config update now see the inherited plugins of the main config, the same way they already see plugins from extends and from descendant configs that inherit.

@dsherret
dsherret merged commit 11337b8 into main Oct 11, 2026
22 checks passed
@dsherret
dsherret deleted the fix-main-config-inherit branch October 11, 2026 15:33
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