✔️ The "extends": "plugin:eslint-plugin/recommended"
property in a configuration file enables this rule.
⚒️ The --fix
option on the command line can automatically fix some of the problems reported by this rule.
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.' });
},
};