mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-11 02:42:27 +08:00
feat(linter/mermaid): improve parsing of messages
This commit is contained in:
parent
8b08e67fdc
commit
d4cd550b7a
@ -17,12 +17,11 @@ describe("Mermaid linter", () => {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const result = await validateMermaid(input);
|
const result = await validateMermaid(input);
|
||||||
expect(result.length).toBe(1);
|
expect(result).toMatchObject([{
|
||||||
expect(result[0].message).toSatisfy((v: string) => v.includes("Expecting 'SPACE'"));
|
message: "Expecting 'SPACE', 'NL', 'SD', got 'ID'",
|
||||||
expect(result[0]).toMatchObject({
|
|
||||||
from: { line: 0, col: 0 },
|
from: { line: 0, col: 0 },
|
||||||
to: { line: 0, col: 1 }
|
to: { line: 0, col: 1 }
|
||||||
});
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("reports correctly basic arrow missing in diagram", async () => {
|
it("reports correctly basic arrow missing in diagram", async () => {
|
||||||
@ -35,11 +34,10 @@ describe("Mermaid linter", () => {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const result = await validateMermaid(input);
|
const result = await validateMermaid(input);
|
||||||
expect(result.length).toBe(1);
|
expect(result).toMatchObject([{
|
||||||
expect(result[0].message).toSatisfy((v: string) => v.includes("Expecting 'ARROW_DELIMITER'"));
|
message: "Expecting 'ARROW_DELIMITER', got 'MINUS'",
|
||||||
expect(result[0]).toMatchObject({
|
|
||||||
from: { line: 3, col: 8 },
|
from: { line: 3, col: 8 },
|
||||||
to: { line: 3, col: 9 }
|
to: { line: 3, col: 9 }
|
||||||
});
|
}]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -39,9 +39,14 @@ export async function validateMermaid(text: string) {
|
|||||||
firstCol = 0;
|
firstCol = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let messageLines = mermaidError.message.split("\n");
|
||||||
|
if (messageLines.length >= 4) {
|
||||||
|
messageLines = messageLines.slice(3);
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
message: mermaidError.message,
|
message: messageLines.join("\n"),
|
||||||
severity: "error",
|
severity: "error",
|
||||||
from: CodeMirror.Pos(loc.first_line - 1, firstCol),
|
from: CodeMirror.Pos(loc.first_line - 1, firstCol),
|
||||||
to: CodeMirror.Pos(loc.last_line - 1, lastCol)
|
to: CodeMirror.Pos(loc.last_line - 1, lastCol)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user