Skip to content

v2: Re-allow enabling formatters via --enable CLI option of run command #5664

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

Closed
2 of 3 tasks
LukasHeimann opened this issue Mar 31, 2025 · 4 comments
Closed
2 of 3 tasks
Labels
question Further information is requested

Comments

@LukasHeimann
Copy link

Welcome

How did you install golangci-lint?

Official binary

Your feature request related to a problem? Please describe

In v1, formatters were not separated from linters and could, without any configuration yaml, be enabled via the cli, e.g. like this:

golangling-ci run --enable goimports,gofmt,misspell,unconvert,revive 

After v2, I'm getting an error message:

Error: can't load config: goimports is a formatter
Failed executing command with error: can't load config: goimports is a formatter

@ldez's release blog post mentions that golanglint-ci run will run all formatters from the configuration file as well: https://ldez.github.io/blog/2025/03/23/golangci-lint-v2/#:~:text=The%20formatters%20defined%20in%20this%20section%20are%20automatically%20used%20as%20%E2%80%9Clinter%E2%80%9D%20when%20you%20run%20the%20command%20golangci%2Dlint%20run.

Thus, I would expect that the --enable flag of runalso allows to activate formatters.

Describe the solution you'd like

As before, adding formatters into run --enable should work without issues

Describe alternatives you've considered

Adding configuration files to each repository

Additional context

No response

Supporter

@LukasHeimann LukasHeimann added the enhancement New feature or improvement label Mar 31, 2025
Copy link

boring-cyborg bot commented Mar 31, 2025

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@LukasHeimann LukasHeimann changed the title v2: Re-allow enabling formatters via --enable CLI option v2: Re-allow enabling formatters via --enable CLI option of run command Mar 31, 2025
@alexandear
Copy link
Member

alexandear commented Mar 31, 2025

Hi, this has already been implemented in #5620 and is available in v2.0.2.

golangci-lint fmt --enable gofmt,goimports

@LukasHeimann
Copy link
Author

I've doublechecked the fmt command, but I explicitly mean the run here. As per the blog of the core maintainer, golangci-lint run should, if I have any active formatters in my config, also run the formatters.

Thus, passing them to golangci-lint run --enable gofmt via cli, they should also be loaded. Or the run command should have a separate flag for --enable-formatters, so that there is more clear separation (that seems to be a major design goal of v2).

Background: I'm running the reviewdog integration of this, and that is only calling the run command.

@ldez ldez added question Further information is requested and removed enhancement New feature or improvement labels Mar 31, 2025
@ldez
Copy link
Member

ldez commented Mar 31, 2025

Hello,

Inside v2, a formatter is not a linter.

The formatters are related to the new command golangci-lint fmt.
They are "converted" as linter for convenience, but their main usage is related to this command.

So, a configuration file is required in this context.

@ldez ldez closed this as completed Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants