Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support ESLint 9.3.0 #51

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/purple-terms-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vite-plugin-eslint4b": patch
---

feat: support ESLint 9.3.0
18 changes: 11 additions & 7 deletions src/vite-plugin-eslint4b.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,13 @@ function buildLinter() {
eslintPackageJsonPath,
"../lib/rules/index.js",
);
const code = build(linterPath, ["path", "assert", "util"], {
[rulesPath]: virtualRulesModuleId,
});
const code = build(
linterPath,
["path", "node:path", "assert", "node:assert", "util"],
{
[rulesPath]: virtualRulesModuleId,
},
);
return code;
}

Expand All @@ -206,7 +210,7 @@ function buildSourceCode() {
eslintPackageJsonPath,
"../lib/source-code/index.js",
);
return build(sourceCodePath, ["path"]);
return build(sourceCodePath, ["path", "node:path", "assert", "node:assert"]);
}

function buildRules() {
Expand All @@ -215,7 +219,7 @@ function buildRules() {
eslintPackageJsonPath,
"../lib/rules/index.js",
);
return build(rulesPath, ["path"]);
return build(rulesPath, ["path", "node:path"]);
}

function buildPackageJSON() {
Expand Down Expand Up @@ -262,7 +266,7 @@ function bundle(
inject: [path.join(dirname, "../shim/process-shim.mjs")],
});

return `${result.outputFiles[0].text}`;
return result.outputFiles[0].text;
}

function transform(
Expand All @@ -273,7 +277,7 @@ function transform(
const injectSources: { id: string; source: string; module: string }[] = [
...injects.map((inject) => ({
id: `$inject_${inject.replace(/[^\w$]/giu, "_")}`,
source: inject,
source: inject.replace(/^node:/u, ""),
module: inject,
})),
...Object.entries(alias).map(([module, source]) => ({
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/build-test-v8/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { name } from "eslint/package.json";
import * as TSESLintUtils from "@typescript-eslint/utils";
import * as TSESLintPlugin from "@typescript-eslint/eslint-plugin";

const linter = new Linter();
const linter = new Linter({ configType: "eslintrc" });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use legacy config if we install ESLint v9.


export function lint(): Linter.LintMessage[] {
return linter.verify("const a = 1", {
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/build-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { name } from "eslint/package.json";
import * as TSESLintUtils from "@typescript-eslint/utils";
import * as TSESLintPlugin from "@typescript-eslint/eslint-plugin";

const linter = new Linter();
const linter = new Linter({ configType: "eslintrc" });

export function lint(): Linter.LintMessage[] {
return linter.verify("const a = 1", [
Expand Down