diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 55cfa5d..4e24e40 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -81,15 +81,15 @@ export default function ESLintPlugin( }, async transform(_, id) { debug("==== transform hook ===="); - debug(`id: ${id}`); - const filePath = getFilePath(id); - debug(`filePath: ${filePath}`); // worker - if (worker) return worker.postMessage(filePath); + if (worker) return worker.postMessage(id); // no worker + debug(`id: ${id}`); const shouldIgnore = await shouldIgnoreModule(id, filter, eslintInstance); debug(`should ignore: ${shouldIgnore}`); if (shouldIgnore) return; + const filePath = getFilePath(id); + debug(`filePath: ${filePath}`); return await lintFiles( { files: options.lintDirtyOnly ? filePath : options.include, diff --git a/packages/core/src/worker.ts b/packages/core/src/worker.ts index e73c06d..8077a8e 100644 --- a/packages/core/src/worker.ts +++ b/packages/core/src/worker.ts @@ -8,6 +8,7 @@ import type { ESLintPluginOptions, } from "./types"; import { + getFilePath, getFilter, initializeESLint, lintFiles, @@ -48,16 +49,18 @@ const initPromise = initializeESLint(options).then((result) => { } })(); -parentPort?.on("message", async (files) => { +parentPort?.on("message", async (id) => { // make sure eslintInstance is initialized if (!eslintInstance) await initPromise; debug("==== worker message event ===="); - debug(`message: ${files}`); - const shouldIgnore = await shouldIgnoreModule(files, filter, eslintInstance); + debug(`id: ${id}`); + const shouldIgnore = await shouldIgnoreModule(id, filter, eslintInstance); debug(`should ignore: ${shouldIgnore}`); if (shouldIgnore) return; + const filePath = getFilePath(id); + debug(`filePath: ${filePath}`); lintFiles({ - files: options.lintDirtyOnly ? files : options.include, + files: options.lintDirtyOnly ? filePath : options.include, eslintInstance, formatter, outputFixes,