Page MenuHomePhabricator

[SPIKE] Replace uses of `$.extend` in Wikibase with correct applications of `Object.assign`
Closed, ResolvedPublic

Description

In T377777 we upgraded eslint-config-wikimedia in Wikibase to 0.28.2. This version would normally have included the no-jquery/no-extend rule that replaces usages of $.extend with Object.assign. Unfortunately, Object.assign is not a drop-in replacement for $.extend. To allow the upgrade to go through, the rule has been disabled in Wikibase, but we want to enable the rule again.

Object.assign differs in semantics from a shallow (default) $.extend in that:

  • Object.assign does not copy undefined values from the source to the target object
  • Object.assign only acts on own properties - it does not copy properties inherited from the object prototype.

Audit the 73 uses of $.extend in the Wikibase repository and replace them with appropriate uses of Object.assign (plus Object.create for the case of copying inherited properties). Re-enable the disabled linting rule no-jquery/no-extend.

Acceptance Criteria

  • Depending on the result of an initial spike, either this ticket is broken down or it the following acceptance criteria are fulfilled
  • All uses of $.extend have been removed from the Wikibase codebase
  • All tests pass and Wikibase continues to work as before
  • The no-jquery/no-extend rule is enabled again for the codebase

TIMEBOX: 8 hrs

Event Timeline

ItamarWMDE subscribed.

Prio Notes:

Impact AreaAffected
production / end usersno
monitoringno
development effortsyes
onboarding effortsno
additional stakeholdersno
ItamarWMDE renamed this task from Replace uses of `$.extend` in Wikibase with correct applications of `Object.assign` to [SW] Replace uses of `$.extend` in Wikibase with correct applications of `Object.assign`.Dec 6 2024, 11:56 AM
ItamarWMDE renamed this task from [SW] Replace uses of `$.extend` in Wikibase with correct applications of `Object.assign` to [SPIKE] Replace uses of `$.extend` in Wikibase with correct applications of `Object.assign`.Dec 12 2024, 11:46 AM
ItamarWMDE updated the task description. (Show Details)

Change #1131284 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] Replace class definitions that use $.extend with native definitions

https://gerrit.wikimedia.org/r/1131284

Change #1131317 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] Replace option assignments that use $.extend with Object.assign

https://gerrit.wikimedia.org/r/1131317

Change #1131650 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] Some JS refactoring

https://gerrit.wikimedia.org/r/1131650

Change #1131654 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] A few more files

https://gerrit.wikimedia.org/r/1131654

Change #1131671 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] More!

https://gerrit.wikimedia.org/r/1131671

Change #1131650 abandoned by Arthur taylor:

[mediawiki/extensions/Wikibase@master] Some JS refactoring

Reason:

not needed

https://gerrit.wikimedia.org/r/1131650

Change #1131654 abandoned by Arthur taylor:

[mediawiki/extensions/Wikibase@master] A few more files

Reason:

not needed

https://gerrit.wikimedia.org/r/1131654

Change #1131671 abandoned by Arthur taylor:

[mediawiki/extensions/Wikibase@master] More!

Reason:

not needed

https://gerrit.wikimedia.org/r/1131671

Change #1131687 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] Replace some miscellaneous $.extend usages with Object.assign

https://gerrit.wikimedia.org/r/1131687

Change #1131707 had a related patch set uploaded (by Arthur taylor; author: Arthur taylor):

[mediawiki/extensions/Wikibase@master] Re-enable the no-jquery/no-extend eslint rule

https://gerrit.wikimedia.org/r/1131707

Change #1131284 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Replace class definitions that use $.extend with native definitions

https://gerrit.wikimedia.org/r/1131284

Change #1131317 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Replace option assignments that use $.extend with Object.assign

https://gerrit.wikimedia.org/r/1131317

Change #1131687 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Replace some miscellaneous $.extend usages with Object.assign

https://gerrit.wikimedia.org/r/1131687

Change #1131707 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Re-enable the no-jquery/no-extend eslint rule

https://gerrit.wikimedia.org/r/1131707

@ArthurTaylor, could you please check if your patches caused T390949.

Final bits of this spike will be handled in T390181 with the bug introduced handled in T390949