File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 1
1
export const processor_options = { } ;
2
2
3
3
// find Linter instance
4
- const linter_path = Object . keys ( require . cache ) . find ( path => path . endsWith ( '/eslint/lib/linter/linter.js' ) || path . endsWith ( '\\eslint\\lib\\linter\\linter.js' ) ) ;
5
- if ( ! linter_path ) {
4
+ const linter_paths = Object . keys ( require . cache ) . filter ( path => path . endsWith ( '/eslint/lib/linter/linter.js' ) || path . endsWith ( '\\eslint\\lib\\linter\\linter.js' ) ) ;
5
+ if ( ! linter_paths . length ) {
6
6
throw new Error ( 'Could not find ESLint Linter in require cache' ) ;
7
7
}
8
+ // There may be more than one instance of the linter when we're in a workspace with multiple directories.
9
+ // We first try to find the one that's inside the same node_modules directory as this plugin.
10
+ // If that can't be found for some reason, we assume the one we want is the last one in the array.
11
+ const current_node_modules_path = __dirname . replace ( / (?< = [ / \\ ] n o d e _ m o d u l e s [ / \\ ] ) .* $ / , '' )
12
+ const linter_path = linter_paths . find ( path => path . startsWith ( current_node_modules_path ) ) || linter_paths . pop ( ) ;
8
13
const { Linter } = require ( linter_path ) ;
9
14
10
15
// patch Linter#verify
You can’t perform that action at this time.
0 commit comments