fix(core): report parameter errors at their line with a quoting hint (#13)

An unquoted comma in a flow-mapping label splits it into a valueless key.
Parameter diagnostics now point at the parameter's own frontmatter line,
and a valueless unknown field says that the value needs quotes.
This commit is contained in:
Florian Schmidt
2026-11-16 14:45:53 +01:00
parent dd0af5d580
commit 6bfcc9d70d
2 changed files with 32 additions and 10 deletions
+8
View File
@@ -80,6 +80,14 @@ describe("parser", () => {
])("reports malformed input without throwing: %s", (source, message) => {
expect(parseNotebook(source).diagnostics.some(d => d.message.includes(message))).toBe(true);
});
it("points an unquoted comma in a flow-mapping label at the parameter line with a fix", () => {
const n = parseNotebook("---\ntitle: T\nparams:\n host: { type: host }\n key: { type: secret, label: Auth key (optional, else log in) }\n---\n# T\n");
expect(n.diagnostics).toEqual([{
severity: "error",
line: 5,
message: 'Unknown parameter field "else log in)" for key. A value containing a comma needs quotes, e.g. label: "a, b"',
}]);
});
it("uses title fallback, numeric step ids, CRLF ranges and exact script whitespace", () => {
expect(parseNotebook("").title).toBe("Untitled");
const n = parseNotebook("---\r\ntitle: Front\r\n---\r\n# Heading\r\n```sh {run}\r\n echo x \r\n\r\n```\r\n");