️ Repo: Convert remaining `lib/cli/` files to ESM
Author: JoshuaKGoldbergCreated May 16, 2026Updated Sep 16, 2026
Labelsstatus: accepting prsarea: repository tooling
Sub-issue of #5400 (Switch from CJS to ESM internally).
lib/cli/cli.mjs was converted in #5899. The following yargs command handler and helper files remain in CJS:
Files to convert
lib/cli/collect-files.js: has arequire.resolve()lib/cli/config.js: has arequire.resolve()lib/cli/run.jslib/cli/run-helpers.js: has arequire.resolve()lib/cli/watch-run.js: intentionally callsrequire()after a cache clear
lib/cli/index.js is an intentional CJS shim (module.exports = require("./cli.mjs")) and can remain CJS until the very end of the migration.
Notes
Per AGENTS.md CJS-to-ESM conventions:
- Prefer named exports over
export default - Rename each file from
.jsto.mjs - Update consumers to use destructured
require("./file.mjs") - These files depend on
lib/mocha.js— converting #5966 first is recommended
Source: mochajs/mocha