feat(eslint): add support for module.exports

This commit is contained in:
Elian Doran 2025-03-09 21:41:13 +02:00
parent 1fb4634b7b
commit be6e56fbe8
No known key found for this signature in database
2 changed files with 7 additions and 1 deletions

View File

@ -50,4 +50,9 @@ describe("Linter", () => {
expect(await lint(`$("<div>");`, "application/javascript;env=backend")).toMatchObject([{ "ruleId": "no-undef" }]);
expect(await lint(`console.log($("<div>"));`, "application/javascript;env=frontend")).toStrictEqual([]);
});
it("supports module.exports", async () => {
expect(await lint(`module.exports("Hi");`, "application/javascript;env=backend")).toStrictEqual([]);
expect(await lint(`module.exports("Hi");`, "application/javascript;env=frontend")).toStrictEqual([]);
});
});

View File

@ -6,7 +6,8 @@ export async function lint(code: string, mimeType: string) {
let globals: Record<string, any> = {
...globalDefinitions.browser,
api: "readonly"
api: "readonly",
module: "readonly"
};
if (mimeType === "application/javascript;env=frontend") {