Skip to content

Add a directive for ignoring imports - #36

Merged
Calsign merged 1 commit into
Calsign:mainfrom
mrkkrp:ignore-import
Mar 27, 2026
Merged

Add a directive for ignoring imports#36
Calsign merged 1 commit into
Calsign:mainfrom
mrkkrp:ignore-import

Conversation

@mrkkrp

@mrkkrp mrkkrp commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Based on #34.

The motivation here is that sometimes certain internal crates re-export modules which looks to the plugin as if we are depending on those modules directly. It is desirable to have a mechanism for avoiding these false positives.

@mrkkrp mrkkrp changed the title Ignore import Add a directive for ignoring imports Mar 18, 2026
@mdeville

Copy link
Copy Markdown

@mrkkrp Hey,
Thanks a lot for this new directive :)
However I realized that it seems to apply the behavior automatically to sub-packages too.

If I add it to a BUILD.bazel file, then all BUILD.bazel files in sub-directories have their dependency removed.
I think it should only do it for the current file.

What do you think ?

@mrkkrp
mrkkrp force-pushed the ignore-import branch 2 times, most recently from b9e3c97 to c7767ba Compare March 21, 2026 07:43
@mrkkrp

mrkkrp commented Mar 21, 2026

Copy link
Copy Markdown
Contributor Author

Hey @mdeville, good catch! I have adjusted the PR to make the new directive local to the BUILD file where it is used. I have also adjusted the test accordingly.

@Calsign Calsign left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I normally expect directives to apply recursively to subdirectories. From the gazelle docs:

Directives apply in the directory where they are set and in subdirectories.

But there isn't an obvious way to override or undo this directive in a subpackage, so I suppose this OK.


gazelle_rust also has the import macro, i.e.:

#[gazelle::ignore]
use foo::bar;

but I can see a directive being useful as well.

@mrkkrp

mrkkrp commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

@Calsign I've rebased the PR.

@Calsign
Calsign merged commit 7eef6bb into Calsign:main Mar 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants