Repository navigation
fix(pre-commit): stop the hook from overriding .editorconfig indent_size - #67
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #61.
I couldn't reproduce subdirectory resolution failing with the CLI itself.
dockerfmt docker/Dockerfilerun from the repo root picks up the root.editorconfigfor 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 toroot = true.What does silently ignore
.editorconfigis the pre-commit hook. Both.pre-commit-hooks.yamland the README's example config passed--indent=4explicitly. Explicit flags take precedence over.editorconfig(as documented), soindent_sizenever applied for pre-commit users, in any directory.--indent=4from the hook's default args. It is already the CLI default, so nothing changes for users without an.editorconfig.--newlineand--space-redirectsstay, because removing them would change existing users' output.argsreplaces them and overrides.editorconfig. The EditorConfig section now explains lookup for Dockerfiles in subdirectories.cmd/editorconfig_test.gowith regression tests for subdirectory resolution, path globs, and flag precedence.Test plan
go test ./...🤖 Generated with Claude Code