Skip to content

fix(linting): add attributive-safe adjective exclusion for MissingPreposition#3683

Open
jlaportebot wants to merge 2 commits into
Automattic:masterfrom
jlaportebot:fix/missing-preposition-false-positive-best-friends
Open

fix(linting): add attributive-safe adjective exclusion for MissingPreposition#3683
jlaportebot wants to merge 2 commits into
Automattic:masterfrom
jlaportebot:fix/missing-preposition-false-positive-best-friends

Conversation

@jlaportebot

Copy link
Copy Markdown
Contributor

Summary

  • Add ATTRIBUTIVE_SAFE_ADJECTIVES constant with 29 common superlatives and attributive-only adjectives (best, worst, closest, dearest, etc.)
  • Add is_attributive_safe() helper for case-insensitive matching
  • Skip MissingPreposition lint when adjective is in safe list
  • Add test allows_best_friends() covering 7 cases

Problem

The MissingPreposition lint was incorrectly flagging phrases like:

  • "We were best friends"
  • "They are closest friends"
  • "She is my dearest friend"
  • "This is the finest example"

These use adjectives that can function attributively (directly modifying a noun) without requiring a preposition.

Solution

Maintain a list of known attributive-safe adjectives and check against it before emitting the lint. This is a targeted fix that avoids false positives while preserving the lint's ability to catch genuine missing prepositions.

Testing

Added comprehensive test case covering all 7 example phrases from the issue.

…position

- Add ATTRIBUTIVE_SAFE_ADJECTIVES constant with 29 common superlatives and
  attributive-only adjectives (best, worst, closest, dearest, etc.)
- Add is_attributive_safe() helper for case-insensitive matching
- Skip MissingPreposition lint when adjective is in safe list
- Add test allows_best_friends() covering 7 cases

Fixes false positives like "We were best friends" and "They are closest friends".
- Replace fixed index lookup with dynamic search for UPOS::ADJ token
- Handles variable whitespace token inclusion in matched_tokens
- Fixes test failure for 'allows_best_friends'
@jlaportebot

Copy link
Copy Markdown
Contributor Author

All CI checks passing. PR ready for merge queue.

@hippietrail

Copy link
Copy Markdown
Collaborator

All CI checks passing. PR ready for merge queue.

Please use our PR template as the AI-related fields in it are important to us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants