Automattic / Automattic/harper

A non-greedy `RepeatingPattern` would be handy

Open
#1,261 4 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue harper-core linting
Dominant language
Rust
Stars
15.4k
Forks
627
Avg merge
1d 15h
Merged PRs (30d)
102

Description

## Description

For patterns that can match multiple variants you often have to figure out which one was matched inside `match_to_lint()`.
One way to do that would be to use another pattern inside `match_to_lint()` that did the equivalent of `/.*?"word"/`.
Currently `RepeatingPattern` is always greedy so it will match to the end of the chunk. Then whatever is after it can't match.

This is my use case but there's bound to be others since this is common in pattern matching.

## Component

- Core grammar checking engine

Contributor guide

Open the contributing guide

Research direction

Start by tracing RepeatingPattern and match_to_lint() in the core grammar checking engine, then inspect how a repeated match currently consumes the chunk. Define how a non-greedy option should interact with following patterns and cover the /.*?"word"/ use case; done means later pattern components can match after the shortest valid repetition.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.