@@ -24,7 +24,7 @@ module.exports = {
24
24
} ,
25
25
26
26
create ( context ) {
27
- const sourceCode = context . getSourceCode ( ) ;
27
+ const sourceCode = context . sourceCode || context . getSourceCode ( ) ; // TODO: just use context.sourceCode when dropping eslint < v9
28
28
const { scopeManager } = sourceCode ;
29
29
const ruleInfo = utils . getRuleInfo ( sourceCode ) ;
30
30
if ( ! ruleInfo ) {
@@ -47,7 +47,7 @@ module.exports = {
47
47
contextIdentifiers = utils . getContextIdentifiers ( scopeManager , ast ) ;
48
48
} ,
49
49
50
- 'Program:exit' ( ) {
50
+ 'Program:exit' ( ast ) {
51
51
if ( hasSeenUnknownMessageId || ! hasSeenViolationReport ) {
52
52
/*
53
53
Bail out when the rule is likely to have false positives.
@@ -57,9 +57,10 @@ module.exports = {
57
57
return ;
58
58
}
59
59
60
+ const scope = sourceCode . getScope ?. ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < 9.0.0
61
+
60
62
const messageIdNodesUnused = messageIdNodes . filter (
61
- ( node ) =>
62
- ! messageIdsUsed . has ( utils . getKeyName ( node , context . getScope ( ) ) )
63
+ ( node ) => ! messageIdsUsed . has ( utils . getKeyName ( node , scope ) )
63
64
) ;
64
65
65
66
// Report any messageIds that were never used.
@@ -68,7 +69,7 @@ module.exports = {
68
69
node : messageIdNode ,
69
70
messageId : 'unusedMessage' ,
70
71
data : {
71
- messageId : utils . getKeyName ( messageIdNode , context . getScope ( ) ) ,
72
+ messageId : utils . getKeyName ( messageIdNode , scope ) ,
72
73
} ,
73
74
} ) ;
74
75
}
@@ -82,7 +83,7 @@ module.exports = {
82
83
node . callee . property . type === 'Identifier' &&
83
84
node . callee . property . name === 'report'
84
85
) {
85
- const reportInfo = utils . getReportInfo ( node . arguments , context ) ;
86
+ const reportInfo = utils . getReportInfo ( node , context ) ;
86
87
if ( ! reportInfo ) {
87
88
return ;
88
89
}
0 commit comments