Ember 2.7 introduced a new deprecation to EmberBinding. This codemod aims to convert all existing uses of fooBinding: 'path.to.property'
to foo: alias('path.to.property')
and if the current file does not have the alias import the following line will also be added import { alias } from '@ember/object/computed';
npx ember2-x-codemods remove-binding path/of/files/ or/some**/*glob.js
# or
yarn global add ember2-x-codemods
ember2-x-codemods remove-binding path/of/files/ or/some**/*glob.js
node ./bin/cli.js remove-binding path/of/files/ or/some**/*glob.js
- alreadyHasComputedImport
- alreadyImported
- basic
- classBindings
- importWithNamedAndDefaultImport
- importWithoutNamedImport
- randomProperty
Input (alreadyHasComputedImport.input.js):
import { not } from '@ember/object/computed';
let obj = {
testBinding: 'this.app',
}
Output (alreadyHasComputedImport.output.js):
import { not, alias } from '@ember/object/computed';
let obj = {
test: alias('this.app'),
}
Input (alreadyImported.input.js):
import { alias } from '@ember/object/computed';
let obj = {
testBinding: 'this.app',
}
Output (alreadyImported.output.js):
import { alias } from '@ember/object/computed';
let obj = {
test: alias('this.app'),
}
Input (basic.input.js):
let obj = {
testBinding: 'this.app',
}
Output (basic.output.js):
import { alias } from '@ember/object/computed';
let obj = {
test: alias('this.app'),
}
Input (classBindings.input.js):
let obj = {
classBindings: ['class'],
}
Output (classBindings.output.js):
let obj = {
classBindings: ['class'],
}
importWithNamedAndDefaultImport
Input (importWithNamedAndDefaultImport.input.js):
import Computed, { not } from '@ember/object/computed';
let obj = {
testBinding: 'this.app',
};
Output (importWithNamedAndDefaultImport.output.js):
import Computed, { not, alias } from '@ember/object/computed';
let obj = {
test: alias('this.app'),
};
Input (importWithoutNamedImport.input.js):
import Computed from '@ember/object/computed';
let obj = {
testBinding: 'this.app',
};
Output (importWithoutNamedImport.output.js):
import Computed, { alias } from '@ember/object/computed';
let obj = {
test: alias('this.app'),
};
Input (randomProperty.input.js):
let obj = {
randomProperty: 'this.app',
}
Output (randomProperty.output.js):
let obj = {
randomProperty: 'this.app',
}