@@ -47,12 +47,13 @@ export function loadESLint(options) {
4747}
4848
4949/**
50+ * @param {string|undefined } key
5051 * @param {number } poolSize
5152 * @param {Options } options
5253 * @returns {Linter }
5354 */
54- export function loadESLintThreaded ( poolSize , options ) {
55- const key = getCacheKey ( options ) ;
55+ export function loadESLintThreaded ( key , poolSize , options ) {
56+ const cacheKey = getCacheKey ( key , options ) ;
5657 const { eslintPath = 'eslint' } = options ;
5758 const source = require . resolve ( './worker' ) ;
5859 const workerOptions = {
@@ -75,7 +76,7 @@ export function loadESLintThreaded(poolSize, options) {
7576 ( worker && ( await worker . lintFiles ( files ) ) ) ||
7677 /* istanbul ignore next */ [ ] ,
7778 cleanup : async ( ) => {
78- cache [ key ] = local ;
79+ cache [ cacheKey ] = local ;
7980 context . lintFiles = ( files ) => local . lintFiles ( files ) ;
8081 if ( worker ) {
8182 worker . end ( ) ;
@@ -88,10 +89,11 @@ export function loadESLintThreaded(poolSize, options) {
8889}
8990
9091/**
92+ * @param {string|undefined } key
9193 * @param {Options } options
9294 * @returns {Linter }
9395 */
94- export default function getESLint ( { threads, ...options } ) {
96+ export default function getESLint ( key , { threads, ...options } ) {
9597 const max =
9698 typeof threads !== 'number'
9799 ? threads
@@ -100,18 +102,19 @@ export default function getESLint({ threads, ...options }) {
100102 : /* istanbul ignore next */
101103 threads ;
102104
103- const key = getCacheKey ( { threads, ...options } ) ;
104- if ( ! cache [ key ] ) {
105- cache [ key ] =
106- max > 1 ? loadESLintThreaded ( max , options ) : loadESLint ( options ) ;
105+ const cacheKey = getCacheKey ( key , { threads, ...options } ) ;
106+ if ( ! cache [ cacheKey ] ) {
107+ cache [ cacheKey ] =
108+ max > 1 ? loadESLintThreaded ( key , max , options ) : loadESLint ( options ) ;
107109 }
108- return cache [ key ] ;
110+ return cache [ cacheKey ] ;
109111}
110112
111113/**
114+ * @param {string|undefined } key
112115 * @param {Options } options
113116 * @returns {string }
114117 */
115- function getCacheKey ( options ) {
116- return JSON . stringify ( options , jsonStringifyReplacerSortKeys ) ;
118+ function getCacheKey ( key , options ) {
119+ return JSON . stringify ( { key , options } , jsonStringifyReplacerSortKeys ) ;
117120}
0 commit comments