ludic fmt for editors: --lint --json, and a buffer on stdin (R9)
ludic-fmt --lint --json prints the violations --lint reports as one JSON array on stdout,
[{file, line, col, rule, message}] ordered by file, line and column (col where the rule knows it),
the summary on stderr, --lint's exit status, and never rewrites the baseline. ludic-fmt - refuses a
buffer that does not read as Ludic (a string/template/key literal left open, a bracket never closed
or closed by the wrong one) with exit 2 and name:line:col on stderr; - --lint judges a buffer as the
file --stdin-name names (--stdin-rel: that path relative to the project), against its baseline and
lint paths. ludic fmt --lint and ludic fmt - run it from the nearest package.ludic upwards (from
--stdin-name's directory when given). Hooks read nothing and write to stderr under --json or -.
Regression cases added to test-tools and ludic-dev test (fmt_editor_cases), not run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c804c4b0ee
commit
047bdf4189
13 changed files with 405 additions and 17 deletions
|
|
@ -104,14 +104,23 @@ function lint_judge(init: bool) -> bool {
|
|||
file_close(f)
|
||||
}
|
||||
}
|
||||
print(` lint: {total} violation(s) in the baseline, {len(pf)} file/rule pair(s)`)
|
||||
let summary = ` lint: {total} violation(s) in the baseline, {len(pf)} file/rule pair(s)`
|
||||
if lt_json {
|
||||
lt_err(`{summary}\n`)
|
||||
lt_json_out()
|
||||
} else { print(summary) }
|
||||
return ok
|
||||
}
|
||||
function lt_print_pair(path: string, rule: string, now: int, allow: int) -> void {
|
||||
var i = 0
|
||||
while i < len(lr_file) {
|
||||
if lr_file[i] == path and lr_rule[i] == rule { print(`{path}:{lr_line[i]}: {rule}: {lr_msg[i]}`) }
|
||||
if lr_file[i] == path and lr_rule[i] == rule {
|
||||
if lt_json { push(lj_idx, i) } else { print(`{lt_shown(path)}:{lr_line[i]}: {rule}: {lr_msg[i]}`) }
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
if allow > 0 { print(` ({path} may have {allow} of {rule}, and has {now})`) }
|
||||
if allow > 0 {
|
||||
let note = ` ({lt_shown(path)} may have {allow} of {rule}, and has {now})`
|
||||
if lt_json { lt_err(`{note}\n`) } else { print(note) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue