Skip to content

Latest commit

 

History

History
64 lines (52 loc) · 1.41 KB

no-unused-message-ids.md

File metadata and controls

64 lines (52 loc) · 1.41 KB

Disallow unused messageIds in meta.messages (eslint-plugin/no-unused-message-ids)

💼 This rule is enabled in the ✅ recommended config.

When using meta.messages and messageId to report rule violations, it's possible to mistakenly leave a message in meta.messages that is never used.

Rule Details

Examples of incorrect code for this rule:

/* eslint eslint-plugin/no-unused-message-ids: error */

module.exports = {
  meta: {
    messages: {
      foo: 'hello world',
      bar: 'lorem ipsum', // this message is never used
    },
  },
  create(context) {
    return {
      CallExpression(node) {
        context.report({
          node,
          messageId: 'foo',
        });
      },
    };
  },
};

Examples of correct code for this rule:

/* eslint eslint-plugin/no-unused-message-ids: error */

module.exports = {
  meta: {
    messages: {
      foo: 'hello world',
    },
  },
  create(context) {
    return {
      CallExpression(node) {
        context.report({
          node,
          messageId: 'foo',
        });
      },
    };
  },
};

Further Reading