Skip to content
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

Add vitest globals #274

Merged
merged 3 commits into from
Dec 18, 2024
Merged

Add vitest globals #274

merged 3 commits into from
Dec 18, 2024

Conversation

yongholeeme
Copy link
Contributor

@yongholeeme yongholeeme commented Dec 17, 2024

Hello @sindresorhus! I'm opening a PR to add vitest globals.

A similar PR was previously opened in #210, but it was closed due to the package's management policy at that time (as discussed in #82). However, since ESLint no longer bundles globals and new environments are now being added to the globals package, I believe it's appropriate to open this request.

I've added these by referencing the official Vitest globals definition file: https://github.com/vitest-dev/vitest/blob/main/packages/vitest/globals.d.ts.

globals.json Show resolved Hide resolved
@yongholeeme yongholeeme force-pushed the main branch 2 times, most recently from e8e811e to 1ef7d84 Compare December 17, 2024 10:35
@yongholeeme yongholeeme requested a review from fisker December 17, 2024 10:36
@fisker
Copy link
Collaborator

fisker commented Dec 17, 2024

As I tested, vitest package can't be imported, it seems there is no way to get those from vitest package, but vitest/globals contains types, is it possible to assert they are equal here https://github.com/sindresorhus/globals/blob/main/index.test-d.ts?

@yongholeeme
Copy link
Contributor Author

As I tested, vitest package can't be imported, it seems there is no way to get those from vitest package, but vitest/globals contains types, is it possible to assert they are equal here https://github.com/sindresorhus/globals/blob/main/index.test-d.ts?

@fisker, as you mentioned, vitest/globals contains types in globals.d.ts. However, since these are declared as global types, I think it's difficult to assert their equality.

@yongholeeme
Copy link
Contributor Author

yongholeeme commented Dec 17, 2024

@fisker, I've updated the way of generating vitest globals by using @vitest/eslint-plugin (see https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/src/index.ts#L269-L285). However, it's not identical to vitest/globals. As this is the official package, I think this approach would be better for maintaining globals, and I'll create an issue to request alignment between them. I've synchronized with PR vitest-dev/eslint-plugin-vitest#599 and updated it. (dd5cdcb)

@sindresorhus sindresorhus merged commit 06a5723 into sindresorhus:main Dec 18, 2024
2 checks passed
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.

3 participants