Skip to content

Commit 2de6e15

Browse files
committed
fix(core): AnA linter did not recognize capital articles
1 parent 2105cfd commit 2de6e15

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

harper-core/src/linting/an_a.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ impl Linter for AnA {
3333

3434
let is_a_an = match chars_first {
3535
['a'] => Some(true),
36+
['A'] => Some(true),
3637
['a', 'n'] => Some(false),
38+
['A', 'n'] => Some(false),
3739
_ => None,
3840
};
3941

@@ -52,7 +54,10 @@ impl Linter for AnA {
5254
lints.push(Lint {
5355
span: first.span,
5456
lint_kind: LintKind::Miscellaneous,
55-
suggestions: vec![Suggestion::ReplaceWith(replacement)],
57+
suggestions: vec![Suggestion::replace_with_match_case(
58+
replacement,
59+
chars_first,
60+
)],
5661
message: "Incorrect indefinite article.".to_string(),
5762
priority: 31,
5863
})
@@ -113,7 +118,8 @@ fn starts_with_vowel(word: &[char]) -> bool {
113118
| ['u', 'n', 'i', 'n' | 'm', ..]
114119
| ['u', 'n', 'a' | 'u', ..]
115120
| ['h', 'e', 'r', 'b', ..]
116-
| ['u', 'r', 'b', ..])
121+
| ['u', 'r', 'b', ..]
122+
| ['i', 'n', 't', ..])
117123
{
118124
return true;
119125
}
@@ -250,4 +256,13 @@ mod tests {
250256
fn disallows_uppercase_consonants() {
251257
assert_lint_count("not an Crash", AnA, 1);
252258
}
259+
260+
#[test]
261+
fn disallows_a_interface() {
262+
assert_lint_count(
263+
"A interface for an object that can perform linting actions.",
264+
AnA,
265+
1,
266+
);
267+
}
253268
}

0 commit comments

Comments
 (0)