Skip to content

fix(pre-commit): stop the hook from overriding .editorconfig indent_size - #67

Merged
reteps merged 1 commit into
mainfrom
fix/editorconfig-precommit
Nov 7, 2026
Merged

reteps merged 1 commit into
mainfrom
fix/editorconfig-precommit

Conversation

@reteps

@reteps reteps commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #61.

I couldn't reproduce subdirectory resolution failing with the CLI itself. dockerfmt docker/Dockerfile run from the repo root picks up the root .editorconfig for relative, ./-prefixed, nested, absolute and .. paths, and for path globs like [docker/Dockerfile], [**/Dockerfile] and [docker/**]. editorconfig-core-go resolves the absolute path and walks up to root = true.

What does silently ignore .editorconfig is the pre-commit hook. Both .pre-commit-hooks.yaml and the README's example config passed --indent=4 explicitly. Explicit flags take precedence over .editorconfig (as documented), so indent_size never applied for pre-commit users, in any directory.

  • Drop --indent=4 from the hook's default args. It is already the CLI default, so nothing changes for users without an .editorconfig. --newline and --space-redirects stay, because removing them would change existing users' output.
  • README: the pre-commit example now uses the hook defaults and explains that args replaces them and overrides .editorconfig. The EditorConfig section now explains lookup for Dockerfiles in subdirectories.
  • Add cmd/editorconfig_test.go with regression tests for subdirectory resolution, path globs, and flag precedence.

Test plan

  • go test ./...

🤖 Generated with Claude Code

The pre-commit hook (and the README's example config) passed --indent=4
explicitly. Explicit CLI flags take precedence over .editorconfig, so for
pre-commit users indent_size from .editorconfig was never applied, in any
directory. --indent=4 is already the default, so dropping it changes
nothing for users without an .editorconfig.

Document how .editorconfig files are resolved for Dockerfiles in
subdirectories and how hook args interact with them, and add regression
tests for subdirectory, ./-prefixed, nested, absolute and path-glob cases.

Fixes #61

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@reteps
reteps merged commit 00886ac into main Nov 7, 2026
3 checks passed
@reteps
reteps deleted the fix/editorconfig-precommit branch November 14, 2026 04:50
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.

.editorconfig settings are not applied when formatting a Dockerfile in a subdirectory

1 participant