mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
refactor(deps): use different approach for eslint
This commit is contained in:
parent
c4f8e9605f
commit
0273fad0ba
6
libraries/codemirror/eslint.js
vendored
6
libraries/codemirror/eslint.js
vendored
@ -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
112883
libraries/eslint/eslint.js
vendored
File diff suppressed because one or more lines are too long
9
src/public/app/services/eslint.ts
Normal file
9
src/public/app/services/eslint.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export async function lint(code: string) {
|
||||
|
||||
const Linter = (await import("eslint-linter-browserify")).Linter;
|
||||
|
||||
return new Linter().verify(code, {
|
||||
|
||||
});
|
||||
|
||||
}
|
@ -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
|
||||
|
@ -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,
|
||||
|
2
src/public/app/types.d.ts
vendored
2
src/public/app/types.d.ts
vendored
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user