Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat: backlash vs backslash (#4768)
Andrew Dunbarea52d6061290
diff --git a/harper-core/default_config.json b/harper-core/default_config.jsonindex 2354e6a4f..ba243c496 100644--- a/harper-core/default_config.json+++ b/harper-core/default_config.json@@ -4583,6 +4583,13 @@"label": "A Whole Other"}},+ {+ "Bool": {+ "name": "BacklashBackslash",+ "state": true,+ "label": "Backlash / Backslash"+ }+ },{"Bool": {"name": "BadRap",diff --git a/harper-core/src/linting/weir_rules/BacklashBackslash/ToBacklash.weir b/harper-core/src/linting/weir_rules/BacklashBackslash/ToBacklash.weirnew file mode 100644index 000000000..cf4361a10--- /dev/null+++ b/harper-core/src/linting/weir_rules/BacklashBackslash/ToBacklash.weir@@ -0,0 +1,14 @@+expr main <[([conservative, cultural, gear, political, public, violent] backslash), (backslash [adjustment, against, gear, gears])], backslash>++let message "Did you mean `backlash`?"+let description "Corrects `backslash` to `backlash` when it looks like a typo."+let kind "Typo"+let becomes "backlash"++test "Citizens' Assembly Sparks Art World Criticism and Conservative Backslash." "Citizens' Assembly Sparks Art World Criticism and Conservative Backlash."+test "adopt AI, despite inevitable public backslash" "adopt AI, despite inevitable public backlash"+test "The attacks triggered a violent backslash against the Muslim community" "The attacks triggered a violent backlash against the Muslim community"+test "calibration errors,gear backslash" "calibration errors,gear backlash"+test "Backslash adjustment in Takahashi mounts" "Backlash adjustment in Takahashi mounts"+test "Miniature zero-backslash gears and actuators for precision positioning applications." "Miniature zero-backlash gears and actuators for precision positioning applications."+test "Cultural Backslash: Trump, Brexit and the Rise of Authoritarian Populism" "Cultural Backlash: Trump, Brexit and the Rise of Authoritarian Populism"diff --git a/harper-core/src/linting/weir_rules/BacklashBackslash/ToBacklashes.weir b/harper-core/src/linting/weir_rules/BacklashBackslash/ToBacklashes.weirnew file mode 100644index 000000000..bed5c8598--- /dev/null+++ b/harper-core/src/linting/weir_rules/BacklashBackslash/ToBacklashes.weir@@ -0,0 +1,11 @@+expr main <[(backslashes against), ([conservative, political, public] backslashes)], backslashes>++let message "Did you mean `backlashes`?"+let description "Corrects `backslashes` to `backlashes` when it looks like a typo."+let kind "Typo"+let becomes "backlashes"++test "The recent backslashes against the numerisation project" "The recent backlashes against the numerisation project"+test "the easiest job you can do without receiving public backslashes is to market a generally loved 'item'" "the easiest job you can do without receiving public backlashes is to market a generally loved 'item'"+test "there were political backslashes, with energy cost a factor" "there were political backlashes, with energy cost a factor"+test "but faced various conservative backslashes in the form of right-wing national policies" "but faced various conservative backlashes in the form of right-wing national policies"diff --git a/harper-core/src/linting/weir_rules/BacklashBackslash/ToBackslash.weir b/harper-core/src/linting/weir_rules/BacklashBackslash/ToBackslash.weirnew file mode 100644index 000000000..04519760e--- /dev/null+++ b/harper-core/src/linting/weir_rules/BacklashBackslash/ToBackslash.weir@@ -0,0 +1,14 @@+expr main <[([single, double][-, ( )]backlash), (backlash [character, characters, key]), ([escaped, escaping] backlash)], backlash>++let message "Did you mean `backslash`?"+let description "Corrects `backlash` to `backslash` when it looks like a typo."+let kind "Typo"+let becomes "backslash"++test "Exporting adds backlash characters after each row" "Exporting adds backslash characters after each row"+test "Backlash character in the prompt needs to be escaped" "Backslash character in the prompt needs to be escaped"+test "It was written as a double backslash but it renders as a single backlash." "It was written as a double backslash but it renders as a single backslash."+test "string representation of a JSON with escaped backlash is incorrect" "string representation of a JSON with escaped backslash is incorrect"+test "which does not differentiate between the escaping backlash and the literal character" "which does not differentiate between the escaping backslash and the literal character"+test "Mapping the yen/backlash key didn't seem to work" "Mapping the yen/backslash key didn't seem to work"+test "note the double backlash only on the first backslash" "note the double backslash only on the first backslash"diff --git a/harper-core/src/linting/weir_rules/BacklashBackslash/ToBackslashes.weir b/harper-core/src/linting/weir_rules/BacklashBackslash/ToBackslashes.weirnew file mode 100644index 000000000..54850cc08--- /dev/null+++ b/harper-core/src/linting/weir_rules/BacklashBackslash/ToBackslashes.weir@@ -0,0 +1,16 @@+expr main <[([single, double][-, ( )]backlashes), (both backlashes), ([enter, entered, insert, inserted, type, typed] two backlashes), (backlashes [character, characters])], backlashes>++let message "Did you mean `backslashes`?"+let description "Corrects `backlashes` to `backslashes` when it looks like a typo."+let kind "Typo"+let becomes "backslashes"++test "Using r-strings is the correct solution if you want unescaped single backlashes" "Using r-strings is the correct solution if you want unescaped single backslashes"+test "As an aside, it looks like the Markdown extension only interprets double-backlashes as escapes." "As an aside, it looks like the Markdown extension only interprets double-backslashes as escapes."+test "To make a \“SLSH\” appear in the forum, type TWO backlashes" "To make a \“SLSH\” appear in the forum, type TWO backslashes"+test "To use a backslash in such shell string, enter two backlashes" "To use a backslash in such shell string, enter two backslashes"+test "A parameter designator consists of a backlashes character, followed by a digit (0 - 9)" "A parameter designator consists of a backslashes character, followed by a digit (0 - 9)"++# test "Replacing backslash with two backlashes in ansible" "Replacing backslash with two backslashes in ansible"++allows "The two backlashes against globalisation."