Skip to content

feat: enhance the ToTo linter - #4100

Merged
hippietrail merged 2 commits into
Automattic:masterfrom
hippietrail:to-to-exceptions
Aug 18, 2026
Merged

feat: enhance the ToTo linter#4100
hippietrail merged 2 commits into
Automattic:masterfrom
hippietrail:to-to-exceptions

Conversation

@hippietrail

Copy link
Copy Markdown
Collaborator

Issues

N/A

Description

Previously it always flagged "to to" and only suggested "to do".

It did not cooperate with RepeatedWords to suggest dropping the second "to", since that's not possible.

It was not aware of patterns where "to to" is grammatically correct, such as after certain verbs and before a verb in the infinitive.

This PR moved the old linter out of phrase_set_corrections into a custom Rust linter.

I also added a new surrounded_by_words() method to ExprLinter that combines the existing followed_by_token() and preceded_by_word().

How Has This Been Tested?

cargo test

AI Disclosure

  • I am a human and didn't use any AI.
  • I used LLM features of my editor, but not an agent.
  • I consulted one or more coding AIs, but didn't use an agent.
  • I used an AI agent interactively.
  • I am an agent or I got an agent to do the work autonomously.

I asked Google's AI to suggest how best to implement surrounded_by_words() and to write the doc comments.

If Your PR Implements or Enhances a Linter

  • I made up the sentences in the unit tests.
  • The sentences in the unit tests were generated by an AI.
  • I'm using examples from the bug report / feature request.
  • I collected real-world sentences for the unit tests.

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • I have considered splitting this into smaller pull requests.

Previously it always flagged "to to" and only suggested "to do".

It did not cooperate with `RepeatedWords` to suggest dropping the second "to", since that's not possible.

It was not aware of patterns where "to to" is grammatically correct, such as after certain verbs and before a verb in the infinitive.
@hippietrail hippietrail added rust Pull requests that update Rust code linting Related to lint rules and linter execution labels Aug 18, 2026
@hippietrail
hippietrail enabled auto-merge August 18, 2026 09:58
@hippietrail
hippietrail added this pull request to the merge queue Aug 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Aug 18, 2026
@hippietrail
hippietrail added this pull request to the merge queue Aug 18, 2026
Merged via the queue into Automattic:master with commit 3a3e520 Aug 18, 2026
20 of 21 checks passed
@hippietrail
hippietrail deleted the to-to-exceptions branch August 18, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linting Related to lint rules and linter execution rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant