Skip to content

feat(lint): add LifetimeLife rule to catch 'lifetime' where 'life' is meant#3518

Open
jlaportebot wants to merge 4 commits into
Automattic:masterfrom
jlaportebot:feat/lifetime-life-lint
Open

feat(lint): add LifetimeLife rule to catch 'lifetime' where 'life' is meant#3518
jlaportebot wants to merge 4 commits into
Automattic:masterfrom
jlaportebot:feat/lifetime-life-lint

Conversation

@jlaportebot
Copy link
Copy Markdown
Contributor

@jlaportebot jlaportebot commented May 27, 2026

Summary

Adds a new lint rule (LifetimeLife) that detects common misuse of lifetime in superlative expressions where life is the correct word.

What it catches

Patterns where a superlative adjective is followed by a noun, a preposition (of/in), a possessive determiner, and lifetime:

  • "the best day of my lifetime" → "the best day of my life"
  • "the biggest change in your lifetime" → "the biggest change in your life"
  • "the most influential person in our lifetime" → "the most influential person in our life"
  • "the greatest achievement of his lifetime" → "the greatest achievement of his life"

Also handles bare forms without possessives: "the best game of lifetime" → "the best game of life"

What it does NOT flag (false positive avoidance)

  • "once in a lifetime opportunity" — idiomatic, correct
  • "lifetime achievement award" — lifetime as attributive modifier
  • "lifetime warranty" / "lifetime guarantee" / "lifetime access" / "lifetime membership" — valid attributive uses
  • "the lifetime of this component" — lifetime meaning duration

Implementation

  • ExprLinter using Sentence-level matching with FirstMatchOf across 9 pattern variants (3 prepositions × 3 possessive variants)
  • Uses then_fixed_phrase for the preposition + possessive + lifetime pattern
  • Excludes prepositions from the noun-gap matcher
  • 18 unit tests (8 positive, 6 negative, 4 compound noun)

AI Disclosure

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

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.

jlaportebot and others added 4 commits May 26, 2026 23:38
… meant

Detects common misuse of 'lifetime' in superlative expressions where
'life' is the correct word. Catches patterns like 'the best day of my
lifetime' (→ 'life'), 'the biggest change in your lifetime' (→ 'life'),
and similar constructions with superlative adjectives + preposition +
possessive + lifetime.

Does NOT flag valid uses: 'lifetime achievement', 'lifetime warranty',
'once in a lifetime', etc.

18 tests covering both detection and false-positive avoidance.
The test  was
failing because LifetimeLife was registered as a rule but missing
from default_config.json.
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