Skip to content

fix(plugins): credit NestJS framework-dispatched lifecycle/handler methods as used#853

Closed
BartWaardenburg wants to merge 3 commits into
mainfrom
fix/issue-843-nestjs-lifecycle-members
Closed

fix(plugins): credit NestJS framework-dispatched lifecycle/handler methods as used#853
BartWaardenburg wants to merge 3 commits into
mainfrom
fix/issue-843-nestjs-lifecycle-members

Conversation

@BartWaardenburg
Copy link
Copy Markdown
Collaborator

Replaced the define_plugin! macro in crates/core/src/plugins/nestjs.rs with a manual impl Plugin that returns used_class_member_rules(). Added 11 implements-scoped rules covering NestModule.configure, the five lifecycle hook interfaces (OnModuleInit, OnModuleDestroy, OnApplicationBootstrap, BeforeApplicationShutdown, OnApplicationShutdown), and the five handler dispatch interfaces (CanActivate, NestInterceptor, PipeTransform, ExceptionFilter, NestMiddleware). Added 7 unit tests including a regression test that asserts configure is credited as used for a NestModule implementor while a genuinely-unused method on the same class is not credited.

Review

Verdict: SHIP

  • Verified, non-blocking: the lifecycle rules credit all five lifecycle method names on a class implementing ANY single lifecycle interface (e.g. implements OnModuleInit also credits onModuleDestroy). This is intentional and more correct (NestJS dispatches lifecycle hooks by duck-typed method-name presence, not interface declaration) and is documented in the doc/inline comments, so it reduces false positives rather than introducing false negatives. Handler-dispatch interfaces are correctly single-method-scoped.
  • Out of scope for the diff but observed in the working tree: an unrelated modification to crates/core/src/plugins/oxlint.rs (parallel-agent / pre-existing change). The patch itself does not touch it.

Closes #843

- Fix clippy uninlined_format_args in nestjs test
- Add real end-to-end regression test + fixture (fails before / passes after)
- Document detection behavior in detection.md and CHANGELOG
@BartWaardenburg BartWaardenburg force-pushed the fix/issue-843-nestjs-lifecycle-members branch from 041dd6e to e5c09d8 Compare June 1, 2026 22:01
@BartWaardenburg
Copy link
Copy Markdown
Collaborator Author

Landed on main via maintainer direct-to-main flow, squashed into 4a5d0b2. The linked issue is fixed on main; closing this PR as redundant.

@BartWaardenburg BartWaardenburg deleted the fix/issue-843-nestjs-lifecycle-members branch June 2, 2026 09:09
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.

NestJS framework-dispatched lifecycle/handler methods flagged as unused-class-member

1 participant