Home

Awesome

Ember on codemod

To conform to this linting rule, this codemod will replace uses of Ember.on with their method equivalent.

Changes

willChange

export default Component.extend({
  abc: on('didInsertElement', function () { /* custom logic */ }),  
});

will become

export default Component.extend({
  didInsertElement() { /* custom logic */ }
});

wontChange

non-lifecycle events

export default Ember.Component.extend({
  onSomething: Ember.on('something', function() {

  }),
});

initted observers

cos probably done for a reason and observer needs manual refactoring and proper testing

export default Ember.Component.extend({
  a: Ember.on('init', Ember.observer('something', function() {

  })),
});

with params

soon to be deprecated, should remain as a linting error until refactored

export default Ember.Component.extend({
  onDidReceiveAttrs: Ember.on('didReceiveAttrs', function({ newAttrs, oldAttrs }) {

  }),
});