mirror of
https://github.com/zadam/trilium.git
synced 2025-11-14 09:15:50 +01:00
chore(code): add smart tab behaviour
This commit is contained in:
46
packages/codemirror/src/extensions/eslint.ts
Normal file
46
packages/codemirror/src/extensions/eslint.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import type { Linter } from "eslint-linter-browserify";
|
||||
|
||||
export async function lint(mimeType: string) {
|
||||
|
||||
const Linter = (await import("eslint-linter-browserify")).Linter;
|
||||
const js = (await import("@eslint/js"));
|
||||
const globalDefinitions = (await import("globals"));
|
||||
|
||||
let globals: Record<string, any> = {
|
||||
...globalDefinitions.browser,
|
||||
api: "readonly",
|
||||
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") {
|
||||
|
||||
}
|
||||
|
||||
const config: (Linter.LegacyConfig | Linter.Config | Linter.Config[]) = [
|
||||
js.configs.recommended,
|
||||
{
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
ecmaVersion: 2024
|
||||
},
|
||||
globals
|
||||
},
|
||||
rules: {
|
||||
"no-unused-vars": [ "warn", { vars: "local", args: "after-used" }]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
return {
|
||||
linter: new Linter(),
|
||||
config
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user