Skip to content

Latest commit

 

History

History
63 lines (51 loc) · 1.38 KB

no-missing-message-ids.md

File metadata and controls

63 lines (51 loc) · 1.38 KB

Disallow messageIds that are missing from meta.messages (eslint-plugin/no-missing-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 use a messageId that doesn't exist in meta.messages.

Rule Details

Examples of incorrect code for this rule:

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

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

Examples of correct code for this rule:

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

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

Further Reading