Skip to content

feat: set languageOptions.globals in base config #1038

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

Closed
wants to merge 1 commit into from

Conversation

TatsuyaYamamoto
Copy link

eslint-plugin-svelte's config does not have languageOptions.globals.
https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/configs/flat/base.ts

I think many Svelte applications require globals.browser, so is it worth providing it in the base config?

references:

Copy link

changeset-bot bot commented Jan 22, 2025

⚠️ No Changeset found

Latest commit: 2c62af9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@baseballyama
Copy link
Member

Is my understanding correct that setting globals is necessary for frontend projects regardless of whether eslint-plugin-svelte is used or not? Even if eslint-plugin-svelte includes globals, other plugins or core rules that don’t rely on this plugin would still require globals.

In that case, users would need to configure globals anyway, meaning this PR doesn’t change what they need to do. Is that correct? @ota-meshi

@ota-meshi
Copy link
Member

I don't know if it's necessary for all users to use globals.browser.

I think globals.browser is necessary because *.svelte files run on the browser, but users who use SSR may not want to set globals.browser. I think users might prefer /* globals document */ depending on their project.
I think it might be better to mention globals.browser in the documentation instead of providing it from our config, because it's easier to turn on multiple identifiers from globals than to turn them off.
What do you think?

@baseballyama
Copy link
Member

This is exactly what I want to say.
Already I added this in #1041

https://github.com/sveltejs/eslint-plugin-svelte/pull/1041/files#diff-971a69e5ae264bfdae535d0c72902cc6f15a559f6d2dc650b78b473f6783c3caR45-R46

So close this PR now.
Thank you for your contribution @TatsuyaYamamoto !

@TatsuyaYamamoto TatsuyaYamamoto deleted the globals branch January 27, 2025 03:32
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