Skip to content

Conversation

@jfly
Copy link
Contributor

@jfly jfly commented Dec 3, 2025

With vanilla shfmt, it's easy to get it to use .editorconfig files: you simply invoke it with no
arguments
.

However, with treefmt-nix, it's a bit more challenging because we turn on some knobs by default, and those knobs change over time. For example, we have users who used to accomplish this by setting indent_size to null, but then we recently added the simplify flag which defaults to true, thereby causing shfmt to no longer honor .editorconfig files.

To give people some stability, this new useEditorConfig option changes the defaults so they're all disabled, and furthermore asserts that every option is disabled (in case people try to change them by hand). This protects our users against new default options in the future.

An alternative to this would be a policy of not deviating from shfmt's defaults, but I think this is clearer for everyone.

With vanilla `shfmt`, it's easy to get it to use `.editorconfig` files:
you simply [invoke it with no
arguments](https://github.com/mvdan/sh/blob/v3.12.0/cmd/shfmt/shfmt.1.scd?plain=1#L20-L21).

However, with `treefmt-nix`, it's a bit more challenging because we turn
on some knobs by default, and those knobs change over time. For example,
we have users who [used to accomplish this by setting `indent_size` to
`null`](https://github.com/sellout/bash-strict-mode/blob/37eaa2e33d24168e0a903ddd9828666c1b91f867/.config/project/default.nix#L31-L33),
but then we recently added the [simplify flag which defaults to
true](numtide@6b850ba),
thereby causing shfmt to no longer honor `.editorconfig` files.

To give people some stability, this new `useEditorConfig` option changes
the defaults so they're all disabled, and furthermore asserts that every
option is disabled (in case people try to change them by hand). This
protects our users against new default options in the future.

An alternative to this would be a policy of not deviating from shfmt's
defaults, but I think this is clearer for everyone.
Copy link

@l0b0 l0b0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much clearer, thank you!

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.

2 participants