Skip to content

feat: print linter match with context#2303

Merged
elijah-potter merged 5 commits intoAutomattic:masterfrom
hippietrail:linter-debugging-print-match-with-context
Mar 4, 2026
Merged

feat: print linter match with context#2303
elijah-potter merged 5 commits intoAutomattic:masterfrom
hippietrail:linter-debugging-print-match-with-context

Conversation

@hippietrail
Copy link
Copy Markdown
Collaborator

@hippietrail hippietrail commented Dec 7, 2025

Issues

N/A

Description

Formats a lint match with surrounding context for debug output.

This is a handy little tool for when you're working on a new ExprLinter.

Using the new match_to_lint_with_context method it will print the run of text that matches, along with the text before and after it dimmed using ANSI escape codes.

This can help you hone in your Expr before you start working on extracting the lint.
When you're wondering about false positives or trying to sort them out, this helps you see what the most common previous or next words, or several words tend to be.

It does its best to filter out distracting markup that's sometimes between tokens and printed if you just do toks.span()?.get_content_string(src) since that will get everything between the start and the end. You would've seen this when linting Markdown files containing HTML on the command line.

Works great from cargo test or via the smarts in the editor and Rust LSP, and works really great from the new harper-cli lint run over a directory full of files.

Demo

Screenshot 2025-12-07 at 11 35 49 pm

The ❤️ is not included, I just like it to make messages stand out in the log (-:

How Has This Been Tested?

Manually.

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes

@elijah-potter elijah-potter added this pull request to the merge queue Mar 4, 2026
Merged via the queue into Automattic:master with commit ffd142c Mar 4, 2026
11 checks passed
@hippietrail hippietrail deleted the linter-debugging-print-match-with-context branch March 5, 2026 04:34
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Mar 24, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [Automattic/harper/harper-ls](https://github.com/Automattic/harper) | minor | `v1.9.0` → `v1.12.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>Automattic/harper (Automattic/harper/harper-ls)</summary>

### [`v1.12.0`](https://github.com/Automattic/harper/releases/tag/v1.12.0)

[Compare Source](Automattic/harper@v1.11.0...v1.12.0)

#### What's Changed

- fix(chrome-ext): formatting issues on Google Docs by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2960](Automattic/harper#2960)
- feat: grind to halt → grind to a halt by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2972](Automattic/harper#2972)
- fix: correct typos and grammar in docs and comments by [@&#8203;cl2t](https://github.com/cl2t) in [#&#8203;2971](Automattic/harper#2971)
- feat: bullocks→bollocks by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2970](Automattic/harper#2970)
- feat: add lint rule for "more that likely" typo by [@&#8203;ctonneslan](https://github.com/ctonneslan) in [#&#8203;2964](Automattic/harper#2964)
- fix: solve issue [#&#8203;2966](Automattic/harper#2966) by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2967](Automattic/harper#2967)
- feat: I am worry→I am worried by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2943](Automattic/harper#2943)
- feat: add lint rule for "cutting age" eggcorn by [@&#8203;ctonneslan](https://github.com/ctonneslan) in [#&#8203;2965](Automattic/harper#2965)
- feat: at the expanse of→at the expense of by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2926](Automattic/harper#2926)

#### New Contributors

- [@&#8203;cl2t](https://github.com/cl2t) made their first contribution in [#&#8203;2971](Automattic/harper#2971)
- [@&#8203;ctonneslan](https://github.com/ctonneslan) made their first contribution in [#&#8203;2964](Automattic/harper#2964)

**Full Changelog**: <Automattic/harper@v1.11.0...v1.12.0>

### [`v1.11.0`](https://github.com/Automattic/harper/releases/tag/v1.11.0)

[Compare Source](Automattic/harper@v1.10.0...v1.11.0)

#### What's Changed

- chore: dictionary curation by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2867](Automattic/harper#2867)
- feat: do a mistake→make a mistake by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2463](Automattic/harper#2463)
- refactor: two-digit decade support by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2911](Automattic/harper#2911)
- fix: warn about clashing linter names by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2374](Automattic/harper#2374)
- feat(core): flag redundant use of progressive verbs followed by "more" by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2859](Automattic/harper#2859)
- feat: hit the nail in the head→on the head by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2918](Automattic/harper#2918)
- build(deps): bump tempfile from 3.20.0 to 3.27.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2939](Automattic/harper#2939)
- build(deps): bump tree-sitter-lua from 0.4.1 to 0.5.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2938](Automattic/harper#2938)
- build(deps): bump clap from 4.5.60 to 4.6.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2937](Automattic/harper#2937)
- fix(core): test which was testing the wrong thing by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2946](Automattic/harper#2946)
- feature/obsidian-colored lints by [@&#8203;stanley-910](https://github.com/stanley-910) in [#&#8203;2931](Automattic/harper#2931)
- refactor: `once_cell`→`LazyLock` by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2942](Automattic/harper#2942)
- deps: bump rand to 0.10.0 by [@&#8203;86xsk](https://github.com/86xsk) in [#&#8203;2947](Automattic/harper#2947)
- feat: commitment toward(s) → commitment to by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2948](Automattic/harper#2948)
- feat: add geo acronyms by [@&#8203;tongpu](https://github.com/tongpu) in [#&#8203;2687](Automattic/harper#2687)
- feat: bump spell fixes differing by an apostrophe by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2927](Automattic/harper#2927)
- build(deps): bump once\_cell from 1.21.3 to 1.21.4 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2936](Automattic/harper#2936)
- feat(chrome-ext): replace icons with cleaner variants by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2949](Automattic/harper#2949)
- feat: reason of doing→reason for doing by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2953](Automattic/harper#2953)
- feat: the different(s) between→the difference between by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2951](Automattic/harper#2951)
- Dictionary curation 2026 03 13 by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2941](Automattic/harper#2941)
- perf(core): avoid cloning in `DictWordMetadata::append` by [@&#8203;86xsk](https://github.com/86xsk) in [#&#8203;2912](Automattic/harper#2912)
- refactor: most `ExprLinter`s don't need to be boxed by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2885](Automattic/harper#2885)
- feat: womans→women, writed→wrote, etc. by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2812](Automattic/harper#2812)

#### New Contributors

- [@&#8203;tongpu](https://github.com/tongpu) made their first contribution in [#&#8203;2687](Automattic/harper#2687)

**Full Changelog**: <Automattic/harper@v1.10.0...v1.11.0>

### [`v1.10.0`](https://github.com/Automattic/harper/releases/tag/v1.10.0)

[Compare Source](Automattic/harper@v1.9.0...v1.10.0)

#### What's Changed

- build(deps): bump pulldown-cmark from 0.13.0 to 0.13.1 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2848](Automattic/harper#2848)
- build(deps): bump chrono from 0.4.43 to 0.4.44 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2852](Automattic/harper#2852)
- build(deps): bump quickcheck from 1.0.3 to 1.1.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2850](Automattic/harper#2850)
- chore: dictionary curation by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2822](Automattic/harper#2822)
- build(deps): bump zip from 8.0.0 to 8.1.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2849](Automattic/harper#2849)
- build(deps): bump strum\_macros from 0.27.2 to 0.28.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2851](Automattic/harper#2851)
- feat: hidden into→hidden in by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2844](Automattic/harper#2844)
- feat: the point for→the point of by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2834](Automattic/harper#2834)
- feat(core): more edge cases in `MissingTo` rule by [@&#8203;lewismiddleton](https://github.com/lewismiddleton) in [#&#8203;2837](Automattic/harper#2837)
- feat(core): `chalkboard` is a closed compound by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2858](Automattic/harper#2858)
- feat(chrome-ext): build out support for the online Typst playground by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2706](Automattic/harper#2706)
- fix(core): edge case in `ItsPossessive` rule by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2857](Automattic/harper#2857)
- feat: print linter match with context by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2303](Automattic/harper#2303)
- feat: fed up of→fed up with by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2833](Automattic/harper#2833)
- feat(obsidian): listen to changes to `data.json` by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2868](Automattic/harper#2868)
- fix(obsidian): remove default hotkey by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2869](Automattic/harper#2869)
- feat: get used of→get used to by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2831](Automattic/harper#2831)
- fix: don't flag "our IT" by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2872](Automattic/harper#2872)
- feat: flag "often never" and similar by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2871](Automattic/harper#2871)
- fix(core): recognize "esp." as an abbreviation by [@&#8203;NaveenPrasanth](https://github.com/NaveenPrasanth) in [#&#8203;2816](Automattic/harper#2816)
- fix(core): adjust how words are iterated in `title_case` by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2875](Automattic/harper#2875)
- feat: off coarse→of course by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2878](Automattic/harper#2878)
- feat(chrome-ext): support for Google Docs by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2791](Automattic/harper#2791)
- refactor(core): refactor code in `MissingTo` by [@&#8203;86xsk](https://github.com/86xsk) in [#&#8203;2876](Automattic/harper#2876)
- feat: IIUC→if I understand correctly by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2896](Automattic/harper#2896)
- build(deps): bump tree-sitter-powershell from 0.25.10 to 0.26.3 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2890](Automattic/harper#2890)
- build(deps): bump uuid from 1.21.0 to 1.22.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2889](Automattic/harper#2889)
- build(deps): bump tokio from 1.49.0 to 1.50.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2891](Automattic/harper#2891)
- fix(harper-tex): math mode problems by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2899](Automattic/harper#2899)
- build(deps): bump sysinfo from 0.38.2 to 0.38.3 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2893](Automattic/harper#2893)
- refactor: tests for spell/mod.rs and and linting/spell\_check.rs were arbitrarily mixed by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2809](Automattic/harper#2809)
- feat: aware about→aware of by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2902](Automattic/harper#2902)
- feat: it´s→it's by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2884](Automattic/harper#2884)
- feat: in some degree→to some degree by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2883](Automattic/harper#2883)
- feat(chrome-ext): surface update instructions by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2873](Automattic/harper#2873)
- feat: take/claim/assume responsibility of→responsibility for by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2880](Automattic/harper#2880)
- feat: correct decades with apostrophes by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2886](Automattic/harper#2886)
- fix(core): false positives in the `NeedToNoun` rule by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2905](Automattic/harper#2905)
- fix(chrome-ext): formatted text in Google Docs causing false-positives by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2904](Automattic/harper#2904)
- feat: rise the ranks→rise through/from the ranks by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2903](Automattic/harper#2903)
- perf(core): add early exits for `lex_url`, `lex_email_address` by [@&#8203;86xsk](https://github.com/86xsk) in [#&#8203;2910](Automattic/harper#2910)
- build(deps): bump quinn-proto from 0.11.13 to 0.11.14 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2908](Automattic/harper#2908)
- fix(core): `VerbToAdjective` false positives by [@&#8203;elijah-potter](https://github.com/elijah-potter) in [#&#8203;2906](Automattic/harper#2906)
- feat: not only it is→not only is it by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2907](Automattic/harper#2907)
- feat: compulse→compel by [@&#8203;hippietrail](https://github.com/hippietrail) in [#&#8203;2909](Automattic/harper#2909)
- feat(harper-cli): add --format flag with json and compact output modes by [@&#8203;dumb-kevin](https://github.com/dumb-kevin) in [#&#8203;2843](Automattic/harper#2843)

#### New Contributors

- [@&#8203;lewismiddleton](https://github.com/lewismiddleton) made their first contribution in [#&#8203;2837](Automattic/harper#2837)
- [@&#8203;dumb-kevin](https://github.com/dumb-kevin) made their first contribution in [#&#8203;2843](Automattic/harper#2843)

**Full Changelog**: <Automattic/harper@v1.9.0...v1.10.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My42Ni4zIiwidXBkYXRlZEluVmVyIjoiNDMuNzguMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants