Proposal: Expose 'zig fmt' autofix functionality as a separate command

The zig fmt command currently has two purposes: formatting the code to match the official style, and performing automatic fixes as the compiler changes. The latter is necessary when upgrading compilers, but the former is not. I’d like to see a way to invoke the necessary changes only.

While I agree with the premise of a standard code style, particularly in use of public libraries, for my own personal projects I stick to the code style I’ve used for years and find to be more readable. Which is fine, to each their own. Any time I create a public zig project, I use the official style.

However, for my personal projects this means I can never benefit from the automatic fixes that zig fmt can provide.

It would be nice if this non-styling functionality could be exposed as a separate command, i.e. zig fix or zig lint. This would apply required language fixes, without the optional style changes. zig fmt would continue to make both changes, as is currently expected.

6 Likes

It would be interesting to know - what are the diffs between your coding style and the “official” one?