Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(weir): add BoarderBorder rule to catch boarder/border word confusion (#3481)
Mister Lobster8aefcb89cb2f
diff --git a/harper-core/default_config.json b/harper-core/default_config.jsonindex bea3879dc..dec114f06 100644--- a/harper-core/default_config.json+++ b/harper-core/default_config.json@@ -4438,6 +4438,13 @@"label": "Blanket Statement"}},+ {+ "Bool": {+ "name": "BoarderBorder",+ "state": true,+ "label": "Boarder Border"+ }+ },{"Bool": {"name": "Brutality",diff --git a/harper-core/src/linting/weir_rules/BoarderBorder.weir b/harper-core/src/linting/weir_rules/BoarderBorder.weirnew file mode 100644index 000000000..8ee536f67--- /dev/null+++ b/harper-core/src/linting/weir_rules/BoarderBorder.weir@@ -0,0 +1,72 @@+# "Boarder" (a person who rents a room) is an eggcorn for "border"+# (an edge, boundary, or dividing line). The words sound similar and+# "boarder" can superficially seem plausible, but in technical and everyday+# writing "border" is far more commonly the intended word.+#+# See: https://github.com/Automattic/harper/issues/3471+#+# Strategy: Flag "boarder" when followed by prepositions that indicate the+# spatial/boundary sense of "border" (of, between, around, with, on).+# Also flag "cross the boarder" (geographic border). We do NOT flag bare+# "the boarder" or "boarder to" because those are ambiguous with the+# lodger sense. Allow uses where "boarder" genuinely means a person who+# rents a room.++expr preps [of, between, around, with, on]++expr main [<(boarder @preps), boarder>, <(boarders @preps), boarders>, <(cross the boarder), boarder>, <(cross the boarders), boarders>]++let message "Did you mean `border`?"+let description "Flags the eggcorn `boarder` (a lodger) where `border` (an edge/boundary) is intended."+let kind "Eggcorn"+let becomes ["border", "borders"]+let strategy "MatchCase"++# --- TRUE POSITIVES: "boarder" should be "border" ---++# "boarder of" — the most common pattern+test "Draw the boarder of the container." "Draw the border of the container."+test "The boarder of the image is black." "The border of the image is black."+test "Change the boarder of the element." "Change the border of the element."++# "boarder between"+test "The boarder between the two countries is disputed." "The border between the two countries is disputed."+test "There is a thin boarder between the sections." "There is a thin border between the sections."++# "boarder around"+test "Add a boarder around the text." "Add a border around the text."+test "She drew a boarder around the page." "She drew a border around the page."++# "boarder with"+test "Set the boarder with CSS." "Set the border with CSS."+test "A boarder with a dashed style." "A border with a dashed style."++# "boarder on"+test "Put a boarder on the left side." "Put a border on the left side."++# "cross the boarder" — geographic border+test "They cross the boarder at night." "They cross the border at night."+test "Many people cross the boarder daily." "Many people cross the border daily."++# Plural "boarders"+test "The boarders of the table cells are visible." "The borders of the table cells are visible."+test "The boarders between states are marked." "The borders between states are marked."+test "Set the boarders with a uniform width." "Set the borders with a uniform width."+test "Refugees cross the boarders daily." "Refugees cross the borders daily."++# --- Case matching ---+test "Set the BOARDER of the div." "Set the BORDER of the div."+test "The Boarder of the image is black." "The Border of the image is black."++# --- FALSE POSITIVES: "boarder" is correct (lodger context) ---+# These should NOT be flagged because they lack the spatial preposition context+allows "The new boarder moved in yesterday."+allows "A boarder in the house heard the noise."+allows "She took in a boarder to help with rent."+allows "The boarder paid his rent on time."+allows "Abby is a pregnant woman with a curious new boarder in the apartment over her garage."++# --- Legitimate "border" usage should not be flagged ---+allows "Add a border around the div."+allows "The border between the countries is closed."+allows "She crossed the border at dawn."