Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(core): create a good number of new Weir rules (#2506)
Elijah Potter1f02bfcf47b4
diff --git a/harper-core/src/linting/weir_rules/AOkHyphen.weir b/harper-core/src/linting/weir_rules/AOkHyphen.weirnew file mode 100644index 000000000..62ea64960--- /dev/null+++ b/harper-core/src/linting/weir_rules/AOkHyphen.weir@@ -0,0 +1,29 @@+expr main a [ok, okay]++let message "Use `A-OK` when stating that something is acceptable or ready."+let description "Replaces the loose article-plus-abbreviation pairing with the standard hyphenated form whenever a linking verb describes readiness or approval."+let kind "Style"+let becomes "A-OK"++test "I am a ok with the plan." "I am a-ok with the plan."+test "We are totally a ok team before the launch." "We are totally a-ok team before the launch."+test "The crew was pretty a okay about the repairs." "The crew was pretty a-ok about the repairs."+test "It will be a ok once the update reaches the fleet." "It will be a-ok once the update reaches the fleet."+test "You are very a ok partner for the call." "You are very a-ok partner for the call."+test "This is almost a ok outcome for the holiday." "This is almost a-ok outcome for the holiday."+test "I am just a okay voice on the call." "I am just a-ok voice on the call."+test "We were really a ok group at the summit." "We were really a-ok group at the summit."+test "It is a ok moment to decide." "It is a-ok moment to decide."+test "The product is pretty a ok example of resilience." "The product is pretty a-ok example of resilience."+test "The service was totally a okay signal." "The service was totally a-ok signal."+test "Are you a ok with this change?" "Are you a-ok with this change?"+test "It is A OK to proceed." "It is A-OK to proceed."+test "I was a ok support while the team was busy." "I was a-ok support while the team was busy."+test "You were totally a ok host." "You were totally a-ok host."+test "Being a ok line of communication matters." "Being a-ok line of communication matters."+test "It has been a ok solution in the past." "It has been a-ok solution in the past."++test "The dashboard shows A-OK feedback." "The dashboard shows A-OK feedback."+test "Our status is OK." "Our status is OK."+test "This is a good plan." "This is a good plan."+test "AOK signals readiness." "AOK signals readiness."diff --git a/harper-core/src/linting/weir_rules/AsFollows.weir b/harper-core/src/linting/weir_rules/AsFollows.weirnew file mode 100644index 000000000..3d5bb7c22--- /dev/null+++ b/harper-core/src/linting/weir_rules/AsFollows.weir@@ -0,0 +1,25 @@+expr main (as follow)++let message "Use `as follows`."+let description "Corrects the phrase `as follow`, which is sometimes produced by overcorrection. While it appeared briefly in 19th-century English, it is now considered archaic; modern standard usage requires `as follows` regardless of number."+let kind "Grammar"+let becomes "as follows"++test "The main points are as follow:" "The main points are as follows:"+test "Please read the steps as follow before you begin." "Please read the steps as follows before you begin."+test "As follow you requested, I have compiled the list." "As follows you requested, I have compiled the list."+test "I write this as follow for future reference." "I write this as follows for future reference."+test "as follow" "as follows"+test "AS FOLLOW" "AS FOLLOWS"+test "The instructions are listed as follow in the appendix." "The instructions are listed as follows in the appendix."+test "We were told as follow the timeline would slip." "We were told as follows the timeline would slip."+test "Is this description as follow the sample?" "Is this description as follows the sample?"+test "You can verify as follow once the build completes." "You can verify as follows once the build completes."++# Ensure unrelated uses of "follow" are not affected+test "Follow the instructions as written." "Follow the instructions as written."+test "We follow-up on these requests weekly." "We follow-up on these requests weekly."+test "This is the way to follow as best you can." "This is the way to follow as best you can."+test "As follows the plan will unfold." "As follows the plan will unfold."+test "I will follow your lead." "I will follow your lead."+test "The as follows section is helpful." "The as follows section is helpful."diff --git a/harper-core/src/linting/weir_rules/BewareOf.weir b/harper-core/src/linting/weir_rules/BewareOf.weirnew file mode 100644index 000000000..1e1b9b9e9--- /dev/null+++ b/harper-core/src/linting/weir_rules/BewareOf.weir@@ -0,0 +1,27 @@+expr main [(beware with regard to), (beware about), (beware with), (beware regarding), (beware concerning), (beware against), (beware for), (beware in), (beware on), (beware at), (beware among), (beware between)]++let message "Use `beware of` when naming the object you want readers to avoid."+let description "The verb `beware` naturally pairs with `of` before the noun being warned about, so swap other prepositions for clarity."+let kind "Usage"+let becomes "beware of"+let strategy "MatchCase"++test "Beware about scams that arrive by email." "Beware of scams that arrive by email."+test "beware with the loose wires behind the TV." "beware of the loose wires behind the TV."+test "Beware with regard to the rusted railing." "Beware of the rusted railing."+test "Beware regarding the crumbling guardrail." "Beware of the crumbling guardrail."+test "Beware concerning the expired coupon." "Beware of the expired coupon."+test "Beware against mixing cleaning chemicals." "Beware of mixing cleaning chemicals."+test "Beware for the slippery tile near the pool." "Beware of the slippery tile near the pool."+test "Beware in the area where the fog hides the cliffs." "Beware of the area where the fog hides the cliffs."+test "Beware on the step that squeaks." "Beware of the step that squeaks."+test "Beware at that crossing when traffic is heavy." "Beware of that crossing when traffic is heavy."+test "Beware among the wild animals outside the park." "Beware of the wild animals outside the park."+test "Beware between the gaps in the scaffolding." "Beware of the gaps in the scaffolding."+test "BEWARE WITH THE LOUD CRASHING." "BEWARE OF THE LOUD CRASHING."++test "Beware of the dog that guards the porch." "Beware of the dog that guards the porch."+test "Beware the gap between the platforms." "Beware the gap between the platforms."+test "Beware every time you go near the cliff." "Beware every time you go near the cliff."+test "Some people say beware: the path narrows." "Some people say beware: the path narrows."+test "Beware of tall waves on this beach." "Beware of tall waves on this beach."diff --git a/harper-core/src/linting/weir_rules/DoIAdjective.weir b/harper-core/src/linting/weir_rules/DoIAdjective.weirnew file mode 100644index 000000000..55a0917e0--- /dev/null+++ b/harper-core/src/linting/weir_rules/DoIAdjective.weir@@ -0,0 +1,25 @@+expr main <([(Do I [interested, excited, tired, ready, curious, comfortable, prepared, overwhelmed, confident, available, worried, annoyed, relieved, frustrated, surprised, anxious, calm, satisfied, concerned]), (Do I not [interested, excited, tired, ready, curious, comfortable, prepared, overwhelmed, confident, available, worried, annoyed, relieved, frustrated, surprised, anxious, calm, satisfied, concerned])]), Do>++let message "When describing how you feel, `I` pairs with `am`, not `do`."+let description "Swaps the helping verb `do` for `am` in `Do I <adjective>` questions so they use the correct linking verb."+let kind "Grammar"+let becomes "am"++test "Do I interested in music?" "Am I interested in music?"+test "Do I excited about the launch?" "Am I excited about the launch?"+test "Do I tired after the hike?" "Am I tired after the hike?"+test "Do I ready for the interview?" "Am I ready for the interview?"+test "Do I curious what they decide?" "Am I curious what they decide?"+test "Do I comfortable sharing that detail?" "Am I comfortable sharing that detail?"+test "Do I prepared to join the call?" "Am I prepared to join the call?"+test "Do I overwhelmed by the inbox?" "Am I overwhelmed by the inbox?"+test "Do I confident in that plan?" "Am I confident in that plan?"+test "Do I not interested in attending?" "Am I not interested in attending?"+test "Do I not ready yet?" "Am I not ready yet?"+test "do I concerned about the changes?" "am I concerned about the changes?"++test "Do I want to help you?" "Do I want to help you?"+test "Do I need to finish this tonight?" "Do I need to finish this tonight?"+test "Do I have to explain everything?" "Do I have to explain everything?"+test "Do I run the tests again?" "Do I run the tests again?"+test "Do I look like I'm not listening?" "Do I look like I'm not listening?"diff --git a/harper-core/src/linting/weir_rules/DoToDueTo.weir b/harper-core/src/linting/weir_rules/DoToDueTo.weirnew file mode 100644index 000000000..74dec3a29--- /dev/null+++ b/harper-core/src/linting/weir_rules/DoToDueTo.weir@@ -0,0 +1,24 @@+expr main <([(![PRON, INTJ, PART, ADV, CCONJ, SCONJ, ADP, DET] do to [ADJ, NOUN, VERB, PROPN] NOUN), (![PRON, INTJ, PART, ADV, CCONJ, SCONJ, ADP, DET] do to DET * NOUN), (![PRON, INTJ, PART, ADV, CCONJ, SCONJ, ADP, DET] ADV do to [ADJ, NOUN, VERB, PROPN] NOUN), (![PRON, INTJ, PART, ADV, CCONJ, SCONJ, ADP, DET] ADV do to DET * NOUN)]), (do to)>++let message "Did you mean `due to`?"+let description "Corrects the typo `do to` when it is intended to mean `due to` in causal phrases."+let kind "Usage"+let becomes "due to"++test "Many restaurants will close do to the corona restrictions." "Many restaurants will close due to the corona restrictions."+test "The event was canceled do to bad weather." "The event was canceled due to bad weather."+test "Production stopped do to a supply shortage." "Production stopped due to a supply shortage."+test "Flights were delayed do to heavy fog." "Flights were delayed due to heavy fog."+test "The server rebooted do to power issues." "The server rebooted due to power issues."+test "They left early do to a family emergency." "They left early due to a family emergency."+test "The cancelation happened do to unexpected maintenance." "The cancelation happened due to unexpected maintenance."+test "Our plan changed do to the new policy." "Our plan changed due to the new policy."+test "The app crashed do to memory leaks." "The app crashed due to memory leaks."+test "Tickets sold quickly do to a viral post." "Tickets sold quickly due to a viral post."+test "It failed do to data loss." "It failed due to data loss."++test "What did you do to the file?" "What did you do to the file?"+test "Please do to the file what you did to the other one." "Please do to the file what you did to the other one."+test "Don't do to others what you wouldn't want done to you." "Don't do to others what you wouldn't want done to you."+test "We need to do to this spreadsheet what we did last week." "We need to do to this spreadsheet what we did last week."+test "She asked what the update would do to her settings." "She asked what the update would do to her settings."diff --git a/harper-core/src/linting/weir_rules/DoubleNegative.weir b/harper-core/src/linting/weir_rules/DoubleNegative.weirnew file mode 100644index 000000000..e05bb4086--- /dev/null+++ b/harper-core/src/linting/weir_rules/DoubleNegative.weir@@ -0,0 +1,26 @@+expr main <([(didn't), (did not), (did n't)] [need, have, want, make, take, get] no), no>++let message "With `didn't/did not`, using `no` creates a double negative; replace `no` with `any` to keep a single negation."+let description "Replaces the determiner `no` with `any` when it follows the auxiliary `didn't/did not` plus a main verb (e.g., have, need, want, make, take, get) so the clause contains only one negation."+let kind "Grammar"+let becomes "any"++test "I didn't have no idea what to say." "I didn't have any idea what to say."+test "She didn't want no trouble last night." "She didn't want any trouble last night."+test "He did not make no progress this week." "He did not make any progress this week."+test "We didn't take no for an answer." "We didn't take any for an answer."+test "They didn't get no signal from the device." "They didn't get any signal from the device."+test "You didn't need no permission to do that." "You didn't need any permission to do that."+test "I didn't have no choice after the meeting." "I didn't have any choice after the meeting."+test "I didn't want no part of it." "I didn't want any part of it."+test "The driver didn't take no excuses." "The driver didn't take any excuses."+test "I didn't have no time for that." "I didn't have any time for that."+test "I DIDN'T HAVE NO IDEA WHEN THIS WOULD END." "I DIDN'T HAVE ANY IDEA WHEN THIS WOULD END."+test "She did not make no progress yet." "She did not make any progress yet."++# Should not change when there's no double negative `no`+test "I didn't have any idea what to do." "I didn't have any idea what to do."+test "I didn't say no to the invitation." "I didn't say no to the invitation."+test "She doesn't have any idea why the alarm rang." "She doesn't have any idea why the alarm rang."+test "I did not see any sign of trouble." "I did not see any sign of trouble."+test "No friends came over." "No friends came over."diff --git a/harper-core/src/linting/weir_rules/HeDos.weir b/harper-core/src/linting/weir_rules/HeDos.weirnew file mode 100644index 000000000..d66dd1678--- /dev/null+++ b/harper-core/src/linting/weir_rules/HeDos.weir@@ -0,0 +1,22 @@+expr main <([(he dos), (he ADV dos), (she dos), (she ADV dos), (it dos), (it ADV dos)]), dos>++let message "Did you mean `does`?"+let description "Corrects the misspelling `dos` after `he`, `she`, or `it`."+let kind "Typo"+let becomes "does"++test "He dos not want to go." "He does not want to go."+test "She dos it." "She does it."+test "It dos work." "It does work."+test "he dos not like it." "he does not like it."+test "HE DOS IT." "HE DOES IT."+test "He just dos it." "He just does it."+test "She never dos that." "She never does that."+test "It really dos." "It really does."+test "He dos." "He does."+test "She dos, then she stops." "She does, then she stops."+test "I dos it." "I dos it."+test "They dos it." "They dos it."+test "Dos is Spanish for two." "Dos is Spanish for two."+test "He does it." "He does it."+test "He doso it." "He doso it."diff --git a/harper-core/src/linting/weir_rules/HeartToHeard.weir b/harper-core/src/linting/weir_rules/HeartToHeard.weirnew file mode 100644index 000000000..8e71fcfc4--- /dev/null+++ b/harper-core/src/linting/weir_rules/HeartToHeard.weir@@ -0,0 +1,23 @@+expr main <([([have, has, had] [I, you, he, she, it, we, they] [heart, herd] [of, about, from, in, on, for, to, with]), ([have, has, had] [I, you, he, she, it, we, they] ADV [heart, herd] [of, about, from, in, on, for, to, with]), ([have, has, had] n't [I, you, he, she, it, we, they] [heart, herd] [of, about, from, in, on, for, to, with]), ([have, has, had] n't [I, you, he, she, it, we, they] ADV [heart, herd] [of, about, from, in, on, for, to, with]), ([have, has, had] DET NOUN ADV [heart, herd] [of, about, from, in, on, for, to, with]), ([have, has, had] n't DET NOUN ADV [heart, herd] [of, about, from, in, on, for, to, with]), ([haven't, hasn't, hadn't] [I, you, he, she, it, we, they] [heart, herd] [of, about, from, in, on, for, to, with]), ([haven't, hasn't, hadn't] [I, you, he, she, it, we, they] ADV [heart, herd] [of, about, from, in, on, for, to, with]), ([haven't, hasn't, hadn't] DET NOUN ADV [heart, herd] [of, about, from, in, on, for, to, with])]), [heart, herd]>++let message "Did you mean the verb `heard` (= past tense of `hear`)?"+let description "Corrects `heart` or `herd` to `heard` in common `have ... heard of/about` questions."+let kind "Usage"+let becomes "heard"++test "Have you heart of this band?" "Have you heard of this band?"+test "Have you herd of this band?" "Have you heard of this band?"+test "Have you ever heart of this band?" "Have you ever heard of this band?"+test "Have you ever herd of this band?" "Have you ever heard of this band?"+test "Has she heart of the update?" "Has she heard of the update?"+test "Has she ever heart of the update?" "Has she ever heard of the update?"+test "Had they heart of the plan?" "Had they heard of the plan?"+test "Have the police ever heart of this?" "Have the police ever heard of this?"+test "Have the staff ever herd of the policy?" "Have the staff ever heard of the policy?"+test "Haven't you heart of that movie?" "Haven't you heard of that movie?"+test "Haven't you ever herd of that movie?" "Haven't you ever heard of that movie?"+test "Have you heard of this band?" "Have you heard of this band?"+test "Have the police heard of this?" "Have the police heard of this?"+test "Have the heart of this story been told?" "Have the heart of this story been told?"+test "I have a herd of cattle." "I have a herd of cattle."+test "I have heart of the matter already." "I have heart of the matter already."diff --git a/harper-core/src/linting/weir_rules/HowMach.weir b/harper-core/src/linting/weir_rules/HowMach.weirnew file mode 100644index 000000000..567ec7741--- /dev/null+++ b/harper-core/src/linting/weir_rules/HowMach.weir@@ -0,0 +1,22 @@+expr main <(how [mach, match] !PUNCT), [mach, match]>++let message "Use `how much` when you're asking about quantity, not the brand name or verb."+let description "Swaps `how mach` or `how match` with the correct quantifier `how much`."+let kind "Typo"+let becomes "much"++test "Do you know how mach it weighs?" "Do you know how much it weighs?"+test "Tell me how match sugar you want." "Tell me how much sugar you want."+test "How mach are we supposed to study?" "How much are we supposed to study?"+test "How match time have we spent already?" "How much time have we spent already?"+test "He wondered how mach courage it takes." "He wondered how much courage it takes."+test "She asked how match water to add." "She asked how much water to add."+test "Ask how mach light you need." "Ask how much light you need."+test "How mach did you train for this race?" "How much did you train for this race?"+test "How match of those settings are legal?" "How much of those settings are legal?"+test "HOW MACH DO YOU WANT IT?" "HOW MUCH DO YOU WANT IT?"+test "Now that we know how match() works, let's refactor." "Now that we know how match() works, let's refactor."+test "How Match.com Got Women to Sign Up for Online Dating." "How Match.com Got Women to Sign Up for Online Dating."+test "The engine develops 131.7kN and the speed of the aircraft is Mach 2." "The engine develops 131.7kN and the speed of the aircraft is Mach 2."+test "Tell me how much time you need." "Tell me how much time you need."+test "I can't decide how much of this to keep." "I can't decide how much of this to keep."diff --git a/harper-core/src/linting/weir_rules/LaughOfAt.weir b/harper-core/src/linting/weir_rules/LaughOfAt.weirnew file mode 100644index 000000000..b3ccc43e9--- /dev/null+++ b/harper-core/src/linting/weir_rules/LaughOfAt.weir@@ -0,0 +1,25 @@+expr main <([laugh, laughs, laughed, laughing] of [PRON, PROPN]), of>++let message "Use `laugh at ...` instead of `laugh of ...` when pointing at someone."+let description "Warns when `laugh` takes `of` before a person or pronoun and nudges writers toward the conventional `at`."+let kind "Usage"+let becomes "at"++test "I laugh of him." "I laugh at him."+test "She laughs of her teacher." "She laughs at her teacher."+test "They laughed of us in the hallway." "They laughed at us in the hallway."+test "He's laughing of them already." "He's laughing at them already."+test "We laugh of you whenever you wear that hat." "We laugh at you whenever you wear that hat."+test "Laugh of John while he waits." "Laugh at John while he waits."+test "Don't laugh of your teammate again." "Don't laugh at your teammate again."+test "The crowd laughs of Mary when she trips." "The crowd laughs at Mary when she trips."+test "I was laughing of Alex when the joke landed." "I was laughing at Alex when the joke landed."+test "They laugh of me even when I'm serious." "They laugh at me even when I'm serious."+test "The laugh of the audience shook the rafters." "The laugh of the audience shook the rafters."+test "That's the laugh of the most relentless critic." "That's the laugh of the most relentless critic."+test "The laugh of the baby warmed everyone." "The laugh of the baby warmed everyone."+test "We had a laugh of relief when it ended." "We had a laugh of relief when it ended."+test "A laugh of astonishment escaped him." "A laugh of astonishment escaped him."+test "Her laugh of disbelief made us pause." "Her laugh of disbelief made us pause."+test "The laugh of a friend sounded distant." "The laugh of a friend sounded distant."+test "I savor the laugh of children playing outside." "I savor the laugh of children playing outside."diff --git a/harper-core/src/linting/weir_rules/LeaveToFor.weir b/harper-core/src/linting/weir_rules/LeaveToFor.weirnew file mode 100644index 000000000..e6a49d00f--- /dev/null+++ b/harper-core/src/linting/weir_rules/LeaveToFor.weir@@ -0,0 +1,23 @@+expr main <([leave, leaves, left, leaving] to [PROPN] [next, tomorrow, soon]), to>++let message "Use `for` when pointing a departure toward a place."+let description "When describing travel plans that include a destination and a time frame, prefer `leave for a destination` instead of `leave to a destination`."+let kind "Usage"+let becomes "for"+let strategy "MatchCase"++test "They are leaving to England soon." "They are leaving for England soon."+test "We leave to Japan tomorrow morning." "We leave for Japan tomorrow morning."+test "He leaves to Canada next week." "He leaves for Canada next week."+test "We're leaving to Morocco next fall." "We're leaving for Morocco next fall."+test "They're leaving to France tomorrow." "They're leaving for France tomorrow."+test "My team leaves to London soon for the conference." "My team leaves for London soon for the conference."+test "We are leaving to Brazil soon." "We are leaving for Brazil soon."+test "I leave to Spain next Monday." "I leave for Spain next Monday."+test "He left to Italy soon after the ceremony." "He left for Italy soon after the ceremony."+test "The crew is leaving to Paris soon." "The crew is leaving for Paris soon."+test "I leave it to you." "I leave it to you."+test "Leave it to me, and I'll handle it." "Leave it to me, and I'll handle it."+test "We are leaving to the west soon." "We are leaving to the west soon."+test "We left to surprise them." "We left to surprise them."+test "They leave to inform the board tomorrow." "They leave to inform the board tomorrow."diff --git a/harper-core/src/linting/weir_rules/LooksLikes.weir b/harper-core/src/linting/weir_rules/LooksLikes.weirnew file mode 100644index 000000000..b34879d89--- /dev/null+++ b/harper-core/src/linting/weir_rules/LooksLikes.weir@@ -0,0 +1,25 @@+expr main <([looks, looked, looking] likes), likes>++let message "Drop the extra `s` in `likes` when it immediately follows a form of `look`."+let description "This rule turns `looks likes`, `looked likes`, and `looking likes` into the idiomatic `look ... like`."+let kind "Typo"+let becomes "like"++test "It looks likes the same story." "It looks like the same story."+test "The memoir looked likes a diary." "The memoir looked like a diary."+test "The detective is looking likes the culprit." "The detective is looking like the culprit."+test "She looks likes, honestly, a champion." "She looks like, honestly, a champion."+test "LOOKS LIKES a bad omen." "LOOKS LIKE a bad omen."+test "It looked LIKES a mirage." "It looked LIKE a mirage."+test "He is looking LIKES his brother." "He is looking LIKE his brother."+test "Looks likes both people are arriving." "Looks like both people are arriving."+test "She looked likes, well there it is." "She looked like, well there it is."+test "Those who are looking likes a miracle never arrive." "Those who are looking like a miracle never arrive."+test "Looks likes the worst scenario." "Looks like the worst scenario."++test "Looks like the winner." "Looks like the winner."+test "He likes to code every day." "He likes to code every day."+test "She looked like a star." "She looked like a star."+test "I was looking carefully." "I was looking carefully."+test "I like how it looks." "I like how it looks."+test "Like how he likes the team." "Like how he likes the team."diff --git a/harper-core/src/linting/weir_rules/PasswordProtectedHyphen.weir b/harper-core/src/linting/weir_rules/PasswordProtectedHyphen.weirnew file mode 100644index 000000000..1b4198db6--- /dev/null+++ b/harper-core/src/linting/weir_rules/PasswordProtectedHyphen.weir@@ -0,0 +1,27 @@+expr main <(password protected [(area), (areas), (document), (documents), (doc), (docs), (spreadsheet), (spreadsheets), (archive), (archives), (zip), (zips), (pdf), (pdfs), (folder), (folders), (system), (systems), (page), (pages), (website), (websites), (site), (sites), (file), (files), (account), (accounts), (drive), (drives), (stick), (sticks), (usb), (usbs), (excel), (apps), (app), (cd), (cds), (dropbox), (dropboxes), (email), (emails), (gallery), (galleries), (iphone), (iphones)]), (password protected)>++let message "Hyphenate `password-protected` when the phrase modifies a following resource."+let description "Keeps the compound adjective together before nouns like folders, files, or web pages so the dependency between them is clear."+let kind "Style"+let becomes "password-protected"++test "A password protected area restricts access." "A password-protected area restricts access."+test "We store logs in a password protected folder." "We store logs in a password-protected folder."+test "Please send the password protected document tomorrow." "Please send the password-protected document tomorrow."+test "The password protected spreadsheet contains numbers." "The password-protected spreadsheet contains numbers."+test "They locked the password protected archive." "They locked the password-protected archive."+test "Bring the password protected pdf to the meeting." "Bring the password-protected pdf to the meeting."+test "That password protected page requires a login." "That password-protected page requires a login."+test "This password protected website is for beta users." "This password-protected website is for beta users."+test "Our password protected file sits on the drive." "Our password-protected file sits on the drive."+test "The password protected account holds secrets." "The password-protected account holds secrets."+test "Their password protected app went live." "Their password-protected app went live."+test "We updated the password protected system this morning." "We updated the password-protected system this morning."+test "These password protected folders double as backups." "These password-protected folders double as backups."+test "Password protected emails pile up." "Password-protected emails pile up."+test "The password protected gallery remains hidden." "The password-protected gallery remains hidden."+test "A password protected iphone case is ready." "A password-protected iphone case is ready."+test "A password protected drive keeps everything safe." "A password-protected drive keeps everything safe."+test "The area is password protected." "The area is password protected."+test "She mentioned password protected with no follow-up." "She mentioned password protected with no follow-up."+test "The password protected from clause does not match." "The password protected from clause does not match."diff --git a/harper-core/src/linting/weir_rules/PedalToTheMetal.weir b/harper-core/src/linting/weir_rules/PedalToTheMetal.weirnew file mode 100644index 000000000..f1ce4bd5d--- /dev/null+++ b/harper-core/src/linting/weir_rules/PedalToTheMetal.weir@@ -0,0 +1,24 @@+expr main pedal to the medal++let message "Use the idiom `pedal to the metal`."+let description "Corrects the eggcorn `pedal to the medal` to the standard idiom `pedal to the metal`, meaning to accelerate at full speed."+let kind "Typo"+let becomes "pedal to the metal"++test "pedal to the medal" "pedal to the metal"+test "Pedal to the medal when you see the green flag." "Pedal to the metal when you see the green flag."+test "The coach shouted pedal to the medal before the jump." "The coach shouted pedal to the metal before the jump."+test "We pedal to the medal whenever the lights go yellow." "We pedal to the metal whenever the lights go yellow."+test "Pedal to the medal is how you fly out of the gate." "Pedal to the metal is how you fly out of the gate."+test "He loves to say pedal to the medal while revving engines." "He loves to say pedal to the metal while revving engines."+test "Pedal to the medal in these conditions and the tyres scream." "Pedal to the metal in these conditions and the tyres scream."+test "Pedal to the medal, please, once we cross the start line." "Pedal to the metal, please, once we cross the start line."+test "Keep saying pedal to the medal until the rival hears it." "Keep saying pedal to the metal until the rival hears it."+test "PEDAL TO THE MEDAL seems to be the rally cry." "PEDAL TO THE METAL seems to be the rally cry."++test "Pedal to the metal is the correct idiom." "Pedal to the metal is the correct idiom."+test "She earned a medal for her performance." "She earned a medal for her performance."+test "The medal ceremony happened before the race." "The medal ceremony happened before the race."+test "Pedal to the mettle, not the medal, outlines courage." "Pedal to the mettle, not the medal, outlines courage."+test "The medal in our archive dates to 1895." "The medal in our archive dates to 1895."+test "They pedaled to the medal." "They pedaled to the medal."diff --git a/harper-core/src/linting/weir_rules/RainbowColoredHyphen.weir b/harper-core/src/linting/weir_rules/RainbowColoredHyphen.weirnew file mode 100644index 000000000..fc16484dc--- /dev/null+++ b/harper-core/src/linting/weir_rules/RainbowColoredHyphen.weir@@ -0,0 +1,23 @@+expr main <(([rainbow, cream] [colored, coloured]) NOUN), ( )>++let message "Keep these compound color modifiers hyphenated before their nouns."+let description "When rainbow-colored or cream-colored describe a noun, replace the space between the color words with a hyphen to keep the modifier cohesive."+let kind "Style"+let becomes "-"++test "The rainbow colored leaves shimmered in the morning light." "The rainbow-colored leaves shimmered in the morning light."+test "A cream colored sofa anchored the living room." "A cream-colored sofa anchored the living room."+test "Bright rainbow colored banners lined the promenade." "Bright rainbow-colored banners lined the promenade."+test "Bring the cream colored napkins to the table." "Bring the cream-colored napkins to the table."+test "RAINBOW COLORED FLAGS fluttered over the pier." "RAINBOW-COLORED FLAGS fluttered over the pier."+test "Our designer introduced cream coloured sneakers for fall." "Our designer introduced cream-coloured sneakers for fall."+test "These rainbow colored posters mark the festival days." "These rainbow-colored posters mark the festival days."+test "Cream coloured curtains softened the gallery lights." "Cream-coloured curtains softened the gallery lights."+test "The designer chose rainbow colored tiles for the backsplash." "The designer chose rainbow-colored tiles for the backsplash."+test "Our lineup now shows cream colored lipsticks and rainbow colored gloss." "Our lineup now shows cream-colored lipsticks and rainbow-colored gloss."++test "The rainbow colored the sky with a soft gradient." "The rainbow colored the sky with a soft gradient."+test "She rainbow colored every triangle on the quilt." "She rainbow colored every triangle on the quilt."+test "The artist cream colored the mural in minutes." "The artist cream colored the mural in minutes."+test "The leaves were rainbow colored after the festival lights." "The leaves were rainbow colored after the festival lights."+test "Cream colored the vase intentionally for the commission." "Cream colored the vase intentionally for the commission."diff --git a/harper-core/src/linting/weir_rules/RallyToReally.weir b/harper-core/src/linting/weir_rules/RallyToReally.weirnew file mode 100644index 000000000..6a5dfb7ef--- /dev/null+++ b/harper-core/src/linting/weir_rules/RallyToReally.weir@@ -0,0 +1,27 @@+expr main <([(am rally PROG), (am not rally PROG), (am PRON rally PROG), (am PRON not rally PROG), (is rally PROG), (is not rally PROG), (is PRON rally PROG), (is PRON not rally PROG), (isn't rally PROG), (isn't PRON rally PROG), (are rally PROG), (are not rally PROG), (are PRON rally PROG), (are PRON not rally PROG), (aren't rally PROG), (aren't PRON rally PROG), (was rally PROG), (was not rally PROG), (was PRON rally PROG), (was PRON not rally PROG), (wasn't rally PROG), (wasn't PRON rally PROG), (were rally PROG), (were not rally PROG), (were PRON rally PROG), (were PRON not rally PROG), (weren't rally PROG), (weren't PRON rally PROG), (be rally PROG), (be not rally PROG), (be PRON rally PROG), (be PRON not rally PROG), (being rally PROG), (being not rally PROG), (been rally PROG), (been not rally PROG), (ain't rally PROG), (ain't PRON rally PROG)]), (rally)>++let message "Replace `rally` with `really` whenever a form of `be` introduces a progressive verb."+let description "Catches the typo where `rally` sneaks into `be + ...ing` constructions, including common contractions."+let kind "Typo"+let becomes "really"+let strategy "MatchCase"++test "It is rally going to happen." "It is really going to happen."+test "We are rally getting closer to shipping." "We are really getting closer to shipping."+test "I am rally trying to finish this before midnight." "I am really trying to finish this before midnight."+test "She is not rally learning the concept." "She is not really learning the concept."+test "It isn't rally raining anymore." "It isn't really raining anymore."+test "They were rally practicing their lines." "They were really practicing their lines."+test "It was not rally raining on our drive." "It was not really raining on our drive."+test "He had been rally preparing to leave." "He had been really preparing to leave."+test "Ain't rally happening yet?" "Ain't really happening yet?"+test "Weren't we rally celebrating that plan?" "Weren't we really celebrating that plan?"+test "Be rally precise when you describe the steps." "Be rally precise when you describe the steps."+test "He was RALLY going to go all night." "He was REALLY going to go all night."++test "The rally celebrating our victory lasted forever." "The rally celebrating our victory lasted forever."+test "I really appreciate your effort." "I really appreciate your effort."+test "Rally fans gathered outside the stadium." "Rally fans gathered outside the stadium."+test "We had a rally before the game." "We had a rally before the game."+test "The news rallied the team but left them motivated." "The news rallied the team but left them motivated."+test "We were ready to rally around the idea." "We were ready to rally around the idea."diff --git a/harper-core/src/linting/weir_rules/TrueToWord.weir b/harper-core/src/linting/weir_rules/TrueToWord.weirnew file mode 100644index 000000000..db7a5bf0d--- /dev/null+++ b/harper-core/src/linting/weir_rules/TrueToWord.weir@@ -0,0 +1,26 @@+expr main <(true to [my, your, his, her, its, our, their, one's] words), words>++let message "Replace the plural `words` with the idiomatic singular form when someone stays true to a promise."+let description "Normalizes phrasing around `true to <possessive>` so it follows the conventional `true to one's word`."+let kind "Style"+let becomes "word"++test "She was true to her words." "She was true to her word."+test "He stays TRUE to his words daily." "He stays TRUE to his word daily."+test "We're true to our words even when it's hard." "We're true to our word even when it's hard."+test "You're true to your words, no matter what." "You're true to your word, no matter what."+test "I try to be true to my words." "I try to be true to my word."+test "They remain true to their words after the announcement." "They remain true to their word after the announcement."+test "True to one's words, the promise held." "True to one's word, the promise held."+test "True to its words, the contract stands." "True to its word, the contract stands."+test "He has been true to her words through thick and thin." "He has been true to her word through thick and thin."+test "They were true to THEIR words, so the customers celebrated." "They were true to THEIR word, so the customers celebrated."+test "One stays true to one's words while keeping a diary." "One stays true to one's word while keeping a diary."+test "I'm true to my words." "I'm true to my word."+test "True to your words, you resumed the pledge." "True to your word, you resumed the pledge."++test "She was true to her word." "She was true to her word."+test "They were true to the words they heard in class." "They were true to the words they heard in class."+test "Being true to your word is the goal." "Being true to your word is the goal."+test "The article praised her true words." "The article praised her true words."+test "Our team is true to the word we said earlier." "Our team is true to the word we said earlier."diff --git a/harper-core/src/linting/weir_rules/WithoutOut.weir b/harper-core/src/linting/weir_rules/WithoutOut.weirnew file mode 100644index 000000000..078b98b90--- /dev/null+++ b/harper-core/src/linting/weir_rules/WithoutOut.weir@@ -0,0 +1,23 @@+expr main without out++let message "Drop the duplicated `out` when it follows `without`."+let description "When writers accidentally type `without out`, Harper can collapse the two words back into the single preposition."+let kind "Typo"+let becomes "without"+let strategy "MatchCase"++test "Without out a doubt, the team delivered." "Without a doubt, the team delivered."+test "She ran without out hesitation this morning." "She ran without hesitation this morning."+test "Without out fail, the backup completed." "Without fail, the backup completed."+test "We proceed without out complaint from clients." "We proceed without complaint from clients."+test "Without out this addition, the plan collapses." "Without this addition, the plan collapses."+test "Without out any warning, the lights went out." "Without any warning, the lights went out."+test "Without OUT, the process would stop." "Without, the process would stop."+test "WITHOUT OUT luck, the players backed down." "WITHOUT luck, the players backed down."+test "without out all hope, we succeeded." "without all hope, we succeeded."+test "Last week we moved without out delay." "Last week we moved without delay."+test "Without outstanding debts we can pivot." "Without outstanding debts we can pivot."+test "There is a without output fallback." "There is a without output fallback."+test "The absence of outbuildings was puzzling." "The absence of outbuildings was puzzling."+test "Without doubt, the plan succeeded." "Without doubt, the plan succeeded."+test "Mind the output to ensure correctness." "Mind the output to ensure correctness."diff --git a/harper-core/src/weir/parsing/stmt.rs b/harper-core/src/weir/parsing/stmt.rsindex 1bf161c99..f35845bbe 100644--- a/harper-core/src/weir/parsing/stmt.rs+++ b/harper-core/src/weir/parsing/stmt.rs@@ -61,7 +61,7 @@ fn parse_stmt(tokens: &[Token], source: &[char]) -> Result<FoundNode<Option<AstS.span().unwrap().get_content_string(source);- Ok(FoundNode::new(Some(AstStmtNode::Comment(comment)), end + 2))+ Ok(FoundNode::new(Some(AstStmtNode::Comment(comment)), end + 1))}TokenKind::Word(_) => {let word_literal = key_token.span.get_content(source);@@ -364,6 +364,36 @@ mod tests {);}+ #[test]+ fn parses_comment_in_middle() {+ let ast = parse_str(+ "let test \"to be this\"\n# this is a comment\nexpr main word",+ true,+ )+ .unwrap();++ assert_eq!(+ ast.stmts,+ vec![+ AstStmtNode::create_declare_variable(+ "test",+ AstVariable::create_string("to be this")+ ),+ AstStmtNode::Comment("# this is a comment".to_string()),+ AstStmtNode::create_set_expr("main", AstExprNode::Word(char_string!("word")))+ ]+ );++ assert_eq!(+ ast.get_variable_value("test"),+ Some(&AstVariable::create_string("to be this"))+ );+ assert_eq!(+ ast.get_expr("main"),+ Some(&AstExprNode::Word(char_string!("word")))+ );+ }+#[test]#[should_panic]fn catches_non_whitespace_after_expr() {