Skip to content

Conversation

Offroaders123
Copy link

PR Checklist

Overview

This is the (nearly) complete migration to the ES6 class syntax, from the original constructor function implementation.

This was originally intended to include changes for two more files, but they both were having challenges with passing tests. Those were lib/mocha.js, and lib/reporters/base.js. As they seemingly will require more formatting than simple syntax changes, I am leaving them for a separate commit.

A concern of mine:
For the goal of diff clarity, I did not perform a Prettier format step. I am happy to add a second commit, which does the formatting separately!

Related to mochajs#5025

This is the (nearly) complete migration to the ES6 class syntax, from the original constructor function implementation.

This was originally intended to include changes for two more files, but they both were having challenges with passing tests. Those were `lib/mocha.js`, and `lib/reporters/base.js`. As they seemingly will require more formatting than simple syntax changes, I am leaving them for a separate commit.
Copy link

linux-foundation-easycla bot commented Oct 6, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Member

@mark-wiemer mark-wiemer left a comment

Choose a reason for hiding this comment

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

Looks very good, just a few small comments and questions :) thanks for this and for keeping the PR focused on one core issue!

If we are no longer using the inherits package, let's see if we can remove it from the repo entirely in this PR as well (package.json, etc.)

* @param {Function} fn
* @private
*/
Runner.immediately = global.setImmediate || process.nextTick;
Copy link
Member

Choose a reason for hiding this comment

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

please move this back up to line ~250, a tiny part of me is worried these values might be changed somewhere in the next 1000 lines :D

Copy link
Author

Choose a reason for hiding this comment

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

Ideally it would be able to stay there, I would wished it could have, too. But since ES2022 class field syntax isn't supported by the tooling we currently have, I'm not sure if there are any other ways to define them without moving it out of the ES6 class syntax scope (normal variable assignments aren't valid there).

@JoshuaKGoldberg
Copy link
Member

For the goal of diff clarity, I did not perform a Prettier format step. I am happy to add a second commit, which does the formatting separately!

Blurgh, yeah, this has been bugging me. I've been meaning to get us to a clean baseline for a while. Thanks for the reminder 😄. Sent: #5492 -> #5493.

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

The source code changes look great! You've hit the right patterns IMO. Just, the test failures show there's more work to be done:

  77) XUnit reporter
       event handlers
         on 'pending', 'pass' and 'fail' events
           should add test to tests called on 'end' event:
     TypeError: Class constructor XUnit cannot be invoked without 'new'
      at Context.<anonymous> (test/reporters/xunit.spec.js:188:15)
      at callFn (lib/runnable.js:111:584)
      ...

Thanks for getting started & making so much progress on this very tedious task! 🤎

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author waiting on response from OP or other posters - more information needed label Oct 6, 2025
Offroaders123 and others added 2 commits October 8, 2025 00:08
Co-authored-by: Mark Wiemer <[email protected]>
This is a second commit to the first part, which was committed just before this. I am not completely familiar with code review yet, so I may need some more practice with things overall.

Co-authored-by: Mark Wiemer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for author waiting on response from OP or other posters - more information needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Bug: remove util.inherits / convert to classes
3 participants