Skip to content

Commit

Permalink
fix: correct id & filePath params
Browse files Browse the repository at this point in the history
  • Loading branch information
ModyQyW committed Nov 8, 2024
1 parent 7ca8fe9 commit 1ac2b85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions packages/core/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
ESLintPluginOptions,
} from "./types";
import {
getFilePath,
getFilter,
initializeESLint,
lintFiles,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1ac2b85

Please # to comment.