Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): update ESLint to latest

Elian Doranc4f8e9605f32
diff --git a/libraries/codemirror/eslint.js b/libraries/codemirror/eslint.js
index 9efda72ea9..88de97847a 100644
--- a/libraries/codemirror/eslint.js
+++ b/libraries/codemirror/eslint.js
@@ -44,29 +44,7 @@
}
const errors = new eslint().verify(text, {
- root: true,
- parserOptions: {
- ecmaVersion: "2019"
- },
- extends: ['eslint:recommended', 'airbnb-base'],
- env: {
- 'browser': true,
- 'node': true
- },
- rules: {
- 'import/no-unresolved': 'off',
- 'func-names': 'off',
- 'comma-dangle': ['warn'],
- 'padded-blocks': 'off',
- 'linebreak-style': 'off',
- 'class-methods-use-this': 'off',
- 'no-unused-vars': ['warn', { vars: 'local', args: 'after-used' }],
- 'no-nested-ternary': 'off',
- 'no-underscore-dangle': ['error', {'allow': ['_super', '_lookupFactory']}]
- },
- globals: {
- "api": "readonly"
- }
+
});
console.log(errors);
diff --git a/package-lock.json b/package-lock.json
index ba6eed1a08..dbb671f4f9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -44,6 +44,7 @@
"electron-squirrel-startup": "1.0.1",
"electron-window-state": "5.0.3",
"escape-html": "1.0.3",
+ "eslint-linter-browserify": "9.21.0",
"express": "4.21.2",
"express-rate-limit": "7.5.0",
"express-session": "1.18.1",
@@ -10117,6 +10118,12 @@
}
}
},
+ "node_modules/eslint-linter-browserify": {
+ "version": "9.21.0",
+ "resolved": "https://registry.npmjs.org/eslint-linter-browserify/-/eslint-linter-browserify-9.21.0.tgz",
+ "integrity": "sha512-6/VTsxcyzWkqAOZJdZluk68SZsdm3UaMrImyJzuixIDK9ZxItdGwHU1Ti8XVYgMGyEOdLgTK3csZDBk4oUPefg==",
+ "license": "MIT"
+ },
"node_modules/eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
diff --git a/package.json b/package.json
index 6cddb2e32d..6677989f01 100644
--- a/package.json
+++ b/package.json
@@ -100,6 +100,7 @@
"electron-squirrel-startup": "1.0.1",
"electron-window-state": "5.0.3",
"escape-html": "1.0.3",
+ "eslint-linter-browserify": "9.21.0",
"express": "4.21.2",
"express-rate-limit": "7.5.0",
"express-session": "1.18.1",
diff --git a/src/public/app/services/library_loader.ts b/src/public/app/services/library_loader.ts
index 85bc1082c0..accb27eb65 100644
--- a/src/public/app/services/library_loader.ts
+++ b/src/public/app/services/library_loader.ts
@@ -43,7 +43,10 @@ const CODE_MIRROR: Library = {
};
const ESLINT: Library = {
- js: ["libraries/eslint/eslint.js"]
+ js: async () => {
+ (window as any).eslint = (await import("eslint-linter-browserify")).Linter;
+ return [];
+ }
};
const RELATION_MAP: Library = {
@@ -108,13 +111,17 @@ async function requireLibrary(library: Library) {
}
if (library.js) {
- for (const scriptUrl of unwrapValue(library.js)) {
+ for (const scriptUrl of await unwrapValue(library.js)) {
await requireScript(scriptUrl);
}
}
}
-function unwrapValue<T>(value: T | (() => T)) {
+async function unwrapValue<T>(value: T | (() => T) | Promise<(() => T)>) {
+ if (value && typeof value === "object" && "then" in value) {
+ return (await (value as Promise<() => T>))();
+ }
+
if (typeof value === "function") {
return (value as () => T)();
}