Skip to content

feat!: move to ESM only #516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 20, 2025
Merged

feat!: move to ESM only #516

merged 12 commits into from
Jun 20, 2025

Conversation

43081j
Copy link
Contributor

@43081j 43081j commented Jun 15, 2025

Anyone who is using commonjs on node <20 will have to do one of the following:

  • move to esm
  • move toeslint.config.mjs
  • upgrade node

Everyone else should be unaffected.

This would be a new major of course.

Let me know if there's any other changes you think we should do

@bmish bmish mentioned this pull request Jun 15, 2025
@43081j
Copy link
Contributor Author

43081j commented Jun 15, 2025

One of the ci failures seems to be some funk with unsupported API imports

I'll figure it out tomorrow

@bmish bmish added the BREAKING CHANGE This change will require a major version bump label Jun 18, 2025
lib/index.js Outdated
Copy link
Member

Choose a reason for hiding this comment

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

This is generated by hand now? Authors of new rules usually forget to update this kind of thing so just want to confirm tests/index.js verifies everything is included here properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is

we could write a script to auto generate it if that helps

Copy link
Member

Choose a reason for hiding this comment

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

It's fine for now.

@michaelfaith
Copy link
Contributor

For the node 21-23 test failures, I wonder if it's just the typechecking taking slightly longer in that first run of the rule. The earlier node versions that succeeded, the runtime of that rule was pretty long too, and somewhat close to the 2s timeout

image

@43081j
Copy link
Contributor Author

43081j commented Jun 19, 2025

yeah im pretty sure its just how long it takes typescript to run

but im not sure what we can do about that other than increase the timeout for that specific test

Copy link
Member

@bmish bmish Jun 19, 2025

Choose a reason for hiding this comment

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

Thread about the test failure in Node 21-24.

Looks like it's just this rule only.

  1068 passing (7s)
  1 failing

  1) no-property-in-node
       valid
         'a' in window;:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/runner/work/eslint-plugin-eslint-plugin/eslint-plugin-eslint-plugin/tests/lib/rules/no-property-in-node.js)
      at process.processImmediate (node:internal/timers:478:21)

CC: @JoshuaKGoldberg who authored the rule in case he has any ideas

Copy link
Member

Choose a reason for hiding this comment

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

I'm updating TS dependencies just in case:

Copy link
Contributor

Choose a reason for hiding this comment

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

Even if it's not something that gets merged, it'd be interesting to know if extending the timeout does indeed allow the tests to pass, or if it's something more significant

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll try and repro it locally, when i get home

Copy link
Contributor

Choose a reason for hiding this comment

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

Running locally passes for me in half the timeout time (but still long). This is on node 22. So, that would suggest it's environment dependent and the type checking is running a bit longer on node 21-24.

image

Copy link
Member

Choose a reason for hiding this comment

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

Increasing the mocha timeout from 2000ms to 3000ms (--timeout 3000) didn't fix it. Unclear how long the timeout would need to be to accommodate this test file.

Copy link
Contributor

@michaelfaith michaelfaith Jun 19, 2025

Choose a reason for hiding this comment

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

I could take a stab at moving the repo to vitest (in place of mocha / c8) in a separate change, if that would help.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, would be open to a separate PR to move to vitest first, assuming that has advantages over the current setup.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@43081j this merged, if you want to rebase when you're able.

michaelfaith added a commit to michaelfaith/eslint-plugin-eslint-plugin that referenced this pull request Jun 19, 2025
This change moves the test runner from `mocha` + `nyc` to `vitest`.

In order to import `vitest` the tests had to be in esm, so I checked out everything under the `tests` folder from eslint-community#516 (leaving the source as it was).

I also moved the `eslint-rule-tester` out of the `tests/lib` folder and into its own `utils` folder.  That way vitest didn't treat it as a test.

Note: rather than using `vitest`'s preferred `v8` coverage reporter, I used the `istanbul` one, to ensure the coverages between old and new were the same.  I did notice that when I tried the `v8` coverage reporter, the coverage numbers were much less.  Something to consider as a follow-up change.  The v8 reporter *should* be more accurate, so the coverage may not be as high as it seems.  I'd recommend moving up to the `v8` reporter after the esm branch lands.
bmish pushed a commit that referenced this pull request Jun 19, 2025
* test: change test runner to vitest

This change moves the test runner from `mocha` + `nyc` to `vitest`.

In order to import `vitest` the tests had to be in esm, so I checked out everything under the `tests` folder from #516 (leaving the source as it was).

I also moved the `eslint-rule-tester` out of the `tests/lib` folder and into its own `utils` folder.  That way vitest didn't treat it as a test.

Note: rather than using `vitest`'s preferred `v8` coverage reporter, I used the `istanbul` one, to ensure the coverages between old and new were the same.  I did notice that when I tried the `v8` coverage reporter, the coverage numbers were much less.  Something to consider as a follow-up change.  The v8 reporter *should* be more accurate, so the coverage may not be as high as it seems.  I'd recommend moving up to the `v8` reporter after the esm branch lands.

* test: update fixtures tsconfig to use wildcard

* build: remove `globals` and packageManager config
@bmish bmish changed the title feat: move to ESM only feat!: move to ESM only Jun 20, 2025
Copy link
Member

@bmish bmish left a comment

Choose a reason for hiding this comment

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

Nice work!

@bmish bmish merged commit 9cd5af8 into eslint-community:main Jun 20, 2025
9 checks passed
@43081j 43081j deleted the esm-only branch June 20, 2025 14:24
@michaelfaith
Copy link
Contributor

Nice work @43081j 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BREAKING CHANGE This change will require a major version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants