Ember.js V5 - Cp Property Map

This automation adds extra property dependencies to computed properties like filter, map, and sort, automating the inclusion of an array of dependent keys as a second parameter.

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

Ember.js version higher or equal to 2.4.

Made by
Rajasegar Chandran
Rajasegar Chandran

Usage →

Codemod CLI:

intalling vs code extension tooltip icon
codemod ember/5/cp-property-map
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. For filter, map, and sort computed property macros, this codemod ensures they receive an array of additional dependent keys as a second parameter.

Example

Before:

const Person = EmberObject.extend({
	friendNames: map('friends', function (friend) {
		return friend[this.get('nameKey')];
	}).property('nameKey'),
});

After:

const Person = EmberObject.extend({
	friendNames: map('friends', ['nameKey'], function (friend) {
		return friend[this.get('nameKey')];
	}),
});