-
-
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 linter exclusions system #5339
Open
ldez
wants to merge
27
commits into
golangci:master
Choose a base branch
from
ldez:feat/linter-exclusions
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.
Open
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
ldez
added
area: config
Related to .golangci.yml and/or cli options
area: exclusions
labels
Jan 20, 2025
ldez
force-pushed
the
feat/linter-exclusions
branch
from
January 20, 2025 17:19
aed5c27
to
a96fcf4
Compare
ccoVeille
reviewed
Jan 21, 2025
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.
This PR is a part of the v2: #5300
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 section for now: I think it is better to handle that when all the v2 proposals are managed to avoid multiple migrations.
The main goal is to replace
issue.exclude-xxx
options withlinters.exclusions
section.There is a new option
linters.exclusions.warn-unused
that emits a warning if alinters.exclusions.rules
orlinters.exclusions.paths
is unused.There is a new option
run.relative-path-mode
with 4 modes:gomod
: paths are relative to thego.mod
gitroot
: paths are relative to the git root.cfg
: paths are relative to the configuration position.wd
(v1 default): paths are relative to the location where golangci-lint is run.This option controls all the path-related options:
issues.exclude-rules[].path
issues.exclude-rules[].path-except
issues.exclude-dirs
issues.exclude-files
severity.rules[].path
severity.rules[].path-except
custom[].path
linters.exclusions.paths
linters.exclusions.rules[].path
linters.exclusions.rules[].path-except
The linter configuration related to paths should use the placeholder
${base-path}
:gocritic
(gocritic.ruleguard.rules
)depguard
(rules[].files
)goheader
(goheader.template-path
)errcheck
: the optionerrcheck.exclude
has been deprecated since golangci-lint v1.42 so I didn't add the support of the placeholder.With the new option
run.relative-path-mode
, you can now run golangci-lint inside a package and the configuration related to file paths will work.In v2,
output.path-prefix
will be used only for output and not for matching, and the default relative path mode will begomod
orcfg
(notwd
like today).More details about the topic are inside the issues:
configuration overview
Fixes #5297
Related to #5298
Fixes #3953
Fixes #3717
Fixes #1178
Closes #3748