Skip to content

Latest commit

 

History

History
46 lines (28 loc) · 1.62 KB

no-incorrect-computed-macros.md

File metadata and controls

46 lines (28 loc) · 1.62 KB

no-incorrect-computed-macros

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

🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

This rule attempts to find incorrect usages of computed property macros, such as calling them with the incorrect number of arguments.

It currently only catches using the and and or macros with the wrong number of arguments, but may be expanded later.

Examples

Examples of incorrect code for this rule:

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

export default Component.extend({
  macroPropertyAnd: and('someProperty'), // Not enough arguments.

  macroPropertyOr: or('someProperty') // Not enough arguments.
});

Examples of correct code for this rule:

import { and, or, readOnly } from '@ember/object/computed';

export default Component.extend({
  macroPropertyReadOnly: readOnly('someProperty'),

  macroPropertyAnd: and('someProperty1', 'someProperty2'),

  macroPropertyOr: or('someProperty1', 'someProperty2')
});

Related Rules

References

  • Guide for computed properties
  • Spec for computed property macros