JavaScript

JavaScript

Made by DeepSource

Should not use Arrow functions JS-0774

Bug risk
Minor
ember

Arrow functions should not be used in computed properties because they are unable to access other properties (using this.property) of the same object. Accidental usage can thus lead to bugs.

Bad Practice

import EmberObject, { computed } from '@ember/object';

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

Recommended

import EmberObject, { computed } from '@ember/object';

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