Closed
Description
ESLint version
v9.28.0
What problem do you want to solve?
In the custom rule context.report
, the messageId
property is mandatory, but the meta.message
property is not.
Here, specifying the messageId
property without specifying meta.message
(as in the following example) will result in the following error.
import { Rule } from 'eslint';
export const noClass: Rule.RuleModule = {
meta: {
type: 'suggestion',
},
create(context) {
return {
ClassDeclaration(node) {
context.report({
node,
messageId: 'sampleId',
});
},
};
},
};
Error: Caught an error while linting
Caused by: TypeError: context.report() called with a messageId, but no messages were present in the rule metadata.
What do you think is the correct solution?
Make the meta.message
property a required property
Participation
- I am willing to submit a pull request for this change.
Additional comments
No response
Metadata
Metadata
Assignees
Type
Projects
Status
Complete