Skip to content

Resolve WebdriverIO services, local runner and community reporters - #2309

Merged
webpro merged 4 commits into
webpro-nl:mainfrom
clean99:contrib/knip-wdio-plugin-names
Nov 11, 2026
Merged

webpro merged 4 commits into
webpro-nl:mainfrom
clean99:contrib/knip-wdio-plugin-names

Conversation

@clean99

@clean99 clean99 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

WebdriverIO loads the runner, framework, reporters and services through initializePlugin: a scoped name is imported as is, any other name as @wdio/<name>-<type> and then wdio-<name>-<type>. The plugin skipped runner: 'local' and services, and always used the @wdio/ scope for reporters. So @wdio/local-runner and service packages are reported unused, and with reporters: ['obsidian'] (wdio-obsidian-service's setup) Knip reports wdio-obsidian-reporter unused next to an unlisted @wdio/obsidian-reporter, which doesn't exist. Projects work around it in ignoreDependencies, e.g. ansible/vscode-ansible.

All four now go through the same lookup. The wdio- package is picked only when it's declared in the workspace's or the root package.json and the @wdio/ one isn't. Plugin classes, objects and absolute paths are skipped.

The existing fixture now has a local runner, two services and a community reporter, and a new workspace fixture declares the community packages in the root package.json; both tests fail with only the plugin source reverted. On saberzero1/motions with its wdio ignoreDependencies removed, and on flowing-abyss/obsidian-tabbed with webdriver-io.config pointed at its tests/e2e configs in place of the ignores, the unused @wdio/local-runner, wdio-obsidian-reporter and the unlisted @wdio/obsidian-reporter are gone (plus @wdio/appium-service in the second), and nothing else changes.

WebdriverIO loads every runner, framework, reporter and service name
through initializePlugin: scoped names are imported as is, other names
as @wdio/<name>-<type> and then wdio-<name>-<type>. The plugin skipped
`runner: 'local'` and `services`, and always mapped reporters to the
@wdio/ scope, so @wdio/local-runner and service packages were reported
unused, and a community reporter such as `obsidian` was reported unused
next to an unlisted @wdio/obsidian-reporter that does not exist.

Pick the community package when it is the one declared in package.json.
@pkg-pr-new

pkg-pr-new Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/knip@2309
npm i https://pkg.pr.new/@knip/language-server@2309
npm i https://pkg.pr.new/@knip/mcp@2309

commit: 7fc1431

WebdriverIO imports @wdio/<name>-<type> and falls back to
wdio-<name>-<type> when that is not installed. Ask the resolver the
same question from the config file's directory instead of reading the
workspace and root manifests, so core keeps crediting the declared
package, also in ancestor workspaces.
WebdriverIO uses the local runner when `runner` is not set, so a config
without it needs @wdio/local-runner.

@webpro webpro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! I pushed two commits on top:

  • The plugin now picks the community package when it resolves and the @wdio/ one doesn't, as initializePlugin does, instead of reading package.json itself. Core already owns the declared dependencies and credits them in ancestor workspaces too. A package hoisted to the root resolves from a child workspace as well, so the separate workspace fixture is gone.
  • runner defaults to local, so @wdio/local-runner is no longer reported unused when runner isn't set.

@webpro
webpro merged commit 3ae2ae4 into webpro-nl:main Nov 11, 2026
33 checks passed
@webpro

webpro commented Nov 11, 2026

Copy link
Copy Markdown
Member

🚀 This pull request is included in v6.45.1. See Release 6.45.1 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

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.

2 participants