Skip to content

Commit c32bfbf

Browse files
fix(core): adjust ToTwoToo linter to ignore transitions (#2761)
1 parent 359cf06 commit c32bfbf

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

harper-core/src/linting/to_two_too/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,4 +448,19 @@ mod tests {
448448
fn no_lint_prone_to_melancholy() {
449449
assert_no_lints("He wasn’t a man prone to melancholy.", ToTwoToo::default());
450450
}
451+
452+
#[test]
453+
fn no_lint_superlative_range() {
454+
assert_no_lints("Sort speeds from slowest to fastest.", ToTwoToo::default());
455+
}
456+
457+
#[test]
458+
fn no_lint_comparative_range() {
459+
assert_no_lints("We rank tasks from harder to easier.", ToTwoToo::default());
460+
}
461+
462+
#[test]
463+
fn still_lints_positive_adjective_end() {
464+
assert_lint_count("The room felt to cold.", ToTwoToo::default(), 1);
465+
}
451466
}

harper-core/src/linting/to_two_too/to_too_adjective_end.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ impl ExprLinter for ToTooAdjectiveEnd {
5353
while idx < tokens.len() && tokens[idx].kind.is_whitespace() {
5454
idx += 1;
5555
}
56-
if idx >= tokens.len() || !tokens[idx].kind.is_adjective() {
56+
if idx >= tokens.len()
57+
|| !tokens[idx].kind.is_adjective()
58+
|| !tokens[idx].kind.is_positive_adjective()
59+
{
5760
return None;
5861
}
5962
let prev_non_ws = tokens[..to_index].iter().rfind(|t| !t.kind.is_whitespace());

harper-core/src/linting/to_two_too/to_too_adjective_punct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl ExprLinter for ToTooAdjectivePunct {
5353
return None;
5454
}
5555
let adjective = &tokens[idx];
56-
if !adjective.kind.is_adjective() {
56+
if !adjective.kind.is_adjective() || !adjective.kind.is_positive_adjective() {
5757
return None;
5858
}
5959
if adjective.kind.is_preposition() {

0 commit comments

Comments
 (0)