@@ -4,22 +4,24 @@ const proxyquire = require('proxyquire');
4
4
5
5
let ModuleResolver ;
6
6
try {
7
- // eslint 7.12+
8
- ModuleResolver = require ( '@eslint/eslintrc/lib/shared/relative-module-resolver' ) ;
7
+ // ESLint 7.12+
8
+ ModuleResolver = require ( '@eslint/eslintrc' ) . Legacy . ModuleResolver ;
9
9
} catch ( err ) {
10
10
if ( err . code !== 'MODULE_NOT_FOUND' ) {
11
11
throw err ;
12
12
}
13
+
13
14
try {
14
- // eslint v6 - v7.11: load the actual module
15
+ // ESLint v6 - v7.11: load the actual module
15
16
ModuleResolver = require ( 'eslint/lib/shared/relative-module-resolver' ) ;
16
17
} catch ( err ) {
17
18
if ( err . code !== 'MODULE_NOT_FOUND' ) {
18
19
throw err ;
19
20
}
20
- // eslint < 6: ModuleResolver is `undefined`, which is okay. The proxyquire
21
+
22
+ // ESLint < 6: ModuleResolver is `undefined`, which is okay. The proxyquire
21
23
// override for ../shared/relative-module-resolver won't be used because
22
- // eslint < 6 does not have that module and so does not try to load it.
24
+ // ESLint < 6 does not have that module and so does not try to load it.
23
25
ModuleResolver = undefined ;
24
26
}
25
27
}
@@ -54,27 +56,27 @@ const moduleResolver = {
54
56
55
57
const getRuleFinder = proxyquire ( '../../src/lib/rule-finder' , {
56
58
eslint : {
57
- linter : {
59
+ Linter : ( ) => ( {
58
60
getRules ( ) {
59
61
return new Map ( )
60
62
. set ( 'foo-rule' , { } )
61
63
. set ( 'old-rule' , { meta : { deprecated : true } } )
62
64
. set ( 'bar-rule' , { } )
63
65
. set ( 'baz-rule' , { } ) ;
64
66
}
65
- }
67
+ } )
66
68
} ,
67
69
//
68
- // This following module override is needed for eslint v6 and over. The module
69
- // path that we pass here is literally the one used in eslint (specifically in
70
+ // This following module override is needed for ESLint v6 and over. The module
71
+ // path that we pass here is literally the one used in ESLint (specifically in
70
72
// eslint/lib/cli-engine/config-array-factory.js)
71
73
//
72
74
// The stock `resolve` method attempts to resolve to a file path the module
73
75
// name passed in `name` relative to the path in `relative`. We have to
74
- // override that function, otherwise eslint fails to "load" our plugins.
76
+ // override that function, otherwise ESLint fails to "load" our plugins.
75
77
//
76
- '../shared/relative-module-resolver' : moduleResolver , // in eslint < 7.12, from eslint/lib/cli-engine/config-array-factory.js
77
- './shared/relative-module-resolver' : moduleResolver , // in eslint 7.12+, from @eslint/eslintrc/lib/config-array-factory.js
78
+ '../shared/relative-module-resolver' : moduleResolver , // in ESLint < 7.12, from eslint/lib/cli-engine/config-array-factory.js
79
+ './shared/relative-module-resolver' : moduleResolver , // in ESLint 7.12+, from @eslint/eslintrc/lib/config-array-factory.js
78
80
'eslint-plugin-plugin' : {
79
81
rules : {
80
82
'foo-rule' : { } ,
@@ -156,19 +158,19 @@ const dedupeModuleResolver = {
156
158
} ;
157
159
const getRuleFinderForDedupeTests = proxyquire ( '../../src/lib/rule-finder' , {
158
160
eslint : {
159
- linter : {
161
+ Linter : ( ) => ( {
160
162
getRules ( ) {
161
163
return new Map ( )
162
164
. set ( 'foo-rule' , { } )
163
165
. set ( 'bar-rule' , { } )
164
166
. set ( 'plugin/duplicate-foo-rule' , { } )
165
167
. set ( 'plugin/duplicate-bar-rule' , { } ) ;
166
168
}
167
- }
169
+ } )
168
170
} ,
169
171
// See the long comment in `getRuleFinder` above to learn what the point of this override is.
170
- '../shared/relative-module-resolver' : dedupeModuleResolver , // in eslint < 7.12, from eslint/lib/cli-engine/config-array-factory.js
171
- './shared/relative-module-resolver' : dedupeModuleResolver , // in eslint 7.12+, from @eslint/eslintrc/lib/config-array-factory.js
172
+ '../shared/relative-module-resolver' : dedupeModuleResolver , // in ESLint < 7.12, from eslint/lib/cli-engine/config-array-factory.js
173
+ './shared/relative-module-resolver' : dedupeModuleResolver , // in ESLint 7.12+, from @eslint/eslintrc/lib/config-array-factory.js
172
174
'eslint-plugin-plugin' : {
173
175
rules : {
174
176
'duplicate-foo-rule' : { } ,
0 commit comments