mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 01:05:55 +03:00
[GH-ISSUE #1979] Expose fix mode to custom rules (params.fixMode) #2643
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#2643
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @chalin on GitHub (Feb 24, 2026).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1979
Custom rules can emit
fixInfo, but they currently can’t reliably detect whether the run is check-only or fix-enabled.For rules with expensive fix-only logic, this matters:
Today, a workaround is
process.argv.includes('--fix'), which is brittle in non-CLI/programmatic contexts.Feature request:
params.fixMode: boolean)doc/CustomRules.mdEnvironment:
Thanks for such a great tool!
@DavidAnson commented on GitHub (Feb 24, 2026):
I see what you're getting at with this, but two things make me reluctant to implement something like this:
My experience is that most fix code is pretty trivial once a rule has run its detection logic and computed any relevant ranges to log the issue. So I claim the incremental cost of providing fix info is negligible most/almost all of the time. Off the top of my head, I claim none of the built-in rules involve expensive fix logic, though I would be happy to consider examples if you have some in mind.
Some scenarios – notably the Visual Studio Code extension – would always run in fix mode which means this optimization has no benefit. Arguably, the interactive Nature of the Code extension is the most performance critical of all, so if implementing this feature encouraged people to write fix code that was slow to run, that would be counterproductive.
@chalin commented on GitHub (Mar 2, 2026):
Hi @DavidAnson. Thanks for the prompt reply with the context. I'm OOO for a few weeks. I'll share my motivating use case when I'm back.