mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 02:02:29 +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);
|
||||
expect(result.length).toBe(1);
|
||||
expect(result[0].message).toSatisfy((v: string) => v.includes("Expecting 'SPACE'"));
|
||||
expect(result[0]).toMatchObject({
|
||||
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 () => {
|
||||
@ -35,11 +34,10 @@ describe("Mermaid linter", () => {
|
||||
`;
|
||||
|
||||
const result = await validateMermaid(input);
|
||||
expect(result.length).toBe(1);
|
||||
expect(result[0].message).toSatisfy((v: string) => v.includes("Expecting 'ARROW_DELIMITER'"));
|
||||
expect(result[0]).toMatchObject({
|
||||
expect(result).toMatchObject([{
|
||||
message: "Expecting 'ARROW_DELIMITER', got 'MINUS'",
|
||||
from: { line: 3, col: 8 },
|
||||
to: { line: 3, col: 9 }
|
||||
});
|
||||
}]);
|
||||
});
|
||||
});
|
||||
|
@ -39,9 +39,14 @@ export async function validateMermaid(text: string) {
|
||||
firstCol = 0;
|
||||
}
|
||||
|
||||
let messageLines = mermaidError.message.split("\n");
|
||||
if (messageLines.length >= 4) {
|
||||
messageLines = messageLines.slice(3);
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
message: mermaidError.message,
|
||||
message: messageLines.join("\n"),
|
||||
severity: "error",
|
||||
from: CodeMirror.Pos(loc.first_line - 1, firstCol),
|
||||
to: CodeMirror.Pos(loc.last_line - 1, lastCol)
|
||||
|
Loading…
x
Reference in New Issue
Block a user