refactor(deps): use different approach for eslint

This commit is contained in:
Elian Doran 2025-03-08 02:37:29 +02:00
parent c4f8e9605f
commit 0273fad0ba
No known key found for this signature in database
6 changed files with 14 additions and 112897 deletions

View File

@ -35,17 +35,13 @@
return [];
}
await glob.requireLibrary(glob.ESLINT);
if (text.length > 20000) {
console.log("Skipping linting because of large size: ", text.length);
return [];
}
const errors = new eslint().verify(text, {
});
const errors = await glob.linter(text);
console.log(errors);

112883
libraries/eslint/eslint.js vendored

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
export async function lint(code: string) {
const Linter = (await import("eslint-linter-browserify")).Linter;
return new Linter().verify(code, {
});
}

View File

@ -5,6 +5,7 @@ import libraryLoader from "./library_loader.js";
import ws from "./ws.js";
import froca from "./froca.js";
import linkService from "./link.js";
import { lint } from "./eslint.js";
function setupGlobs() {
window.glob.isDesktop = utils.isDesktop;
@ -18,7 +19,7 @@ function setupGlobs() {
// required for ESLint plugin and CKEditor
window.glob.getActiveContextNote = () => appContext.tabManager.getActiveContextNote();
window.glob.requireLibrary = libraryLoader.requireLibrary;
window.glob.ESLINT = libraryLoader.ESLINT;
window.glob.linter = lint;
window.glob.appContext = appContext; // for debugging
window.glob.froca = froca;
window.glob.treeCache = froca; // compatibility for CKEditor builds for a while

View File

@ -42,13 +42,6 @@ const CODE_MIRROR: Library = {
css: ["node_modules/codemirror/lib/codemirror.css", "node_modules/codemirror/addon/lint/lint.css"]
};
const ESLINT: Library = {
js: async () => {
(window as any).eslint = (await import("eslint-linter-browserify")).Linter;
return [];
}
};
const RELATION_MAP: Library = {
js: ["node_modules/jsplumb/dist/js/jsplumb.min.js", "node_modules/panzoom/dist/panzoom.min.js"],
css: ["stylesheets/relation_map.css"]
@ -190,7 +183,6 @@ export default {
loadHighlightingTheme,
CKEDITOR,
CODE_MIRROR,
ESLINT,
RELATION_MAP,
CALENDAR_WIDGET,
KATEX,

View File

@ -6,6 +6,7 @@ import appContext from "./components/app_context.ts";
import server from "./services/server.ts";
import library_loader, { Library } from "./services/library_loader.ts";
import type { init } from "i18next";
import type { lint } from "./services/eslint.ts";
interface ElectronProcess {
type: string;
@ -44,6 +45,7 @@ interface CustomGlobals {
triliumVersion: string;
TRILIUM_SAFE_MODE: boolean;
platform?: typeof process.platform;
linter: typeof lint;
}
type RequireMethod = (moduleName: string) => any;