Skip to content

refactor: replace Object.assign with spread syntax#7122

Open
eatyourgreens wants to merge 1 commit into
zooniverse:mainfrom
eatyourgreens:patch-1
Open

refactor: replace Object.assign with spread syntax#7122
eatyourgreens wants to merge 1 commit into
zooniverse:mainfrom
eatyourgreens:patch-1

Conversation

@eatyourgreens

@eatyourgreens eatyourgreens commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

Replace Object.assign with the much faster spread operator in the Classification model.

Please request review from @zooniverse/frontend team or an individual member of that team.

Package

lib-classifier

How to Review

No functional changes here. This modernises the classification code but doesn’t change how classifications work.

Checklist

PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.

General

  • Tests are passing locally and on Github
  • Documentation is up to date and changelog has been updated if appropriate
  • You can pnpm panic && pnpm bootstrap
  • FEM works in all major desktop browsers: Firefox, Chrome, Edge, Safari (Use Browserstack account as needed)
  • FEM works in a mobile browser

General UX

Example Staging Project: i-fancy-cats

  • All pages of a FEM project load: Home Page, Classify Page, and About Pages
  • Can submit a classification
  • Can sign-in and sign-out
  • The component is accessible

Refactoring

  • The PR creator has described the reason for refactoring.
  • The refactored component(s) continue to work as expected.

Replace `Object.assign` with the much faster spread operator in the `Classification` model.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 modernizes the Classification mobx-state-tree model snapshot handling by replacing Object.assign usage with object spread syntax, keeping snapshot copying semantics the same while simplifying the code.

Changes:

  • Update toSnapshot() to return a spread-copied snapshot with annotations overridden as an array.
  • Replace Object.assign({}, snapshot) with { ...snapshot } in preProcessSnapshot and postProcessSnapshot.

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

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.

2 participants