Make no-json-stringify-set-or-map binding-aware to avoid cross-scope name collisions - #54301
Merged
pelikhan merged 3 commits intoAug 20, 2026
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix no-json-stringify-set-or-map variable tracking by scope
Make Aug 20, 2026
no-json-stringify-set-or-map binding-aware to avoid cross-scope name collisions
pelikhan
marked this pull request as ready for review
August 20, 2026 18:02
pelikhan
deleted the
copilot/eslint-factory-fix-no-json-stringify-issue
branch
August 20, 2026 18:05
Contributor
There was a problem hiding this comment.
Pull request overview
Makes the ESLint rule resolve Set/Map variables by lexical binding rather than identifier name.
Changes:
- Adds scope-aware resolution for
constSet/Map bindings. - Adds regression tests for cross-scope name collisions and declaration order.
Show a summary per file
| File | Description |
|---|---|
eslint-factory/src/rules/no-json-stringify-set-or-map.ts |
Resolves the exact variable binding before reporting. |
eslint-factory/src/rules/no-json-stringify-set-or-map.test.ts |
Covers same-name bindings across scopes. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
5 tasks
Contributor
|
🎉 This pull request is included in a new release. Release: |
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.
no-json-stringify-set-or-mappreviously tracked Set/Map candidates by bare identifier name at file scope, so same-named variables in different lexical scopes could be misclassified. This change resolvesJSON.stringify(x)againstx’s actual binding before deciding whether it was initialized asnew Set(...)ornew Map(...).Scope-aware binding resolution
Map<string, "Set" | "Map">tracking with lexical lookup via ESLint scope (sourceCode.getScope(...)+ variable defs).JSON.stringify(identifier), the rule now checks the specific resolved binding and flags only when that binding is aconstinitialized from globalSet/Mapconstruction.JSON.stringify(new Set(...))/new Map(...)) remain unchanged.Regression coverage for same-name variables across scopes
seen, where one isnew Set(...)and the other is a plain object.