Skip to content

Simple Monorepo

gruft provides extensive configuration options to support large, multi-language monorepos.

Language Level Modifiers

We recommend maintaining a single gruft.toml file at the root of your repository and defining properties at the language level rather than using overrides with specific glob patterns. This approach simplifies configurations and makes them easier to reason with.

toml
version = '2024.01.1'
root = true

[formatter]
indent_style = 'tab' # Applies to all languages

[formatter.json]
indent_size = 4 # Applies to JSON only

[formatter.json.biome]
format_with_errors = true # Applies to the Biome tool JSON formatter

TIP

All languages already use opinionated defaults to simplify configuration. It's better to define formatting changes at the language level instead of the global level to avoid overwriting defaults for other languages.

Nested Configurations

If your root configuration becomes too large or if you need to configure specific subdirectories, you can split gruft.toml into multiple files. The nested configuration will inherit and merge the parent configuration properties.

Ensure the root configuration has root = true to prevent improper inheritance of configurations.

toml
root = true
version = '2024.01.1'

Any subdirectory configuration must explicitly declare root = false to inherit and merge settings from the parent configuration.

toml
root = false

WARNING

The version property should only be declared once at the root level and is not allowed in nested configurations.

Overrides

As an escape hatch, you can target specific glob patterns with overrides.

toml
[[overrides]] # TOML array of tables
include = ['*.test.py'] # Array of glob patterns

[overrides.formatter.python.ruff]
docstring_code_format = false

[[overrides]] # Declare another override
include = ['*_test.go']
exclude = ['not_this_test.go']

[overrides.formatter.go]
line_width = 200

Overrides can also be applied at the language level.

toml
[[json.overrides]]
include = ['test_file.json']

[json.overrides.formatter]
insert_final_newline = false

TIP

Overrides are a powerful feature but can make configurations harder to reason with. Use them sparingly and prefer language-level modifiers when possible.