Skip to content

feat: display linters help as JSON #5209

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

Merged
merged 3 commits into from
Dec 9, 2024
Merged

Conversation

ldez
Copy link
Member

@ldez ldez commented Dec 9, 2024

Adds the option --json to the command help linters.

Some examples of the usage

Gets a linter by name:

go run ./cmd/golangci-lint/ help linters --json | jq '[ .[] | select(.name=="nolintlint") ]'

Gets all the "fast" linters:

go run ./cmd/golangci-lint/ help linters --json | jq '[ .[] | select(.fast) ]'

Gets all the "slow" linters:

go run ./cmd/golangci-lint/ help linters --json | jq '[ .[] | select(.fast==false) ]'

Gets all linters with autofix:

go run ./cmd/golangci-lint/ help linters --json | jq '[ .[] | select(.autoFix==true) ]'

Gets all the "slow" linters with autofix:

 go run ./cmd/golangci-lint/ help linters --json | jq '[ .[] | select(.autoFix==true and .fast==false) ]'

Gets all linters with a specific preset:

go run ./cmd/golangci-lint/ help linters --json | jq '[ .[] | select(any(.presets[]; . == "style")) ]'

Gets all linters added in a specific version:

go run ./cmd/golangci-lint/ help linters --json | jq '[ .[] | select(.since=="v1.62.0") ]'

Gets all linter names:

go run ./cmd/golangci-lint/ help linters --json | jq '[ .[].name ]'

Gets all the names of linters enabled by default:

go run ./cmd/golangci-lint/ help linters --json | jq '[ .[] | select(.enabledByDefault==true) ] | map(.name)'

Gets all the names of "slow" linter with autofix:

go run ./cmd/golangci-lint/ help linters --json | jq '[ .[] | select(.autoFix==true and .fast==false) ] | map(.name)' 

Gets all the names of linter inside a specific preset:

go run ./cmd/golangci-lint/ help linters --json | jq '[ .[] | select(any(.presets[]; . == "bugs")) ] | map(.name)'

Related to #5207

@ldez ldez added enhancement New feature or improvement area: CLI Related to CLI labels Dec 9, 2024
@ldez ldez added this to the next milestone Dec 9, 2024
@ldez ldez requested a review from alexandear December 9, 2024 20:04
@ldez ldez merged commit a27f475 into golangci:master Dec 9, 2024
15 checks passed
@ldez ldez deleted the feat/help-json branch December 9, 2024 21:13
@ldez ldez modified the milestones: next, v1.63 Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: CLI Related to CLI enhancement New feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants