fix: add the missing globals we use to the playground templates#1306
Merged
fix: add the missing globals we use to the playground templates#1306
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns MongoDB playground templates with the project’s existing pattern of declaring the runtime globals used in playground files (e.g., use, db) so ESLint doesn’t flag newly created playgrounds as no-undef in certain workspace/config resolution scenarios.
Changes:
- Add
/* global use, db */to the “insert document” playground template. - Add
/* global use */to the “from database tree item” playground template. - Add
/* global use, db */to the “from collection tree item” playground template.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/templates/playgroundInsertDocumentTemplate.ts | Adds missing ESLint globals directive for use and db in the generated playground content. |
| src/templates/playgroundFromDatabaseTreeItemTemplate.ts | Adds missing ESLint globals directive for use in the generated playground content. |
| src/templates/playgroundFromCollectionTreeItemTemplate.ts | Adds missing ESLint globals directive for use and db in the generated playground content. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gagik
approved these changes
Apr 13, 2026
himanshusinghs
approved these changes
Apr 13, 2026
nirinchev
approved these changes
Apr 13, 2026
Anemy
approved these changes
Apr 13, 2026
| export const playgroundFromCollectionTreeItemTemplate = createTemplate( | ||
| (databaseName, collectionName) => `// MongoDB Playground | ||
| (databaseName, collectionName) => `/* global use, db */ | ||
| // MongoDB Playground |
Member
There was a problem hiding this comment.
Since this is the same string in every playground, would it make sense for us to put it into a helper function? So all of them then call that templateHeader. Not a blocker, fine as is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I noticed that this started happening where some newly created playgrounds stated off red:
So far it seems to only happen if vscode's active workspace is vscode itself. The error is coming from eslint and I guess at some point something changed in how it resolves the eslint config or in vscode's config or it picks up vscode's config..
Probably not really an issue for most real users, but I did notice that all our playground templates except three have the
/* global use, db */(or whatever globals get used in the template) pattern at the top and that fixes it.Might as well align those?
Four options: