Skip to content

Support default parameters in plugin-activation-args - #167

Open
Yash990-bit wants to merge 2 commits into
jupyterlab:mainfrom
Yash990-bit:plugin-activation-args-default-params
Open

Yash990-bit wants to merge 2 commits into
jupyterlab:mainfrom
Yash990-bit:plugin-activation-args-default-params

Conversation

@Yash990-bit

Copy link
Copy Markdown
Contributor

Close #166

Summary

Fixes a false positive in plugin-activation-args where activation functions using default parameter values (e.g. trans: ITranslator | null = null) were erroneously reported for missing arguments and incorrect argument counts.

Background & Cause

In src/rules/plugin-activation-args.ts, extractFunctionInfo filtered fn.params with:

const params = fn.params.filter(
  (param): param is TSESTree.Identifier => param.type === 'Identifier'
);

Copilot AI balanced review requested due to automatic review settings October 28, 2026 16:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The initializer shortcut incorrectly suppresses optionalNotNullable for explicitly non-nullable parameters, allowing the activation body to receive a missing service while assuming a non-nullable type.

1 open issue
What changed in this PR

This PR addresses #166 by teaching plugin-activation-args to recognize defaulted activation parameters, avoiding false missing-argument and argument-count reports.

Changes:

  • Extract parameter names and types from default-value assignments while preserving parameter positions.
  • Add initializer-based nullability handling.
  • Add regression tests for defaulted parameters, referenced functions, method shorthand, and invalid token types or ordering.
File Description
tests/​jupyter-plugin-activation-args.test.ts Adds valid and invalid cases covering defaulted activation parameters.
src/​rules/​plugin-activation-args.ts Handles defaulted parameters during extraction and updates nullability checks.

Review effort: Balanced

Comment thread src/rules/plugin-activation-args.ts Outdated

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

plugin-activation-args: false positive when activate parameters have default values

2 participants