File tree 12 files changed +16
-17
lines changed
12 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ module.exports = {
81
81
return false ;
82
82
}
83
83
const scope =
84
- ( context . sourceCode || context . getSourceCode ( ) ) ? .getScope ( node ) ||
84
+ ( context . sourceCode || context . getSourceCode ( ) ) . getScope ?. ( node ) ||
85
85
context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < 9.0.0
86
86
const staticValue = getStaticValue ( node , scope ) ;
87
87
if ( ! staticValue ) {
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ module.exports = {
48
48
} ,
49
49
50
50
CallExpression ( node ) {
51
+ const scope = sourceCode . getScope ?. ( node ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < 9.0.0
51
52
// Check for messageId properties used in known calls to context.report();
52
53
if (
53
54
node . callee . type === 'MemberExpression' &&
@@ -80,7 +81,7 @@ module.exports = {
80
81
val . value ,
81
82
ruleInfo ,
82
83
scopeManager ,
83
- sourceCode . getScope ( node )
84
+ scope
84
85
)
85
86
)
86
87
// Couldn't find this messageId in `meta.messages`.
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ module.exports = {
48
48
contextIdentifiers = utils . getContextIdentifiers ( scopeManager , ast ) ;
49
49
} ,
50
50
CallExpression ( node ) {
51
- const scope = sourceCode . getScope ( node ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < 9.0.0
51
+ const scope = sourceCode . getScope ?. ( node ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < 9.0.0
52
52
if (
53
53
node . callee . type === 'MemberExpression' &&
54
54
contextIdentifiers . has ( node . callee . object ) &&
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ module.exports = {
57
57
return ;
58
58
}
59
59
60
- const scope = sourceCode . getScope ( ast ) ;
60
+ const scope = sourceCode . getScope ?. ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < 9.0.0
61
61
62
62
const messageIdNodesUnused = messageIdNodes . filter (
63
63
( node ) => ! messageIdsUsed . has ( utils . getKeyName ( node , scope ) )
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ module.exports = {
47
47
contextIdentifiers = utils . getContextIdentifiers ( scopeManager , ast ) ;
48
48
} ,
49
49
CallExpression ( node ) {
50
+ const scope = sourceCode . getScope ?. ( node ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < 9.0.0
50
51
if (
51
52
node . callee . type === 'MemberExpression' &&
52
53
contextIdentifiers . has ( node . callee . object ) &&
@@ -74,7 +75,7 @@ module.exports = {
74
75
obj . messageId . value ,
75
76
ruleInfo ,
76
77
scopeManager ,
77
- sourceCode . getScope ( node )
78
+ scope
78
79
) ;
79
80
if ( correspondingMessage ) {
80
81
obj . message = correspondingMessage . value ;
@@ -86,10 +87,7 @@ module.exports = {
86
87
for ( const { message, data } of reportMessagesAndDataArray . filter (
87
88
( obj ) => obj . message
88
89
) ) {
89
- const messageStaticValue = getStaticValue (
90
- message ,
91
- sourceCode . getScope ( node )
92
- ) ;
90
+ const messageStaticValue = getStaticValue ( message , scope ) ;
93
91
if (
94
92
( ( message . type === 'Literal' &&
95
93
typeof message . value === 'string' ) ||
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ module.exports = {
43
43
44
44
return {
45
45
Program ( ast ) {
46
- const scope = sourceCode . getScope ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
46
+ const scope = sourceCode . getScope ?. ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
47
47
contextIdentifiers = utils . getContextIdentifiers (
48
48
sourceCode . scopeManager ,
49
49
ast
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ module.exports = {
69
69
70
70
return {
71
71
Program ( ast ) {
72
- const scope = sourceCode . getScope ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
72
+ const scope = sourceCode . getScope ?. ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
73
73
contextIdentifiers = utils . getContextIdentifiers (
74
74
sourceCode . scopeManager ,
75
75
ast
@@ -97,7 +97,7 @@ module.exports = {
97
97
. forEach ( ( it ) => processMessageNode ( it , scope ) ) ;
98
98
} ,
99
99
CallExpression ( node ) {
100
- const scope = sourceCode . getScope ( node ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
100
+ const scope = sourceCode . getScope ?. ( node ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
101
101
if (
102
102
node . callee . type === 'MemberExpression' &&
103
103
contextIdentifiers . has ( node . callee . object ) &&
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ module.exports = {
50
50
51
51
return {
52
52
Program ( ast ) {
53
- const scope = sourceCode . getScope ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
53
+ const scope = sourceCode . getScope ?. ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
54
54
const { scopeManager } = sourceCode ;
55
55
56
56
const pattern =
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ module.exports = {
80
80
81
81
return {
82
82
Program ( ast ) {
83
- const scope = sourceCode . getScope ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
83
+ const scope = sourceCode . getScope ?. ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
84
84
const { scopeManager } = sourceCode ;
85
85
86
86
const metaNode = ruleInfo . meta ;
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ module.exports = {
77
77
}
78
78
} ,
79
79
'Program:exit' ( ast ) {
80
- const scope = sourceCode . getScope ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
80
+ const scope = sourceCode . getScope ?. ( ast ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
81
81
const metaFixableProp =
82
82
ruleInfo &&
83
83
utils
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ module.exports = {
44
44
* @returns {boolean } whether this property should be considered to contain suggestions
45
45
*/
46
46
function doesPropertyContainSuggestions ( node ) {
47
- const scope = sourceCode . getScope ( node ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
47
+ const scope = sourceCode . getScope ?. ( node ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
48
48
const staticValue = getStaticValue ( node . value , scope ) ;
49
49
if (
50
50
! staticValue ||
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ module.exports = {
46
46
47
47
return {
48
48
Program ( node ) {
49
- const scope = sourceCode . getScope ( node ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
49
+ const scope = sourceCode . getScope ?. ( node ) || context . getScope ( ) ; // TODO: just use sourceCode.getScope() when we drop support for ESLint < v9.0.0
50
50
const { scopeManager } = sourceCode ;
51
51
52
52
const metaNode = ruleInfo . meta ;
You can’t perform that action at this time.
0 commit comments