Skip to content

Commit

Permalink
fix: add support for eslint v9.5 (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Jun 15, 2024
1 parent 240b463 commit 9de33f8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-paws-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vite-plugin-eslint4b": patch
---

fix: add support for eslint v9.5
9 changes: 8 additions & 1 deletion src/vite-plugin-eslint4b.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,17 @@ function buildLinter() {

function buildSourceCode() {
const eslintPackageJsonPath = requireResolved("eslint/package.json");
const sourceCodePath = resolveAndNormalizePath(
let sourceCodePath = resolveAndNormalizePath(
eslintPackageJsonPath,
"../lib/source-code/index.js",
);
if (!fs.existsSync(sourceCodePath)) {
// ESLint v9.5.0 and later
sourceCodePath = resolveAndNormalizePath(
eslintPackageJsonPath,
"../lib/languages/js/source-code/index.js",
);
}
return build(sourceCodePath, ["path", "node:path", "assert", "node:assert"]);
}

Expand Down
5 changes: 1 addition & 4 deletions tests/fixtures/build-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ 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({ configType: "eslintrc" });
const linter = new Linter({});

export function lint(): Linter.LintMessage[] {
return linter.verify("const a = 1", [
{
languageOptions: {
ecmaVersion: 2020,
},
rules: { semi: "error" },
},
]);
Expand Down
7 changes: 1 addition & 6 deletions tests/src/vite-plugin-eslint4b.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import type { Linter } from "eslint";

const dynamicImport = new Function("file", "return import(file)");
describe("Build with Vite", () => {
if (
!semver.satisfies(
process.version,
"^18.18.0 || ^20.9.0 || >=21.1.018.0.0 || ",
)
) {
if (!semver.satisfies(process.version, "^18.18.0 || ^20.9.0 || >=21.1.0")) {
return;
}
let originalCwd: string;
Expand Down

0 comments on commit 9de33f8

Please sign in to comment.