Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 996 Bytes

no-try-invoke.md

File metadata and controls

38 lines (26 loc) · 996 Bytes

no-try-invoke

✅ The "extends": "plugin:ember/recommended" property in a configuration file enables this rule.

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