refactor: upgrade Expatriate to phrase_set_corrections (#2265)

This commit is contained in:
Andrew Dunbar
2025-12-01 16:58:09 +00:00
committed by GitHub
parent 5ac4c0ad2e
commit 4c539bc75f
4 changed files with 97 additions and 10 deletions

View File

@@ -426,13 +426,6 @@ pub fn lint_group() -> LintGroup {
"Expands the abbreviation `w/o` to the full word `without` for clarity.",
LintKind::Style
),
"Expatriate" => (
["ex-patriot"],
["expatriate"],
"Use the correct term for someone living abroad.",
"Fixes the misinterpretation of `expatriate`, ensuring the correct term is used for individuals residing abroad.",
LintKind::Eggcorn
),
"FaceFirst" => (
["face first into"],
["face-first into"],

View File

@@ -770,9 +770,6 @@ fn expand_cuz() {
// ExpandWithout
// -none-
// Expatriate
// -none-
// FaceFirst
// -none-

View File

@@ -352,6 +352,26 @@ pub fn lint_group() -> LintGroup {
"Suggests using either `await` or `wait for` but not both, as they express the same meaning.",
LintKind::Redundancy
),
"Expat" => (
&[
(&["ex-pat", "ex pat"], &["expat"]),
(&["ex-pats", "ex pats"], &["expats"]),
(&["ex-pat's", "ex pat's"], &["expat's"]),
],
"The correct spelling is `expat` with no hyphen or space.",
"Corrects the mistake of writing `expat` as two words.",
LintKind::Spelling
),
"Expatriate" => (
&[
(&["ex-patriot", "expatriot", "ex patriot"], &["expatriate"]),
(&["ex-patriots", "expatriots", "ex patriots"], &["expatriates"]),
(&["ex-patriot's", "expatriot's", "ex patriot's"], &["expatriate's"]),
],
"Use the correct term for someone living abroad.",
"Fixes the misinterpretation of `expatriate`, ensuring the correct term is used for individuals residing abroad.",
LintKind::Eggcorn
),
"GetRidOf" => (
&[
(&["get rid off", "get ride of", "get ride off"], &["get rid of"]),

View File

@@ -888,6 +888,83 @@ fn correct_awaited_for() {
);
}
// Expat
#[test]
fn correct_ex_pat_hyphen() {
assert_suggestion_result(
"It seems ex-pat means the person will be in a foreign country temporarily",
lint_group(),
"It seems expat means the person will be in a foreign country temporarily",
);
}
#[test]
fn correct_ex_pats_hyphen() {
assert_suggestion_result(
"So, it might be correct to call most Brits ex-pats.",
lint_group(),
"So, it might be correct to call most Brits expats.",
);
}
#[test]
fn correct_ex_pat_space() {
assert_suggestion_result(
"For me, the term ex pat embodies the exquisite hypocrisy of certain people feeling entitled",
lint_group(),
"For me, the term expat embodies the exquisite hypocrisy of certain people feeling entitled",
);
}
#[test]
#[ignore = "replace_with_match_case results in ExPats"]
fn correct_ex_pats_space() {
assert_suggestion_result(
"Why are Brits who emigrate \"Ex Pats\" but people who come here \"immigrants\"?",
lint_group(),
"Why are Brits who emigrate \"Expats\" but people who come here \"immigrants\"?",
);
}
// Expatriate
#[test]
fn correct_expatriot() {
assert_suggestion_result(
"Another expatriot of the era, James Joyce, also followed Papa's writing and drinking schedule.",
lint_group(),
"Another expatriate of the era, James Joyce, also followed Papa's writing and drinking schedule.",
);
}
#[test]
fn correct_expatriots() {
assert_suggestion_result(
"Expatriots, upon discovering the delightful nuances of Dutch pronunciation, often find themselves in stitches.",
lint_group(),
"Expatriates, upon discovering the delightful nuances of Dutch pronunciation, often find themselves in stitches.",
);
}
#[test]
fn correct_ex_patriot_hyphen() {
assert_suggestion_result(
"Then I added we should all be using the word 移民 immigrant, not ex-patriot, not 外国人 gaikokujin, and definitely not 外人 gaijin",
lint_group(),
"Then I added we should all be using the word 移民 immigrant, not expatriate, not 外国人 gaikokujin, and definitely not 外人 gaijin",
);
}
#[test]
fn correct_ex_patriots_hyphen() {
assert_suggestion_result(
"Ex-patriots who move to Hong Kong to seek greener pastures and to experience a new culture seem to bring their own cultural baggage with them.",
lint_group(),
"Expatriates who move to Hong Kong to seek greener pastures and to experience a new culture seem to bring their own cultural baggage with them.",
);
}
// GetRidOf
#[test]