Ember.js V5 - Object New Constructor

This codemod replaces all calls to new EmberObject() with EmberObject.create() and adds a constructor function to classes that extend from EmberObject so that the classes no longer extend from EmberObject.

Ember.js
jscodeshift
Estimated time saving
5 minutes/occurrence
Change mode
Autonomous
Applicability criteria

Ember.js version higher or equal to 3.6.

Made by
Rajasegar Chandran
Rajasegar Chandran

Usage →

Codemod CLI:

intalling vs code extension tooltip icon
codemod ember/5/object-new-constructor
copy CLI command icon

Codemod VS Code extension:

intalling vs code extension tooltip icon
vs code logo
Run in VS Code

Use/edit codemod in Codemod Studio:

intuita logo without text
Open in Codemod Studio

Description

new EmberObject() is deprecated in Ember.js v3.9 in favor of constructing instances of EmberObject and its subclasses. This codemod replaces all calls to new EmberObject() with EmberObject.create() and adds a constructor function to classes that extend from EmberObject so that the classes no longer extend from EmberObject.

Example

Before:

let obj1 = new EmberObject();
let obj2 = new EmberObject({ prop: 'value' });

const Foo = EmberObject.extend();
let foo = new Foo({ bar: 123 });

After:

let obj1 = EmberObject.create();
let obj2 = EmberObject.create({ prop: 'value' });

const Foo = EmberObject.extend();
let foo = new Foo({ bar: 123 });