Skip to content

Read .mocharc.mjs in the Mocha plugin - #2259

Merged
webpro merged 1 commit into
webpro-nl:mainfrom
SwastikTripathi:mocha-config-mjs
Oct 30, 2026
Merged

webpro merged 1 commit into
webpro-nl:mainfrom
SwastikTripathi:mocha-config-mjs

Conversation

@SwastikTripathi

Copy link
Copy Markdown
Contributor

Mocha reads .mocharc.mjs as well as .mocharc.{cjs,js,yaml,yml,jsonc,json} (CONFIG_FILES in lib/cli/config.cjs, mocha 12.0.3). The Mocha plugin only listed .mocharc.{js,cjs,json,jsonc,yml,yaml}, so with an .mjs config its spec, file, require and reporter entries were never read: spec files showed up as unused files and an external reporter as an unused dependency.

This adds mjs to the config pattern.

New fixture plugins/mocha-config-mjs has spec and reporter in .mocharc.mjs (plus the same node_modules/mocha stub as the mocha2 fixture). Without the change the test fails (specs/example.test.js is reported as unused); with it the spec file and mocha-junit-reporter are picked up and only unrelated.js is reported.

Checks: node scripts/run-test.js --runtime node (1627 pass, after pnpm build), pnpm lint, oxfmt --check on the changed files.

I used Claude Code (AI) to write this change, and checked mocha's source for the supported config file names.

πŸ€– Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Oct 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: c4ca8a6

@webpro

webpro commented Oct 30, 2026

Copy link
Copy Markdown
Member

Thank you! Next time, for such a small change we can probably reuse existing fixture folder.

@webpro
webpro merged commit 16fee14 into webpro-nl:main Oct 30, 2026
32 checks passed
@webpro

webpro commented Oct 31, 2026

Copy link
Copy Markdown
Member

πŸš€ This pull request is included in v6.44.1. See Release 6.44.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