Closed
Description
ESLint v4.15.0 introduced messageId
. Looking at this code sample:
module.exports = {
meta: {
messages: {
avoidName: "Avoid using variables named '{{ name }}'",
},
},
create(context) {
return {
Identifier(node) {
if (node.name === 'foo') {
context.report({
node,
messageId: 'avoidName',
data: {
name: 'foo',
},
})
}
},
}
},
}
I would want a rule that:
- ensures that the
messageId
used incontext.report()
matches a key inmeta.messages
(in this example,avoidName
) - if
meta.messages[messageId]
contains a placeholder, it matchesdata[placeholderName]
(in this example,{{ name }}
matchesdata.name
)
I'm wondering if the second bullet point should be added to eslint-plugin/no-unused-placeholders
or as part of a new rule. I think the first case makes sense as its own rule.
What are your thoughts on this? I'd be happy to work on a pull request this week - looking for feedback on if this would be valuable and how to best include these features into this plugin. Thanks!