Skip to content

Latest commit

 

History

History
44 lines (26 loc) · 1.4 KB

no-deprecated-report-api.md

File metadata and controls

44 lines (26 loc) · 1.4 KB

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

(fixable) The --fix option on the command line automatically fixes 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.

The following patterns are considered warnings:

module.exports = {
  create(context) {

    context.report(node, 'This node is bad.');

    context.report(node, loc, 'This node is bad.');

  }
};

The following patterns are not warnings:

module.exports = {
  create(context) {

    context.report({ node, message: 'This node is bad.' });

    context.report({ node, loc, message: 'This node is bad.' });

  }
};

Further Reading