Ember.js V5 - Cp Property

This automation modifies the .property() to move additional property dependencies directly into the main definition of an existing computed property.

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

Ember.js version higher or equal to 3.9.

Made by
Rajasegar Chandran
Rajasegar Chandran

Usage →

Codemod CLI:

intalling vs code extension tooltip icon
codemod ember/5/cp-property
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

.property() is a modifier that adds additional property dependencies to an existing computed property. This codemod moves the dependencies to the main computed property definition.

Example

Before:

const Person = EmberObject.extend({
	fullName: computed(function () {
		return `${this.firstName} ${this.lastName}`;
	}).property('firstName', 'lastName'),
});

After:

const Person = EmberObject.extend({
	fullName: computed('firstName', 'lastName', function () {
		return `${this.firstName} ${this.lastName}`;
	}),
});