Skip to content

Latest commit

 

History

History
39 lines (26 loc) · 1.47 KB

no-deprecated-report-api.md

File metadata and controls

39 lines (26 loc) · 1.47 KB

Disallow use of the deprecated context.report() API (no-deprecated-report-api)

✔️ 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.

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