Skip to content

refactor(linter/plugins): introduce methods for deep cloning JSON values#16962

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-16-refactor_linter_plugins_introduce_methods_for_deep_cloning_json_values
Dec 16, 2025
Merged

refactor(linter/plugins): introduce methods for deep cloning JSON values#16962
graphite-app[bot] merged 1 commit intomainfrom
12-16-refactor_linter_plugins_introduce_methods_for_deep_cloning_json_values

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 16, 2025

Add methods for deep cloning JSON values, objects, and arrays. These are used in the next PR (#16930).

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Dec 16, 2025
Copy link
Member Author

overlookmotel commented Dec 16, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
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

This PR introduces deep cloning functionality for JSON values, complementing the existing deep freeze utilities. The implementation adds three new functions that handle recursive cloning of JSON objects, arrays, and primitive values.

Key changes:

  • Added deepCloneJsonValue as the main entry point for cloning any JSON value
  • Implemented deepCloneJsonObject and deepCloneJsonArray for recursive cloning of complex types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overlookmotel overlookmotel self-assigned this Dec 16, 2025
@overlookmotel overlookmotel force-pushed the 12-16-refactor_linter_plugins_introduce_methods_for_deep_cloning_json_values branch from dfb2fbc to 2763b8f Compare December 16, 2025 16:27
@overlookmotel overlookmotel force-pushed the 12-16-refactor_linter_plugins_convert_global_properties_to_vars_with_tsdown_plugin_instead_of_manually branch from 1abbb33 to 1351d60 Compare December 16, 2025 16:27
@graphite-app graphite-app bot force-pushed the 12-16-refactor_linter_plugins_convert_global_properties_to_vars_with_tsdown_plugin_instead_of_manually branch 2 times, most recently from 1a6536f to d827a4a Compare December 16, 2025 16:46
@graphite-app graphite-app bot force-pushed the 12-16-refactor_linter_plugins_introduce_methods_for_deep_cloning_json_values branch from 2763b8f to 220c326 Compare December 16, 2025 16:47
@graphite-app graphite-app bot changed the base branch from 12-16-refactor_linter_plugins_convert_global_properties_to_vars_with_tsdown_plugin_instead_of_manually to graphite-base/16962 December 16, 2025 17:33
@graphite-app graphite-app bot force-pushed the 12-16-refactor_linter_plugins_introduce_methods_for_deep_cloning_json_values branch from 220c326 to b27b3c1 Compare December 16, 2025 17:40
@graphite-app graphite-app bot force-pushed the graphite-base/16962 branch from d827a4a to da509be Compare December 16, 2025 17:40
@graphite-app graphite-app bot changed the base branch from graphite-base/16962 to main December 16, 2025 17:41
@graphite-app graphite-app bot force-pushed the 12-16-refactor_linter_plugins_introduce_methods_for_deep_cloning_json_values branch from b27b3c1 to b1a8ac2 Compare December 16, 2025 17:41
@nrayburn-tech
Copy link
Collaborator

@overlookmotel
Copy link
Member Author

overlookmotel commented Dec 16, 2025

Thanks for your comment. I hadn't thought of that.

I don't know for sure either, but I imagine the manual implementation is probably faster, as JSON objects are much more constrained (simple) than what you can pass to structuredClone.

This isn't on a hot path, so not so important for perf. So I hope you'll forgive me if I just go with it as is.

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 16, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 16, 2025

Merge activity

…ues (#16962)

Add methods for deep cloning JSON values, objects, and arrays. These are used in the next PR (#16930).
@graphite-app graphite-app bot force-pushed the 12-16-refactor_linter_plugins_introduce_methods_for_deep_cloning_json_values branch from b1a8ac2 to 4c4de62 Compare December 16, 2025 23:03
@graphite-app graphite-app bot merged commit 4c4de62 into main Dec 16, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 12-16-refactor_linter_plugins_introduce_methods_for_deep_cloning_json_values branch December 16, 2025 23:09
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 16, 2025
@camc314
Copy link
Contributor

camc314 commented Dec 17, 2025

strucutredClone is really slow. 😓

https://benchmarklab.azurewebsites.net/Benchmarks/Show/31723/0/json-parse-vs-structuredclone-bigger-object

Not sure of the perf diff vs this implementation

@overlookmotel
Copy link
Member Author

Interesting. I added the manual clone impl from this PR to the benchmark. It's much faster.

bench

https://benchmarklab.azurewebsites.net/Benchmarks/ShowResult/622555

graphite-app bot pushed a commit that referenced this pull request Dec 17, 2025
Follow-on after #16962.

Small optimization to `deepCloneJsonObject`. Iterate through keys of `cloned` instead of `obj`.

Benchmark shows this is marginally faster (0.3%):

https://benchmarklab.azurewebsites.net/Benchmarks/ShowResult/622556
qinyuhang pushed a commit to qinyuhang/oxc that referenced this pull request Jan 22, 2026
…ues (oxc-project#16962)

Add methods for deep cloning JSON values, objects, and arrays. These are used in the next PR (oxc-project#16930).
qinyuhang pushed a commit to qinyuhang/oxc that referenced this pull request Jan 22, 2026
Follow-on after oxc-project#16962.

Small optimization to `deepCloneJsonObject`. Iterate through keys of `cloned` instead of `obj`.

Benchmark shows this is marginally faster (0.3%):

https://benchmarklab.azurewebsites.net/Benchmarks/ShowResult/622556
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments