@@ -11,43 +11,6 @@ const utils = require('../utils');
11
11
// Rule Definition
12
12
// ------------------------------------------------------------------------------
13
13
14
- /**
15
- * Gets report info for a context.report() call
16
- * TODO: Combine this with logic from no-deprecated-report-api
17
- * @param {ASTNode[] } reportArgs The arguments to the context.report() call
18
- * @returns {object }
19
- */
20
- function getReportInfo ( reportArgs ) {
21
- if ( reportArgs . length === 1 ) {
22
- if ( reportArgs [ 0 ] . type === 'ObjectExpression' ) {
23
- const messageProp = reportArgs [ 0 ] . properties . find ( prop => utils . getKeyName ( prop ) === 'message' ) ;
24
- const dataProp = reportArgs [ 0 ] . properties . find ( prop => utils . getKeyName ( prop ) === 'data' ) ;
25
-
26
- return {
27
- message : messageProp && messageProp . value ,
28
- data : dataProp && dataProp . value ,
29
- } ;
30
- }
31
- } else if ( reportArgs . length ) {
32
- if ( reportArgs [ 1 ] . type === 'Literal' && typeof reportArgs [ 1 ] . value === 'string' ) {
33
- return {
34
- message : reportArgs [ 1 ] ,
35
- data : reportArgs [ 2 ] ,
36
- } ;
37
- } else if (
38
- reportArgs [ 1 ] . type === 'ObjectExpression' ||
39
- reportArgs [ 1 ] . type === 'ArrayExpression' ||
40
- ( reportArgs [ 1 ] . type === 'Literal' && typeof reportArgs [ 1 ] . value !== 'string' )
41
- ) {
42
- return {
43
- message : reportArgs [ 2 ] ,
44
- data : reportArgs [ 3 ] ,
45
- } ;
46
- }
47
- }
48
- return null ;
49
- }
50
-
51
14
module . exports = {
52
15
meta : {
53
16
docs : {
@@ -76,7 +39,7 @@ module.exports = {
76
39
contextIdentifiers . has ( node . callee . object ) &&
77
40
node . callee . property . type === 'Identifier' && node . callee . property . name === 'report'
78
41
) {
79
- const reportInfo = getReportInfo ( node . arguments ) ;
42
+ const reportInfo = utils . getReportInfo ( node . arguments ) ;
80
43
81
44
if (
82
45
reportInfo &&
0 commit comments