Skip to content

Commit

Permalink
fix: to correctly normalize ESLint module paths (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Jun 8, 2024
1 parent 9056c24 commit 4c7930a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sixty-olives-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vite-plugin-eslint4b": patch
---

fix: to correctly normalize ESLint module paths
7 changes: 6 additions & 1 deletion src/vite-plugin-eslint4b.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,12 @@ function transform(

injectSources.forEach((s) => {
if (path.isAbsolute(s.module)) {
s.module = `./${path.normalize(path.relative(process.cwd(), s.module))}`;
const normalized = path.normalize(path.relative(process.cwd(), s.module));
s.module =
normalized.startsWith("./") || normalized.startsWith("../")
? normalized
: // This must be a relative path to match the esbuild import path.
`./${normalized}`;
}
});

Expand Down

0 comments on commit 4c7930a

Please sign in to comment.