You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(code-block-tools): stop a linter in a format slot from overwriting the block
The format path takes a tool's stdout as the block's replacement, so a linter
configured there wrote its report into the document: `format = ["ruff:check"]`
rewrote a clean Python block to the literal text `All checks passed!`. Neither
existing guard caught it, because a linter with nothing to complain about exits
0 and can still print a summary line.
A tool that cannot format is now skipped, using the same predicate that already
reports the mistake as a config warning. User-defined tools are unaffected: the
user wrote the command, so rumdl has no opinion about what it does.
Documents the slot rules alongside the built-in tools table: what a bare tool id
resolves to in each slot, that `terraform-fmt` is an alias of `terraform:format`,
that a formatter in a lint slot is a formatting check, and how a finding without
a machine-readable position is placed.
@@ -153,6 +153,46 @@ built-in YAML linter. To lint YAML blocks, wire in a custom tool such as
153
153
[ryl](https://github.com/owenlamont/ryl) (see
154
154
[Linting YAML blocks with ryl](#linting-yaml-blocks-with-ryl)).
155
155
156
+
### Tool IDs and Slots
157
+
158
+
A tool with more than one mode is registered as `tool:mode` (`ruff:check`,
159
+
`ruff:format`, `sqlfluff:lint`, `tombi:format`). A bare name resolves to the
160
+
variant that fits the slot it is written in, so `lint = ["sqlfluff"]` runs
161
+
`sqlfluff:lint` and `format = ["tombi"]` runs `tombi:format`. `terraform-fmt` is
162
+
kept as an alias of `terraform:format`, so a config written either way works.
163
+
164
+
**A formatter in a `lint` slot is a formatting check.** rumdl runs the formatter,
165
+
compares its output with the block, and reports `Code block is not formatted` when
166
+
they differ:
167
+
168
+
```toml
169
+
[code-block-tools.languages]
170
+
python = { lint = ["black"], format = ["black"] }
171
+
```
172
+
173
+
The comparison is exactly what `rumdl fmt` would rewrite, so `check` and `fmt`
174
+
cannot disagree. rumdl does not pass a tool's own `--check` or `--diff` flag:
175
+
those disagree across tools on exit code, on what they print, and on whether the
176
+
flag is even accepted next to the stdin argument the tool requires.
177
+
178
+
**A linter in a `format` slot is declined.** A linter writes its report to stdout,
179
+
which is where the formatted code would come from, so running one would replace
180
+
the block with its own output. rumdl skips such a tool and reports the
181
+
configuration instead:
182
+
183
+
```text
184
+
Tool in code-block-tools.languages.python.format cannot format: ruff:check is a linter (move it to lint)
185
+
```
186
+
187
+
An id that names no tool at all is reported the same way, with a suggestion:
188
+
189
+
```text
190
+
Unknown tool in code-block-tools.languages.python.format: blackk (did you mean: black?)
191
+
```
192
+
193
+
Both warnings are emitted whether or not `enabled` is set, so a typo surfaces
194
+
before the feature is switched on.
195
+
156
196
### Embedded Markdown Linting
157
197
158
198
The special `rumdl` tool enables linting of markdown content inside fenced code blocks:
@@ -266,6 +306,13 @@ With this configuration:
266
306
267
307
Tool output references lines within the code block. rumdl maps these to the actual markdown file line numbers so diagnostics point to the correct location.
268
308
309
+
A tool that reports a position only in prose (`jq`'s "at line 1, column 9") is
310
+
mapped from that prose. A tool that reports no position at all is anchored on the
311
+
opening fence, which is the most precise place rumdl can honestly point to. The
312
+
built-in definitions ask for a machine-readable format where the tool has one, so
313
+
findings land on their own line rather than on the fence: `sqlfluff:lint` uses
314
+
GitHub annotations and `djlint` uses an explicit `--linter-output-format`.
315
+
269
316
### Indented Code Blocks
270
317
271
318
For code blocks inside lists or blockquotes, rumdl:
0 commit comments