#5967·mocha

️ 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 a require.resolve()
  • lib/cli/config.js: has a require.resolve()
  • lib/cli/run.js
  • lib/cli/run-helpers.js: has a require.resolve()
  • lib/cli/watch-run.js: intentionally calls require() 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 .js to .mjs
  • Update consumers to use destructured require("./file.mjs")
  • These files depend on lib/mocha.js — converting #5966 first is recommended