From b0e584924bb7f11bd669abd4f9bdc4ca9edff2e8 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 24 Mar 2025 19:17:45 +0200 Subject: [PATCH] fix(eslint): disable linting of TypeScript due to types (closes #1503) --- src/public/app/services/eslint.spec.ts | 4 ++++ src/public/app/services/eslint.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/public/app/services/eslint.spec.ts b/src/public/app/services/eslint.spec.ts index c6b87162a..42eac213c 100644 --- a/src/public/app/services/eslint.spec.ts +++ b/src/public/app/services/eslint.spec.ts @@ -55,4 +55,8 @@ describe("Linter", () => { expect(await lint(`module.exports("Hi");`, "application/javascript;env=backend")).toStrictEqual([]); expect(await lint(`module.exports("Hi");`, "application/javascript;env=frontend")).toStrictEqual([]); }); + + it("ignores TypeScript file", async () => { + expect(await lint("export async function lint(code: string, mimeType: string) {}", "text/typescript-jsx")).toStrictEqual([]); + }); }); diff --git a/src/public/app/services/eslint.ts b/src/public/app/services/eslint.ts index 4563239e6..bdb2dcaee 100644 --- a/src/public/app/services/eslint.ts +++ b/src/public/app/services/eslint.ts @@ -10,6 +10,12 @@ export async function lint(code: string, mimeType: string) { module: "readonly" }; + // Unsupported languages + if (mimeType.startsWith("text/typescript")) { + return []; + } + + // Custom globals if (mimeType === "application/javascript;env=frontend") { globals = { ...globals, ...globalDefinitions.jquery }; } else if (mimeType === "application/javascript;env=backend") {