Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 1.04 KB

no-try-invoke.md

File metadata and controls

40 lines (27 loc) · 1.04 KB

ember/no-try-invoke

💼 This rule is enabled in the ✅ recommended config.

This rule will catch and prevent the use of tryInvoke.

Rule Details

This rule aims to disallow the usage of tryInvoke. Native JavaScript language now supports optional chaining and developers are encouraged to use optional chaining ?.() instead.

Examples

Examples of incorrect code for this rule:

import { tryInvoke } from '@ember/utils';

class FooComponent extends Component {
  foo() {
    tryInvoke(this.args, 'bar', ['baz']);
  }
}

Examples of correct code for this rule:

class FooComponent extends Component {
  foo() {
    this.args.bar?.('baz');
  }
}

References