Skip to content

Build your personal knowledge base with Trilium Notes

chore(client): remove unused linter for now

Elian Doranc597ad7694bc
diff --git a/apps/client/src/widgets/type_widgets/linters/mermaid.spec.ts b/apps/client/src/widgets/type_widgets/linters/mermaid.spec.ts
deleted file mode 100644
index 638892d711..0000000000
--- a/apps/client/src/widgets/type_widgets/linters/mermaid.spec.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { describe, expect, it } from "vitest";
-import { trimIndentation } from "@triliumnext/commons";
-import { validateMermaid } from "./mermaid.js";
-
-describe("Mermaid linter", () => {
-
- (global as any).CodeMirror = {
- Pos(line: number, col: number) {
- return { line, col };
- }
- };
-
- it("reports correctly bad diagram type", async () => {
- const input = trimIndentation`\
- stateDiagram-v23
- [*] -> Still
- `;
-
- const result = await validateMermaid(input);
- expect(result).toMatchObject([{
- message: "Expecting 'SPACE', 'NL', 'SD', got 'ID'",
- from: { line: 0, col: 0 },
- to: { line: 0, col: 1 }
- }]);
- });
-
- it("reports correctly basic arrow missing in diagram", async () => {
- const input = trimIndentation`\
- xychart-beta horizontal
- title "Percentage usge"
- x-axis [data, sys, usr, var]
- y-axis 0--->100
- bar [20, 70, 0, 0]
- `;
-
- const result = await validateMermaid(input);
- expect(result).toMatchObject([{
- message: "Expecting 'ARROW_DELIMITER', got 'MINUS'",
- from: { line: 3, col: 8 },
- to: { line: 3, col: 9 }
- }]);
- });
-});
diff --git a/apps/client/src/widgets/type_widgets/linters/mermaid.ts b/apps/client/src/widgets/type_widgets/linters/mermaid.ts
deleted file mode 100644
index e0773e6524..0000000000
--- a/apps/client/src/widgets/type_widgets/linters/mermaid.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import mermaid from "mermaid";
-
-interface MermaidParseError extends Error {
- hash: {
- text: string;
- token: string;
- line: number;
- loc: {
- first_line: number;
- first_column: number;
- last_line: number;
- last_column: number;
- };
- expected: string[]
- }
-}
-
-export default function registerErrorReporter() {
- CodeMirror.registerHelper("lint", null, validateMermaid);
-}
-
-export async function validateMermaid(text: string) {
- if (!text.trim()) {
- return [];
- }
-
- try {
- await mermaid.parse(text);
- } catch (e: unknown) {
- console.warn("Got validation error", JSON.stringify(e));
-
- const mermaidError = (e as MermaidParseError);
- const loc = mermaidError.hash.loc;
-
- let firstCol = loc.first_column + 1;
- let lastCol = loc.last_column + 1;
-
- if (firstCol === 1 && lastCol === 1) {
- firstCol = 0;
- }
-
- let messageLines = mermaidError.message.split("\n");
- if (messageLines.length >= 4) {
- messageLines = messageLines.slice(3);
- }
-
- return [
- {
- message: messageLines.join("\n"),
- severity: "error",
- from: CodeMirror.Pos(loc.first_line - 1, firstCol),
- to: CodeMirror.Pos(loc.last_line - 1, lastCol)
- }
- ];
- }
-
- return [];
-}