@@ -46,12 +46,13 @@ export function loadESLint(options) {
4646}
4747
4848/**
49+ * @param {string|undefined } key
4950 * @param {number } poolSize
5051 * @param {Options } options
5152 * @returns {Linter }
5253 */
53- export function loadESLintThreaded ( poolSize , options ) {
54- const key = getCacheKey ( options ) ;
54+ export function loadESLintThreaded ( key , poolSize , options ) {
55+ const cacheKey = getCacheKey ( key , options ) ;
5556 const { eslintPath = 'eslint' } = options ;
5657 const source = require . resolve ( './worker' ) ;
5758 const workerOptions = {
@@ -74,7 +75,7 @@ export function loadESLintThreaded(poolSize, options) {
7475 ( worker && ( await worker . lintFiles ( files ) ) ) ||
7576 /* istanbul ignore next */ [ ] ,
7677 cleanup : async ( ) => {
77- cache [ key ] = local ;
78+ cache [ cacheKey ] = local ;
7879 context . lintFiles = ( files ) => local . lintFiles ( files ) ;
7980 if ( worker ) {
8081 worker . end ( ) ;
@@ -87,10 +88,11 @@ export function loadESLintThreaded(poolSize, options) {
8788}
8889
8990/**
91+ * @param {string|undefined } key
9092 * @param {Options } options
9193 * @returns {Linter }
9294 */
93- export default function getESLint ( { threads, ...options } ) {
95+ export default function getESLint ( key , { threads, ...options } ) {
9496 const max =
9597 typeof threads !== 'number'
9698 ? threads
@@ -99,18 +101,19 @@ export default function getESLint({ threads, ...options }) {
99101 : /* istanbul ignore next */
100102 threads ;
101103
102- const key = getCacheKey ( { threads, ...options } ) ;
103- if ( ! cache [ key ] ) {
104- cache [ key ] =
105- max > 1 ? loadESLintThreaded ( max , options ) : loadESLint ( options ) ;
104+ const cacheKey = getCacheKey ( key , { threads, ...options } ) ;
105+ if ( ! cache [ cacheKey ] ) {
106+ cache [ cacheKey ] =
107+ max > 1 ? loadESLintThreaded ( key , max , options ) : loadESLint ( options ) ;
106108 }
107- return cache [ key ] ;
109+ return cache [ cacheKey ] ;
108110}
109111
110112/**
113+ * @param {string|undefined } key
111114 * @param {Options } options
112115 * @returns {string }
113116 */
114- function getCacheKey ( options ) {
115- return JSON . stringify ( options , jsonStringifyReplacerSortKeys ) ;
117+ function getCacheKey ( key , options ) {
118+ return JSON . stringify ( { key , options } , jsonStringifyReplacerSortKeys ) ;
116119}
0 commit comments