Skip to content

Latest commit

 

History

History
165 lines (132 loc) · 4.48 KB

File metadata and controls

165 lines (132 loc) · 4.48 KB

remove-binding

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';

Usage

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

Local Usage

node ./bin/cli.js remove-binding path/of/files/ or/some**/*glob.js

Input / Output


alreadyHasComputedImport

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'),
}

alreadyImported

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'),
}

basic

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'),
}

classBindings

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'),
};

importWithoutNamedImport

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'),
};

randomProperty

Input (randomProperty.input.js):

let obj = {
  randomProperty: 'this.app',
}

Output (randomProperty.output.js):

let obj = {
  randomProperty: 'this.app',
}