feat: Add .editorconfig for consistent formatting #324
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.
Hi team,
This pull request introduces a
.editorconfigfile to the root of our repository.Motivation
I'm proposing this change to address a common source of friction I've experienced, where commits fail in CI simply due to a missing final newline in a file. By defining a core set of formatting rules that are automatically applied by most code editors, we can eliminate this entire class of errors and make the contribution process smoother for everyone.
As I wrote about recently on my blog, this single file can help unify formatting across our team's diverse development environments.
Benefits of
.editorconfigAutomated Consistency: Automatically enforces basic rules like line endings, character sets, and the presence of a final newline.
Reduced CI Noise: Prevents trivial CI failures, allowing us to focus on the substance of our changes.
Editor Agnostic: It's a single, standard configuration file supported by a vast range of editors and IDEs (including JetBrains IDEs, VS Code with a popular extension, Vim, Emacs, and more). This avoids the need for editor-specific settings files.
Opt-in Enhancement: For contributors whose editors support it, the experience is improved. For those who don't, nothing is enforced, and our existing CI linters will still act as the final backstop. It's a helpful enhancement, not a strict requirement.
About This Configuration
I've created this configuration file based on a detailed analysis of our repository's structure. Key decisions include:
Universal Standards: Enforces
UTF-8,LFline endings, and the crucialinsert_final_newline.Language-Specific Indentation: Sets appropriate indentation for
.awk,.bats,.json, and.ymlfiles.Flexible Line Length:
max_line_lengthis intentionallyunsetfor.awkand.batsfiles, as our analysis showed that many example and test files contain long lines with embedded data that shouldn't be wrapped.Respect for Generated Files: Rules are explicitly
unsetfor files we don't edit, likeLICENSEandfetch-configlet, to prevent unintended changes.I'm very open to discussion on this file. Please feel free to review, comment, and suggest any changes. Let's make this configuration work perfectly for our track!
Looking forward to your feedback.