Skip to content

Latest commit

 

History

History
44 lines (29 loc) · 1.46 KB

no-deprecated-report-api.md

File metadata and controls

44 lines (29 loc) · 1.46 KB

Disallow the version of context.report() with multiple arguments (eslint-plugin/no-deprecated-report-api)

💼 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.

Rule Details

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.' });
  },
};

Further Reading