Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 1.98 KB

no-invalid-debug-function-arguments.md

File metadata and controls

49 lines (32 loc) · 1.98 KB

ember/no-invalid-debug-function-arguments

💼 This rule is enabled in the ✅ recommended config.

Catch usages of Ember's assert() / warn() / deprecate() functions that have the arguments passed in the wrong order.

This rule aims to catch a common mistake when using Ember's debug functions:

  • assert(String description, Boolean condition)
  • warn(String description, Boolean condition, Object options)
  • deprecate(String description, Boolean condition, Object options)

When calling one of these functions, the author may mistakenly pass the description and condition arguments in the reverse order, and not notice because the function will be silent with a truthy string as the condition.

Examples

Examples of incorrect code for this rule:

import { assert, warn } from '@ember/debug';
import { deprecate } from '@ember/application/deprecations';

// ...

assert(label, 'Label must be present.');
warn(label, 'Label must be present.', { id: 'missing-label' });
deprecate(title, 'Title is no longer supported.', { id: 'unwanted-title', until: 'some-version' });

Examples of correct code for this rule:

import { assert, warn } from '@ember/debug';
import { deprecate } from '@ember/application/deprecations';

// ...

assert('Label must be present.', label);
warn('Label must be present.', label, { id: 'missing-label' });
deprecate('Title is no longer supported.', title, { id: 'unwanted-title', until: 'some-version' });

Further Reading