Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 1.6 KB

no-unused-placeholders.md

File metadata and controls

61 lines (43 loc) · 1.6 KB

Disallow unused placeholders in rule report messages (eslint-plugin/no-unused-placeholders)

💼 This rule is enabled in the ✅ recommended config.

This rule aims to disallow unused placeholders in rule report messages.

Rule Details

Reports when a context.report() call contains a data property that does not have a corresponding placeholder in the report message.

Examples of incorrect code for this rule:

/* eslint eslint-plugin/no-unused-placeholders: error*/

module.exports = {
  create(context) {
    context.report({
      node,
      message: 'something is wrong.',
      data: { something: 'foo' },
    });

    context.report(node, 'something is wrong.', { something: 'foo' });
  },
};

Examples of correct code for this rule:

/* eslint eslint-plugin/no-unused-placeholders: error*/

module.exports = {
  create(context) {
    context.report({
      node,
      message: 'something is wrong.',
    });

    context.report({
      node,
      message: '{{something}} is wrong.',
      data: { something: 'foo' },
    });

    context.report(node, '{{something}} is wrong.', { something: 'foo' });
  },
};

When Not To Use It

If you want to allow unused placeholders, you should turn off this rule.

Further Reading