-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: new fmt
command with dedicated formatter configuration
#5357
Open
ldez
wants to merge
10
commits into
golangci:master
Choose a base branch
from
ldez:feat/fmt-cmd
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+911
−404
Conversation
This file contains 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.
Important
This PR deliberately omits documentation about the new options and section (but the JSONSchema is updated).
This is because I don't want to deprecate the previous elements for now: I think it is better to handle that when all the v2 proposals are managed to avoid multiple migrations.
The command
golangci-lint fmt
always formats the code (no diff, no preview, no reports).The current default is the same format used by
go fmt
(!=gofmt
).There is no support for stdin.
The formatters defined in the
formatters.enable
are added automatically tolinters.enable
.If a formatter is enabled inside
formatters
andlinters
, the configuration offormatters.settings
will overridelinters-settings
even if the configuration is omitted or empty insideformatters.settings
section.This means the formatter activation and configurations should be defined only on the
formatters
orlinters
+linters-settings
section and not mixed.The exclusions from
formatters.exclusions[].paths
are converted tolinters.exclusions[].rules
automatically.There are only 2(3) flags:
Note, the
-E, --enable
flags works like--enable-only
for linters: it overrides the formatters defined inside the configuration file.It is the opposite of the behavior the
-E, --enable
flags of therun
command where this flag always adds linters to those defined inside the configuration file.In v2, the configuration of formatters will not be allowed inside the
linters-settings
section.Fixes #5296