Skip to content

fix: add the missing globals we use to the playground templates#1306

Merged
lerouxb merged 1 commit intomainfrom
global-use-db-templates
Apr 13, 2026
Merged

fix: add the missing globals we use to the playground templates#1306
lerouxb merged 1 commit intomainfrom
global-use-db-templates

Conversation

@lerouxb
Copy link
Copy Markdown
Member

@lerouxb lerouxb commented Apr 13, 2026

I noticed that this started happening where some newly created playgrounds stated off red:

Screenshot 2026-04-13 at 11 41 13 Screenshot 2026-04-13 at 11 55 25

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:

  • it is effectively the user's eslint config breaking it here, so we can decide it is their responsibility
  • we can add all the globals they could ever use, add eslint config to ignore unused globals or add eslint config to just turn off validation for using undefined globals, etc. (some variation or combination of those)
  • we could not make playgrounds .js files but rather make a new format that just happens to be using js parsers under the hood and then eslint or similar cannot accidentally match it
  • we could just live with it ;)

@lerouxb lerouxb added the no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) label Apr 13, 2026
Copilot AI review requested due to automatic review settings April 13, 2026 11:12
@lerouxb lerouxb requested a review from a team as a code owner April 13, 2026 11:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

export const playgroundFromCollectionTreeItemTemplate = createTemplate(
(databaseName, collectionName) => `// MongoDB Playground
(databaseName, collectionName) => `/* global use, db */
// MongoDB Playground
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@lerouxb lerouxb merged commit 2cc9b50 into main Apr 13, 2026
31 of 33 checks passed
@lerouxb lerouxb deleted the global-use-db-templates branch April 13, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants