📝 Disallow the version of context.report() with multiple arguments.
💼 This rule is enabled in the ✅ recommended config.
🔧 This rule is automatically fixable by the --fix CLI option.
ESLint has two APIs that rules can use to report problems.
- The deprecated API accepts multiple arguments:
context.report(node, [loc], message). - The "new API" accepts a single argument: an object containing information about the reported problem.
It is recommended that all rules use the new API.
This rule aims to disallow use of the deprecated context.report(node, [loc], message) API.
Examples of incorrect code for this rule:
module.exports = {
create(context) {
context.report(node, 'This node is bad.');
},
};Examples of correct code for this rule:
module.exports = {
create(context) {
context.report({ node, message: 'This node is bad.' });
context.report({ node, loc, message: 'This node is bad.' });
},
};