📝 Require suggestions to have different messageId than their parent report.
When providing fix suggestions to a reported problem, it's important to have an actionable messageId for each suggestion rather than reusing the same messageId as the main report.
Examples of incorrect code for this rule:
/* eslint eslint-plugin/no-matching-violation-suggest-message-ids: error */
module.exports = {
meta: { messages: { notAllowed: '`DebuggerStatement`s are not allowed' } },
create(context) {
return {
DebuggerStatement(node) {
context.report({
node,
messageId: 'notAllowed',
suggest: [{ messageId: 'notAllowed' }],
});
},
};
},
};Examples of correct code for this rule:
/* eslint eslint-plugin/no-matching-violation-suggest-message-ids: error */
module.exports = {
meta: {
messages: {
notAllowed: '`DebuggerStatement`s are not allowed',
remove: 'Remove the debugger statement',
},
},
create(context) {
return {
DebuggerStatement(node) {
context.report({
node,
messageId: 'notAllowed',
suggest: [
{
messageId: 'remove',
fix: (fixer) => fixer.remove(node),
},
],
});
},
};
},
};