Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat: render configuration structurally (#3123)

Elijah Potterb76e8dd395a8
diff --git a/harper-cli/src/lint.rs b/harper-cli/src/lint.rs
index d5789e7a3..47207ee45 100644
--- a/harper-cli/src/lint.rs
+++ b/harper-cli/src/lint.rs
@@ -11,7 +11,7 @@ use rayon::prelude::*;
use serde::Serialize;
use harper_core::{
- linting::{Lint, LintGroup, LintGroupConfig, LintKind},
+ linting::{FlatConfig, Lint, LintGroup, LintKind},
parsers::MarkdownOptions,
spell::{Dictionary, MergedDictionary, MutableDictionary},
weirpack::Weirpack,
@@ -202,7 +202,7 @@ pub fn lint(
// Filter out any rules from ignore/only lists that don't exist in the current config
// Uses a cached config to avoid expensive linter initialization
- let mut config = LintGroupConfig::new_curated();
+ let mut config = FlatConfig::new_curated();
for pack in &weirpacks {
for rule in pack.rules.keys() {
config.set_rule_enabled(rule, true);
diff --git a/harper-core/default_config.json b/harper-core/default_config.json
new file mode 100644
index 000000000..16ac29404
--- /dev/null
+++ b/harper-core/default_config.json
@@ -0,0 +1,5117 @@
+{
+ "settings": [
+ {
+ "Group": {
+ "label": "Proper Nouns",
+ "description": "Checks names of places, organizations, products, and other proper nouns that should keep their standard capitalization.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "Americas",
+ "state": true,
+ "label": "Americas"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Australia",
+ "state": true,
+ "label": "Australia"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OceansAndSeas",
+ "state": true,
+ "label": "Oceans And Seas"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Canada",
+ "state": true,
+ "label": "Canada"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Laos",
+ "state": true,
+ "label": "Laos"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Malaysia",
+ "state": true,
+ "label": "Malaysia"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Countries",
+ "state": true,
+ "label": "Countries"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NationalCapitals",
+ "state": true,
+ "label": "National Capitals"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ChineseCommunistParty",
+ "state": true,
+ "label": "Chinese Communist Party"
+ }
+ },
+ {
+ "Bool": {
+ "name": "UnitedOrganizations",
+ "state": true,
+ "label": "United Organizations"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Holidays",
+ "state": true,
+ "label": "Holidays"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Koreas",
+ "state": true,
+ "label": "Koreas"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AmazonNames",
+ "state": true,
+ "label": "Amazon Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GoogleNames",
+ "state": true,
+ "label": "Google Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AzureNames",
+ "state": true,
+ "label": "Azure Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MicrosoftNames",
+ "state": true,
+ "label": "Microsoft Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AppleNames",
+ "state": true,
+ "label": "Apple Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MetaNames",
+ "state": true,
+ "label": "Meta Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "JetpackNames",
+ "state": true,
+ "label": "Jetpack Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TumblrNames",
+ "state": true,
+ "label": "Tumblr Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PocketCastsNames",
+ "state": true,
+ "label": "Pocket Casts Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DayOneNames",
+ "state": true,
+ "label": "Day One Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "USUniversities",
+ "state": true,
+ "label": "US Universities"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NotablePlaces",
+ "state": true,
+ "label": "Notable Places"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ProperNouns",
+ "state": true,
+ "label": "Proper Nouns"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CompaniesProductsAndTrademarks",
+ "state": true,
+ "label": "Companies Products And Trademarks"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Initialisms",
+ "description": "Covers abbreviated forms and initialisms that should use the expected letter casing or punctuation.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "AsFarAsIKnow",
+ "state": true,
+ "label": "As Far As I Know"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AsSoonAsPossible",
+ "state": true,
+ "label": "As Soon As Possible"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BeRightBack",
+ "state": true,
+ "label": "Be Right Back"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ByTheWay",
+ "state": true,
+ "label": "By The Way"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExplainLikeImFive",
+ "state": true,
+ "label": "Explain Like Im Five"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ForWhatItsWorth",
+ "state": true,
+ "label": "For What Its Worth"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ForYourInformation",
+ "state": true,
+ "label": "For Your Information"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IDontKnow",
+ "state": true,
+ "label": "I Dont Know"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IfIRecallCorrectly",
+ "state": true,
+ "label": "If I Recall Correctly"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IfIUnderstandCorrectly",
+ "state": true,
+ "label": "If I Understand Correctly"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IfYouKnowYouKnow",
+ "state": true,
+ "label": "If You Know You Know"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InCaseYouMissedIt",
+ "state": true,
+ "label": "In Case You Missed It"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InMyHumbleOpinion",
+ "state": true,
+ "label": "In My Humble Opinion"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InMyOpinion",
+ "state": true,
+ "label": "In My Opinion"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InRealLife",
+ "state": true,
+ "label": "In Real Life"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NeverMind",
+ "state": true,
+ "label": "Never Mind"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OhMyGod",
+ "state": true,
+ "label": "Oh My God"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PleaseTakeALook",
+ "state": true,
+ "label": "Please Take A Look"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Really",
+ "state": true,
+ "label": "Really"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TalkToYouLater",
+ "state": true,
+ "label": "Talk To You Later"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToBeHonest",
+ "state": true,
+ "label": "To Be Honest"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Closed Compounds",
+ "description": "Flags compound words that should be written as a single closed form instead of split apart.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "Anybody",
+ "state": true,
+ "label": "Anybody"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Anyhow",
+ "state": true,
+ "label": "Anyhow"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Anywhere",
+ "state": true,
+ "label": "Anywhere"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Backplane",
+ "state": true,
+ "label": "Backplane"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Bypass",
+ "state": true,
+ "label": "Bypass"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Chalkboard",
+ "state": true,
+ "label": "Chalkboard"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Deadlift",
+ "state": true,
+ "label": "Deadlift"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Desktop",
+ "state": true,
+ "label": "Desktop"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Devops",
+ "state": true,
+ "label": "Devops"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Everybody",
+ "state": true,
+ "label": "Everybody"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Everyone",
+ "state": true,
+ "label": "Everyone"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Everywhere",
+ "state": true,
+ "label": "Everywhere"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Furthermore",
+ "state": true,
+ "label": "Furthermore"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Henceforth",
+ "state": true,
+ "label": "Henceforth"
+ }
+ },
+ {
+ "Bool": {
+ "name": "However",
+ "state": true,
+ "label": "However"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Insofar",
+ "state": true,
+ "label": "Insofar"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Instead",
+ "state": true,
+ "label": "Instead"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Intact",
+ "state": true,
+ "label": "Intact"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Itself",
+ "state": true,
+ "label": "Itself"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Keystroke",
+ "state": true,
+ "label": "Keystroke"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Keystrokes",
+ "state": true,
+ "label": "Keystrokes"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Laptop",
+ "state": true,
+ "label": "Laptop"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Meanwhile",
+ "state": true,
+ "label": "Meanwhile"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Middleware",
+ "state": true,
+ "label": "Middleware"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Misunderstand",
+ "state": true,
+ "label": "Misunderstand"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Misunderstood",
+ "state": true,
+ "label": "Misunderstood"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Misuse",
+ "state": true,
+ "label": "Misuse"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Misused",
+ "state": true,
+ "label": "Misused"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Multicore",
+ "state": true,
+ "label": "Multicore"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Multimedia",
+ "state": true,
+ "label": "Multimedia"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Multithreading",
+ "state": true,
+ "label": "Multithreading"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Myself",
+ "state": true,
+ "label": "Myself"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Nonetheless",
+ "state": true,
+ "label": "Nonetheless"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Nothing",
+ "state": true,
+ "label": "Nothing"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Notwithstanding",
+ "state": true,
+ "label": "Notwithstanding"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Nowhere",
+ "state": true,
+ "label": "Nowhere"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Overall",
+ "state": true,
+ "label": "Overall"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Overclocking",
+ "state": true,
+ "label": "Overclocking"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Overload",
+ "state": true,
+ "label": "Overload"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Overnight",
+ "state": true,
+ "label": "Overnight"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Postpone",
+ "state": true,
+ "label": "Postpone"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Proofread",
+ "state": true,
+ "label": "Proofread"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Regardless",
+ "state": true,
+ "label": "Regardless"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Shortcoming",
+ "state": true,
+ "label": "Shortcoming"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Shortcomings",
+ "state": true,
+ "label": "Shortcomings"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Somebody",
+ "state": true,
+ "label": "Somebody"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Somehow",
+ "state": true,
+ "label": "Somehow"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Someone",
+ "state": true,
+ "label": "Someone"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Somewhere",
+ "state": true,
+ "label": "Somewhere"
+ }
+ },
+ {
+ "Bool": {
+ "name": "There",
+ "state": true,
+ "label": "There"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Therefore",
+ "state": true,
+ "label": "Therefore"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Thereupon",
+ "state": true,
+ "label": "Thereupon"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Underclock",
+ "state": true,
+ "label": "Underclock"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Upset",
+ "state": true,
+ "label": "Upset"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Upward",
+ "state": true,
+ "label": "Upward"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Whereupon",
+ "state": true,
+ "label": "Whereupon"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Widespread",
+ "state": true,
+ "label": "Widespread"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Without",
+ "state": true,
+ "label": "Without"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Worldwide",
+ "state": true,
+ "label": "Worldwide"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Worthwhile",
+ "state": true,
+ "label": "Worthwhile"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Phrase Corrections",
+ "description": "Collects common phrase-level fixes where a standard expression is preferred over a mistaken variant.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "Ado",
+ "state": true,
+ "label": "Ado"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AtAllCosts",
+ "state": true,
+ "label": "At All Costs"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Bollocks",
+ "state": true,
+ "label": "Bollocks"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ChampAtTheBit",
+ "state": true,
+ "label": "Champ At The Bit"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ClientOrServerSide",
+ "state": true,
+ "label": "Client Or Server Side"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CompulseToCompel",
+ "state": true,
+ "label": "Compulse To Compel"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ConfirmThat",
+ "state": true,
+ "label": "Confirm That"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DefiniteArticle",
+ "state": true,
+ "label": "Definite Article"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DigestiveTract",
+ "state": true,
+ "label": "Digestive Tract"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Discuss",
+ "state": true,
+ "label": "Discuss"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DoesOrDose",
+ "state": true,
+ "label": "Does Or Dose"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandArgument",
+ "state": true,
+ "label": "Expand Argument"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandDependencies",
+ "state": true,
+ "label": "Expand Dependencies"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandDeref",
+ "state": true,
+ "label": "Expand Deref"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandParameter",
+ "state": true,
+ "label": "Expand Parameter"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandPointer",
+ "state": true,
+ "label": "Expand Pointer"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandStandardInputAndOutput",
+ "state": true,
+ "label": "Expand Standard Input And Output"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExplanationMark",
+ "state": true,
+ "label": "Explanation Mark"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExtendOrExtent",
+ "state": true,
+ "label": "Extend Or Extent"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FlauntForFlout",
+ "state": true,
+ "label": "Flaunt For Flout"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FoamAtTheMouth",
+ "state": true,
+ "label": "Foam At The Mouth"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FootTheBill",
+ "state": true,
+ "label": "Foot The Bill"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GetUsedTo",
+ "state": true,
+ "label": "Get Used To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GrindToAHalt",
+ "state": true,
+ "label": "Grind To A Halt"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HavePassed",
+ "state": true,
+ "label": "Have Passed"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HitTheNailOnTheHead",
+ "state": true,
+ "label": "Hit The Nail On The Head"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HomeInOn",
+ "state": true,
+ "label": "Home In On"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InDetail",
+ "state": true,
+ "label": "In Detail"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InvestIn",
+ "state": true,
+ "label": "Invest In"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LayoutVerb",
+ "state": true,
+ "label": "Layout Verb"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LitotesDirectPositive",
+ "state": true,
+ "label": "Litotes Direct Positive"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MakeDoWith",
+ "state": true,
+ "label": "Make Do With"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MakeSense",
+ "state": true,
+ "label": "Make Sense"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MootPoint",
+ "state": true,
+ "label": "Moot Point"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OperatingSystem",
+ "state": true,
+ "label": "Operating System"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PassersBy",
+ "state": true,
+ "label": "Passers By"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PeekBehindTheCurtain",
+ "state": true,
+ "label": "Peek Behind The Curtain"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Piggyback",
+ "state": true,
+ "label": "Piggyback"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RedundantSuperlatives",
+ "state": true,
+ "label": "Redundant Superlatives"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ResponsibilityFor",
+ "state": true,
+ "label": "Responsibility For"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ScapeGoat",
+ "state": true,
+ "label": "Scape Goat"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SeamToSeem",
+ "state": true,
+ "label": "Seam To Seem"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SubjunctiveWasToWere",
+ "state": true,
+ "label": "Subjunctive Was To Were"
+ }
+ },
+ {
+ "Bool": {
+ "name": "UseToUsedTo",
+ "state": true,
+ "label": "Use To Used To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WreakHavoc",
+ "state": true,
+ "label": "Wreak Havoc"
+ }
+ },
+ {
+ "Bool": {
+ "name": "VerseAsVerb",
+ "state": true,
+ "label": "Verse As Verb"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WroteToRote",
+ "state": true,
+ "label": "Wrote To Rote"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AwaitFor",
+ "state": true,
+ "label": "Await For"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CommitmentTo",
+ "state": true,
+ "label": "Commitment To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Copyright",
+ "state": true,
+ "label": "Copyright"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DateBackFrom",
+ "state": true,
+ "label": "Date Back From"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DoubleEdgedSword",
+ "state": true,
+ "label": "Double Edged Sword"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandAlloc",
+ "state": true,
+ "label": "Expand Alloc"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandDecl",
+ "state": true,
+ "label": "Expand Decl"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Expat",
+ "state": true,
+ "label": "Expat"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Expatriate",
+ "state": true,
+ "label": "Expatriate"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GetRidOf",
+ "state": true,
+ "label": "Get Rid Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HolyWar",
+ "state": true,
+ "label": "Holy War"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HowItLooksLike",
+ "state": true,
+ "label": "How It Looks Like"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MakeItSeem",
+ "state": true,
+ "label": "Make It Seem"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NervousWreck",
+ "state": true,
+ "label": "Nervous Wreck"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NotOnly",
+ "state": true,
+ "label": "Not Only"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RiseTheQuestion",
+ "state": true,
+ "label": "Rise The Question"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToTooIdioms",
+ "state": true,
+ "label": "To Too Idioms"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TooTo",
+ "state": true,
+ "label": "Too To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WholeEntire",
+ "state": true,
+ "label": "Whole Entire"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WorseOrWorst",
+ "state": true,
+ "label": "Worse Or Worst"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Capitalization and Case",
+ "description": "Catches capitalization and casing issues in titles, sentences, brands, and other case-sensitive text.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "CapitalizePersonalPronouns",
+ "state": true,
+ "label": "Capitalize Personal Pronouns"
+ }
+ },
+ {
+ "Bool": {
+ "name": "JohnsHopkins",
+ "state": true,
+ "label": "Johns Hopkins"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NumberSuffixCapitalization",
+ "state": true,
+ "label": "Number Suffix Capitalization"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SentenceCapitalization",
+ "state": true,
+ "label": "Sentence Capitalization"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheProperNounPossessive",
+ "state": true,
+ "label": "The Proper Noun Possessive"
+ }
+ },
+ {
+ "Bool": {
+ "name": "UseTitleCase",
+ "state": true,
+ "label": "Use Title Case"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WordPressDotcom",
+ "state": true,
+ "label": "WordPress Dotcom"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ColdModalTypo",
+ "state": true,
+ "label": "Cold Modal Typo"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GoggleBrand",
+ "state": true,
+ "label": "Goggle Brand"
+ }
+ },
+ {
+ "Bool": {
+ "name": "YeaToYeah",
+ "state": true,
+ "label": "Yea To Yeah"
+ }
+ },
+ {
+ "Bool": {
+ "name": "YehToYeah",
+ "state": true,
+ "label": "Yeh To Yeah"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Punctuation and Spacing",
+ "description": "Handles punctuation marks, apostrophes, quotation marks, commas, and spacing conventions.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "CommaFixes",
+ "state": true,
+ "label": "Comma Fixes"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Dashes",
+ "state": true,
+ "label": "Dashes"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DotInitialisms",
+ "state": true,
+ "label": "Dot Initialisms"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EllipsisLength",
+ "state": true,
+ "label": "Ellipsis Length"
+ }
+ },
+ {
+ "Bool": {
+ "name": "UseEllipsisCharacter",
+ "state": true,
+ "label": "Use Ellipsis Character"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NoFrenchSpaces",
+ "state": true,
+ "label": "No French Spaces"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NoOxfordComma",
+ "state": false,
+ "label": "No Oxford Comma"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OxfordComma",
+ "state": true,
+ "label": "Oxford Comma"
+ }
+ },
+ {
+ "Bool": {
+ "name": "QuoteSpacing",
+ "state": true,
+ "label": "Quote Spacing"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Spaces",
+ "state": true,
+ "label": "Spaces"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TransposedSpace",
+ "state": true,
+ "label": "Transposed Space"
+ }
+ },
+ {
+ "Bool": {
+ "name": "UnclosedQuotes",
+ "state": true,
+ "label": "Unclosed Quotes"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WrongApostrophe",
+ "state": true,
+ "label": "Wrong Apostrophe"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AOkHyphen",
+ "state": true,
+ "label": "A Ok Hyphen"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BluRayHyphen",
+ "state": true,
+ "label": "Blu Ray Hyphen"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CaseSensitive",
+ "state": true,
+ "label": "Case Sensitive"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ClickThroughRate",
+ "state": true,
+ "label": "Click Through Rate"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DoubleCheckHyphen",
+ "state": true,
+ "label": "Double Check Hyphen"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EagleEyed",
+ "state": true,
+ "label": "Eagle Eyed"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EverPresent",
+ "state": true,
+ "label": "Ever Present"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FaceFirst",
+ "state": true,
+ "label": "Face First"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FirstPersonModifierHyphen",
+ "state": true,
+ "label": "First Person Modifier Hyphen"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FromTheGetGo",
+ "state": true,
+ "label": "From The Get Go"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GuineaBissau",
+ "state": true,
+ "label": "Guinea Bissau"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IntroCueCommaBeforeThanks",
+ "state": true,
+ "label": "Intro Cue Comma Before Thanks"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MercedesBenzHyphen",
+ "state": true,
+ "label": "Mercedes Benz Hyphen"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OffTheCuff",
+ "state": true,
+ "label": "Off The Cuff"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OneHanded",
+ "state": true,
+ "label": "One Handed"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PasswordProtectedHyphen",
+ "state": true,
+ "label": "Password Protected Hyphen"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PortAuPrince",
+ "state": true,
+ "label": "Port Au Prince"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PortoNovo",
+ "state": true,
+ "label": "Porto Novo"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PostItNoteHyphen",
+ "state": true,
+ "label": "Post It Note Hyphen"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RainbowColoredHyphen",
+ "state": true,
+ "label": "Rainbow Colored Hyphen"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RapidFire",
+ "state": true,
+ "label": "Rapid Fire"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToDoHyphen",
+ "state": true,
+ "label": "To Do Hyphen"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WellBeing",
+ "state": true,
+ "label": "Well Being"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WorstCaseScenario",
+ "state": true,
+ "label": "Worst Case Scenario"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Numbers and Units",
+ "description": "Checks how numbers, dates, times, decades, and measurement units are written.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "BestOfAllTime",
+ "state": true,
+ "label": "Best Of All Time"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CorrectNumberSuffix",
+ "state": true,
+ "label": "Correct Number Suffix"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CurrencyPlacement",
+ "state": true,
+ "label": "Currency Placement"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DayAndAge",
+ "state": true,
+ "label": "Day And Age"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandMemoryShorthands",
+ "state": true,
+ "label": "Expand Memory Shorthands"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandPeople",
+ "state": true,
+ "label": "Expand People"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandTimeShorthands",
+ "state": true,
+ "label": "Expand Time Shorthands"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FewUnitsOfTimeAgo",
+ "state": true,
+ "label": "Few Units Of Time Ago"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HyphenateNumberDay",
+ "state": true,
+ "label": "Hyphenate Number Day"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InTimeFromNow",
+ "state": true,
+ "label": "In Time From Now"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Months",
+ "state": true,
+ "label": "Months"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MostNumber",
+ "state": true,
+ "label": "Most Number"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MostOfTheTimes",
+ "state": true,
+ "label": "Most Of The Times"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SinceDuration",
+ "state": true,
+ "label": "Since Duration"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SpelledNumbers",
+ "state": false,
+ "label": "Spelled Numbers"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PluralDecades",
+ "state": true,
+ "label": "Plural Decades"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ALongTime",
+ "state": true,
+ "label": "A Long Time"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DegreesKelvin",
+ "state": true,
+ "label": "Degrees Kelvin"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DegreesKelvinSymbol",
+ "state": true,
+ "label": "Degrees Kelvin Symbol"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EveryTime",
+ "state": true,
+ "label": "Every Time"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ForALongTime",
+ "state": true,
+ "label": "For A Long Time"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HalfAnHour",
+ "state": true,
+ "label": "Half An Hour"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ItTimeAuxiliary",
+ "state": true,
+ "label": "It Time Auxiliary"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LinesOfCode",
+ "state": true,
+ "label": "Lines Of Code"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OnSecondThought",
+ "state": true,
+ "label": "On Second Thought"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TickingTimeClock",
+ "state": true,
+ "label": "Ticking Time Clock"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToSomeDegree",
+ "state": true,
+ "label": "To Some Degree"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Pronouns and Possession",
+ "description": "Focuses on pronouns, contractions, possessives, and related agreement problems.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "ElsePossessive",
+ "state": true,
+ "label": "Else Possessive"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HavePronoun",
+ "state": true,
+ "label": "Have Pronoun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IAmAgreement",
+ "state": true,
+ "label": "I Am Agreement"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ItsContraction",
+ "state": true,
+ "label": "Its Contraction"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ItsPossessive",
+ "state": true,
+ "label": "Its Possessive"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MultipleSequentialPronouns",
+ "state": true,
+ "label": "Multiple Sequential Pronouns"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NorModalPronoun",
+ "state": true,
+ "label": "Nor Modal Pronoun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PossessiveNoun",
+ "state": false,
+ "label": "Possessive Noun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PossessiveYour",
+ "state": true,
+ "label": "Possessive Your"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PronounAre",
+ "state": true,
+ "label": "Pronoun Are"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PronounContraction",
+ "state": true,
+ "label": "Pronoun Contraction"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PronounInflectionBe",
+ "state": true,
+ "label": "Pronoun Inflection Be"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PronounKnew",
+ "state": true,
+ "label": "Pronoun Knew"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PronounVerbAgreement",
+ "state": true,
+ "label": "Pronoun Verb Agreement"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SubjectPronoun",
+ "state": true,
+ "label": "Subject Pronoun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheMy",
+ "state": true,
+ "label": "The My"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Theres",
+ "state": true,
+ "label": "There's"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheyreConfusions",
+ "state": true,
+ "label": "They're Confusions"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WereWhere",
+ "state": true,
+ "label": "Were Where"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WhomSubjectOfVerb",
+ "state": true,
+ "label": "Whom Subject Of Verb"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EachOthersPossessive",
+ "state": true,
+ "label": "Each Others Possessive"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HeDos",
+ "state": true,
+ "label": "He Dos"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HeartToHeard",
+ "state": true,
+ "label": "Heart To Heard"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IAm",
+ "state": true,
+ "label": "I Am"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IDo",
+ "state": true,
+ "label": "I Do"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InOfItself",
+ "state": true,
+ "label": "In Of Itself"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MyHouse",
+ "state": true,
+ "label": "My House"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NeedHelp",
+ "state": true,
+ "label": "Need Help"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheirToThere",
+ "state": true,
+ "label": "Their To There"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheirToTheyre",
+ "state": true,
+ "label": "Their To Theyre"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThereToTheir",
+ "state": true,
+ "label": "There To Their"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheyToThem",
+ "state": true,
+ "label": "They To Them"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheyreToTheir",
+ "state": true,
+ "label": "Theyre To Their"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WhetYourAppetite",
+ "state": true,
+ "label": "Whet Your Appetite"
+ }
+ },
+ {
+ "Bool": {
+ "name": "YourOutClauseAgreement",
+ "state": true,
+ "label": "Your Out Clause Agreement"
+ }
+ },
+ {
+ "Bool": {
+ "name": "YourPredicateAdjective",
+ "state": true,
+ "label": "Your Predicate Adjective"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Yourself",
+ "state": true,
+ "label": "Yourself"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Compounds and Hyphenation",
+ "description": "Covers hyphenation and multi-word compounds that should be open, closed, or hyphenated.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "CompoundNouns",
+ "state": true,
+ "label": "Compound Nouns"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CompoundSubjectI",
+ "state": true,
+ "label": "Compound Subject I"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DoubleClick",
+ "state": true,
+ "label": "Double Click"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MergeWords",
+ "state": true,
+ "label": "Merge Words"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OpenCompounds",
+ "state": true,
+ "label": "Open Compounds"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OpenTheLight",
+ "state": true,
+ "label": "Open The Light"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PhrasalVerbAsCompoundNoun",
+ "state": true,
+ "label": "Phrasal Verb As Compound Noun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SplitWords",
+ "state": true,
+ "label": "Split Words"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BuiltIn",
+ "state": true,
+ "label": "Built In"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EasyGoingCompoundAdjective",
+ "state": true,
+ "label": "Easy Going Compound Adjective"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LastDitch",
+ "state": true,
+ "label": "Last Ditch"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MakeupCompoundNoun",
+ "state": true,
+ "label": "Makeup Compound Noun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OvertimeCompoundNoun",
+ "state": true,
+ "label": "Overtime Compound Noun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RoadMap",
+ "state": true,
+ "label": "Road Map"
+ }
+ },
+ {
+ "Bool": {
+ "name": "StateOfTheArt",
+ "state": true,
+ "label": "State Of The Art"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThereAfterCompound",
+ "state": true,
+ "label": "There After Compound"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WokVerbTypo",
+ "state": true,
+ "label": "Wok Verb Typo"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Spelling and Orthography",
+ "description": "Flags misspellings, orthographic inconsistencies, and word forms that are spelled the wrong way.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "Misspell",
+ "state": true,
+ "label": "Misspell"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OrthographicConsistency",
+ "state": true,
+ "label": "Orthographic Consistency"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RegularIrregulars",
+ "state": true,
+ "label": "Regular Irregulars"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SneakedSnuck",
+ "state": true,
+ "label": "Sneaked Snuck"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SpellCheck",
+ "state": true,
+ "label": "Spell Check"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AdNauseam",
+ "state": true,
+ "label": "Ad Nauseam"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Albeit",
+ "state": true,
+ "label": "Albeit"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AllThough",
+ "state": true,
+ "label": "All Though"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AtLeasToLeast",
+ "state": true,
+ "label": "At Leas To Least"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BeenThere",
+ "state": true,
+ "label": "Been There"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BestRegards",
+ "state": true,
+ "label": "Best Regards"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BetterOffWith",
+ "state": true,
+ "label": "Better Off With"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CanBeSeen",
+ "state": true,
+ "label": "Can Be Seen"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CaseInPoint",
+ "state": true,
+ "label": "Case In Point"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DoNotWant",
+ "state": true,
+ "label": "Do Not Want"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EludedTo",
+ "state": true,
+ "label": "Eluded To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EverSince",
+ "state": true,
+ "label": "Ever Since"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExitedExcitedContext",
+ "state": true,
+ "label": "Exited Excited Context"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FetalPosition",
+ "state": true,
+ "label": "Fetal Position"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ForAWhile",
+ "state": true,
+ "label": "For A While"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GoingTo",
+ "state": true,
+ "label": "Going To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HowMach",
+ "state": true,
+ "label": "How Mach"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HumanLife",
+ "state": true,
+ "label": "Human Life"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InLieuOf",
+ "state": true,
+ "label": "In Lieu Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InThe",
+ "state": true,
+ "label": "In The"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IsKnownFor",
+ "state": true,
+ "label": "Is Known For"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ItCan",
+ "state": true,
+ "label": "It Can"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IveGotTo",
+ "state": true,
+ "label": "Ive Got To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "JustDeserts",
+ "state": true,
+ "label": "Just Deserts"
+ }
+ },
+ {
+ "Bool": {
+ "name": "KindRegards",
+ "state": true,
+ "label": "Kind Regards"
+ }
+ },
+ {
+ "Bool": {
+ "name": "KindSortOf",
+ "state": true,
+ "label": "Kind Sort Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LetAlone",
+ "state": true,
+ "label": "Let Alone"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LooksLikes",
+ "state": true,
+ "label": "Looks Likes"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MoreThatLikely",
+ "state": true,
+ "label": "More That Likely"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NobelPeacePrize",
+ "state": true,
+ "label": "Nobel Peace Prize"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NotIn",
+ "state": true,
+ "label": "Not In"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NotTo",
+ "state": true,
+ "label": "Not To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NowWay",
+ "state": true,
+ "label": "Now Way"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OutOfSync",
+ "state": true,
+ "label": "Out Of Sync"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PedalToTheMetal",
+ "state": true,
+ "label": "Pedal To The Metal"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PerSe",
+ "state": true,
+ "label": "Per Se"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PleasRequestVerb",
+ "state": true,
+ "label": "Pleas Request Verb"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RallyToReally",
+ "state": true,
+ "label": "Rally To Really"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SomeOfThe",
+ "state": true,
+ "label": "Some Of The"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SpecialAttention",
+ "state": true,
+ "label": "Special Attention"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SpinalChord",
+ "state": true,
+ "label": "Spinal Chord"
+ }
+ },
+ {
+ "Bool": {
+ "name": "StrikeChord",
+ "state": true,
+ "label": "Strike Chord"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThatThis",
+ "state": true,
+ "label": "That This"
+ }
+ },
+ {
+ "Bool": {
+ "name": "The",
+ "state": true,
+ "label": "The"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThieveNoun",
+ "state": true,
+ "label": "Thieve Noun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThoughtProcess",
+ "state": true,
+ "label": "Thought Process"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToLoseTooLoose",
+ "state": true,
+ "label": "To Lose Too Loose"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TrialAndError",
+ "state": true,
+ "label": "Trial And Error"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TuffEnough",
+ "state": true,
+ "label": "Tuff Enough"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TurnItOff",
+ "state": true,
+ "label": "Turn It Off"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WithoutOut",
+ "state": true,
+ "label": "Without Out"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Style and Redundancy",
+ "description": "Highlights wordy, repetitive, or overly weak phrasing that can usually be tightened up.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "BoringWords",
+ "state": false,
+ "label": "Boring Words"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DiscourseMarkers",
+ "state": true,
+ "label": "Discourse Markers"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FillerWords",
+ "state": true,
+ "label": "Filler Words"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Hedging",
+ "state": true,
+ "label": "Hedging"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LongSentences",
+ "state": true,
+ "label": "Long Sentences"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MoreBetter",
+ "state": true,
+ "label": "More Better"
+ }
+ },
+ {
+ "Bool": {
+ "name": "QuiteQuiet",
+ "state": true,
+ "label": "Quite Quiet"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RedundantAcronyms",
+ "state": true,
+ "label": "Redundant Acronyms"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RedundantAdditiveAdverbs",
+ "state": true,
+ "label": "Redundant Additive Adverbs"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RedundantProgressiveComparative",
+ "state": true,
+ "label": "Redundant Progressive Comparative"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RepeatedWords",
+ "state": true,
+ "label": "Repeated Words"
+ }
+ },
+ {
+ "Bool": {
+ "name": "VeryUnique",
+ "state": true,
+ "label": "Very Unique"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WayTooAdjective",
+ "state": true,
+ "label": "Way Too Adjective"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WidelyAccepted",
+ "state": true,
+ "label": "Widely Accepted"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MultipleFrequencyAdverbs",
+ "state": true,
+ "label": "Multiple Frequency Adverbs"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ACoupleMore",
+ "state": true,
+ "label": "A Couple More"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AnAnother",
+ "state": true,
+ "label": "An Another"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AnotherAn",
+ "state": true,
+ "label": "Another An"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ArriveOnWeekday",
+ "state": true,
+ "label": "Arrive On Weekday"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AsIfThough",
+ "state": true,
+ "label": "As If Though"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AvoidAndAlso",
+ "state": true,
+ "label": "Avoid And Also"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CauseItIsBecause",
+ "state": true,
+ "label": "Cause It Is Because"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CondenseAllThe",
+ "state": true,
+ "label": "Condense All The"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Cybersec",
+ "state": true,
+ "label": "Cybersec"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Excellent",
+ "state": true,
+ "label": "Excellent"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandBecause",
+ "state": true,
+ "label": "Expand Because"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandControl",
+ "state": true,
+ "label": "Expand Control"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandForward",
+ "state": true,
+ "label": "Expand Forward"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandMinimum",
+ "state": true,
+ "label": "Expand Minimum"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandPrevious",
+ "state": true,
+ "label": "Expand Previous"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandThrough",
+ "state": true,
+ "label": "Expand Through"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandWith",
+ "state": true,
+ "label": "Expand With"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExpandWithout",
+ "state": true,
+ "label": "Expand Without"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FatalOutcome",
+ "state": true,
+ "label": "Fatal Outcome"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Freezing",
+ "state": true,
+ "label": "Freezing"
+ }
+ },
+ {
+ "Bool": {
+ "name": "KindOf",
+ "state": true,
+ "label": "Kind Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RedundantIIRC",
+ "state": true,
+ "label": "Redundant IIRC"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RedundantPretty",
+ "state": true,
+ "label": "Redundant Pretty"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RedundantThat",
+ "state": true,
+ "label": "Redundant That"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SendAnEmailTo",
+ "state": true,
+ "label": "Send An Email To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Starving",
+ "state": true,
+ "label": "Starving"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Towards",
+ "state": true,
+ "label": "Towards"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TrueToWord",
+ "state": true,
+ "label": "True To Word"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WasComprisedOf",
+ "state": true,
+ "label": "Was Comprised Of"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Grammar and Agreement",
+ "description": "Catches grammar issues involving agreement, articles, prepositions, verb forms, and sentence structure.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "AdjectiveDoubleDegree",
+ "state": true,
+ "label": "Adjective Double Degree"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AdjectiveOfA",
+ "state": true,
+ "label": "Adjective Of A"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AskNoPreposition",
+ "state": true,
+ "label": "Ask No Preposition"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DoubleModal",
+ "state": true,
+ "label": "Double Modal"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ForNoun",
+ "state": true,
+ "label": "For Noun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HowTo",
+ "state": true,
+ "label": "How To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IfWouldve",
+ "state": true,
+ "label": "If Wouldve"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InflectedVerbAfterTo",
+ "state": true,
+ "label": "Inflected Verb After To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LetToDo",
+ "state": true,
+ "label": "Let To Do"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MassNouns",
+ "state": true,
+ "label": "Mass Nouns"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MissingPreposition",
+ "state": true,
+ "label": "Missing Preposition"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MissingTo",
+ "state": true,
+ "label": "Missing To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ModalBeAdjective",
+ "state": true,
+ "label": "Modal Be Adjective"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ModalOf",
+ "state": true,
+ "label": "Modal Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ModalSeem",
+ "state": true,
+ "label": "Modal Seem"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MoreAdjective",
+ "state": true,
+ "label": "More Adjective"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NeedToNoun",
+ "state": true,
+ "label": "Need To Noun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NominalWants",
+ "state": true,
+ "label": "Nominal Wants"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NounVerbConfusion",
+ "state": true,
+ "label": "Noun Verb Confusion"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ObsessPreposition",
+ "state": true,
+ "label": "Obsess Preposition"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OneAndTheSame",
+ "state": true,
+ "label": "One And The Same"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OneOfTheSingular",
+ "state": true,
+ "label": "One Of The Singular"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OughtToBe",
+ "state": true,
+ "label": "Ought To Be"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PluralWrongWordOfPhrase",
+ "state": true,
+ "label": "Plural Wrong Word Of Phrase"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ProgressiveNeedsBe",
+ "state": true,
+ "label": "Progressive Needs Be"
+ }
+ },
+ {
+ "Bool": {
+ "name": "QuantifierNeedsOf",
+ "state": true,
+ "label": "Quantifier Needs Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "QuantifierNumeralConflict",
+ "state": true,
+ "label": "Quantifier Numeral Conflict"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ReasonForDoing",
+ "state": true,
+ "label": "Reason For Doing"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SimplePastToPastParticiple",
+ "state": true,
+ "label": "Simple Past To Past Participle"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SingleBe",
+ "state": true,
+ "label": "Single Be"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SomeWithoutArticle",
+ "state": true,
+ "label": "Some Without Article"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TakeALookTo",
+ "state": true,
+ "label": "Take A Look To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TakeMedicine",
+ "state": true,
+ "label": "Take Medicine"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThatThan",
+ "state": true,
+ "label": "That Than"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThatWhich",
+ "state": true,
+ "label": "That Which"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThenThan",
+ "state": true,
+ "label": "Then Than"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThriveOn",
+ "state": true,
+ "label": "Thrive On"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TryOnesHandAt",
+ "state": true,
+ "label": "Try Ones Hand At"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TryOnesLuck",
+ "state": true,
+ "label": "Try Ones Luck"
+ }
+ },
+ {
+ "Bool": {
+ "name": "VerbToAdjective",
+ "state": true,
+ "label": "Verb To Adjective"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WouldNeverHave",
+ "state": true,
+ "label": "Would Never Have"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AfterAWhile",
+ "state": true,
+ "label": "After A While"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AfterAll",
+ "state": true,
+ "label": "After All"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AllReady",
+ "state": true,
+ "label": "All Ready"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AnotherOnes",
+ "state": true,
+ "label": "Another Ones"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AnotherThings",
+ "state": true,
+ "label": "Another Things"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AsEvidentBy",
+ "state": true,
+ "label": "As Evident By"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AsFollows",
+ "state": true,
+ "label": "As Follows"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AsLongAs",
+ "state": true,
+ "label": "As Long As"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Beforehand",
+ "state": true,
+ "label": "Beforehand"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BetterOffPhrase",
+ "state": true,
+ "label": "Better Off Phrase"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DoIAdjective",
+ "state": true,
+ "label": "Do I Adjective"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DontCan",
+ "state": true,
+ "label": "Don't Can"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DoubleNegative",
+ "state": true,
+ "label": "Double Negative"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EachAndEveryOne",
+ "state": true,
+ "label": "Each And Every One"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HadOf",
+ "state": true,
+ "label": "Had Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HaveNegNoAny",
+ "state": true,
+ "label": "Have Neg No Any"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HumanBeings",
+ "state": true,
+ "label": "Human Beings"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InAWhile",
+ "state": true,
+ "label": "In A While"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InAnyWay",
+ "state": true,
+ "label": "In Any Way"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InsteadOf",
+ "state": true,
+ "label": "Instead Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "IsBeenAuxSequence",
+ "state": true,
+ "label": "Is Been Aux Sequence"
+ }
+ },
+ {
+ "Bool": {
+ "name": "KnowNothingVerb",
+ "state": true,
+ "label": "Know Nothing Verb"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LikeAsIf",
+ "state": true,
+ "label": "Like As If"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LookInto",
+ "state": true,
+ "label": "Look Into"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MissingDeterminer",
+ "state": true,
+ "label": "Missing Determiner"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NotBeAfterNot",
+ "state": true,
+ "label": "Not Be After Not"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PartsOfSpeech",
+ "state": true,
+ "label": "Parts Of Speech"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PointsOfView",
+ "state": true,
+ "label": "Points Of View"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PrincipleToPrincipalRoleNoun",
+ "state": true,
+ "label": "Principle To Principal Role Noun"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RelayOnForRely",
+ "state": true,
+ "label": "Relay On For Rely"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RulesOfThumb",
+ "state": true,
+ "label": "Rules Of Thumb"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SameAs",
+ "state": true,
+ "label": "Same As"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ShutdownVerb",
+ "state": true,
+ "label": "Shutdown Verb"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SomebodyElses",
+ "state": true,
+ "label": "Somebody Elses"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThanksALot",
+ "state": true,
+ "label": "Thanks A Lot"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheAnother",
+ "state": true,
+ "label": "The Another"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThereMissingIsClause",
+ "state": true,
+ "label": "There Missing Is Clause"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThinkKnowOff",
+ "state": true,
+ "label": "Think Know Off"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThreatenVerb",
+ "state": true,
+ "label": "Threaten Verb"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToGreatLengths",
+ "state": true,
+ "label": "To Great Lengths"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToWorryAbout",
+ "state": true,
+ "label": "To Worry About"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TomorrowPossessiveModifier",
+ "state": true,
+ "label": "Tomorrow Possessive Modifier"
+ }
+ },
+ {
+ "Bool": {
+ "name": "VeryLess",
+ "state": true,
+ "label": "Very Less"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WantBe",
+ "state": true,
+ "label": "Want Be"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WillContain",
+ "state": true,
+ "label": "Will Contain"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WillNonLemma",
+ "state": true,
+ "label": "Will Non Lemma"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AspireTo",
+ "state": true,
+ "label": "Aspire To"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Word Choice and Usage",
+ "description": "Suggests more standard or idiomatic wording when a phrase is technically understandable but poorly chosen.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "AllowTo",
+ "state": true,
+ "label": "Allow To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ArriveTo",
+ "state": true,
+ "label": "Arrive To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AvoidCurses",
+ "state": true,
+ "label": "Avoid Curses"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BeAllowed",
+ "state": true,
+ "label": "Be Allowed"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BeBiased",
+ "state": true,
+ "label": "Be Biased"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BeConcerned",
+ "state": true,
+ "label": "Be Concerned"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BePrejudiced",
+ "state": true,
+ "label": "Be Prejudiced"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BeShocked",
+ "state": true,
+ "label": "Be Shocked"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BeWorried",
+ "state": true,
+ "label": "Be Worried"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Bought",
+ "state": true,
+ "label": "Bought"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BrandBrandish",
+ "state": true,
+ "label": "Brand Brandish"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ByAccident",
+ "state": true,
+ "label": "By Accident"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CautionaryTale",
+ "state": true,
+ "label": "Cautionary Tale"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ChangeTack",
+ "state": true,
+ "label": "Change Tack"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ChockFull",
+ "state": true,
+ "label": "Chock Full"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Confident",
+ "state": true,
+ "label": "Confident"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CureFor",
+ "state": true,
+ "label": "Cure For"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DoMistake",
+ "state": true,
+ "label": "Do Mistake"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EverEvery",
+ "state": true,
+ "label": "Ever Every"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Everyday",
+ "state": true,
+ "label": "Everyday"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ExceptOf",
+ "state": true,
+ "label": "Except Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FarBeIt",
+ "state": true,
+ "label": "Far Be It"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FascinatedBy",
+ "state": true,
+ "label": "Fascinated By"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FeelFell",
+ "state": true,
+ "label": "Feel Fell"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FirstAidKit",
+ "state": true,
+ "label": "First Aid Kit"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FleshOutVsFullFledged",
+ "state": true,
+ "label": "Flesh Out Vs Full Fledged"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FreePredicate",
+ "state": true,
+ "label": "Free Predicate"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FriendOfMe",
+ "state": true,
+ "label": "Friend Of Me"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GoodAt",
+ "state": true,
+ "label": "Good At"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Handful",
+ "state": true,
+ "label": "Handful"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HelloGreeting",
+ "state": true,
+ "label": "Hello Greeting"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Hereby",
+ "state": true,
+ "label": "Hereby"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HopHope",
+ "state": true,
+ "label": "Hop Hope"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InterestedIn",
+ "state": true,
+ "label": "Interested In"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ItLooksLikeThat",
+ "state": true,
+ "label": "It Looks Like That"
+ }
+ },
+ {
+ "Bool": {
+ "name": "JealousOf",
+ "state": true,
+ "label": "Jealous Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LeadRiseTo",
+ "state": true,
+ "label": "Lead Rise To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LeftRightHand",
+ "state": true,
+ "label": "Left Right Hand"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LessWorse",
+ "state": true,
+ "label": "Less Worse"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Likewise",
+ "state": true,
+ "label": "Likewise"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LookDownOnesNose",
+ "state": true,
+ "label": "Look Down Ones Nose"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LookingForwardTo",
+ "state": true,
+ "label": "Looking Forward To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LookForwardTo",
+ "state": true,
+ "label": "Look Forward To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MeansALotTo",
+ "state": true,
+ "label": "Means A Lot To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "MixedBag",
+ "state": true,
+ "label": "Mixed Bag"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NoLonger",
+ "state": true,
+ "label": "No Longer"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NoMatchFor",
+ "state": true,
+ "label": "No Match For"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Nobody",
+ "state": true,
+ "label": "Nobody"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OfCourse",
+ "state": true,
+ "label": "Of Course"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OldestInTheBook",
+ "state": true,
+ "label": "Oldest In The Book"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OnFloor",
+ "state": true,
+ "label": "On Floor"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OnceOrTwice",
+ "state": true,
+ "label": "Once Or Twice"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OutOfDate",
+ "state": true,
+ "label": "Out Of Date"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Oxymorons",
+ "state": true,
+ "label": "Oxymorons"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PiqueInterest",
+ "state": true,
+ "label": "Pique Interest"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Respond",
+ "state": true,
+ "label": "Respond"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RightClick",
+ "state": true,
+ "label": "Right Click"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RiseTheRanks",
+ "state": true,
+ "label": "Rise The Ranks"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RollerSkated",
+ "state": true,
+ "label": "Roller Skated"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SafeToSave",
+ "state": true,
+ "label": "Safe To Save"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SaveToSafe",
+ "state": true,
+ "label": "Save To Safe"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SomethingIs",
+ "state": true,
+ "label": "Something Is"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SomewhatSomething",
+ "state": true,
+ "label": "Somewhat Something"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SoonToBe",
+ "state": true,
+ "label": "Soon To Be"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SoughtAfter",
+ "state": true,
+ "label": "Sought After"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToAdverb",
+ "state": true,
+ "label": "To Adverb"
+ }
+ },
+ {
+ "Bool": {
+ "name": "UpdatePlaceNames",
+ "state": true,
+ "label": "Update Place Names"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ViceVersa",
+ "state": true,
+ "label": "Vice Versa"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WasAloud",
+ "state": true,
+ "label": "Was Aloud"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WellEducated",
+ "state": true,
+ "label": "Well Educated"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WinPrize",
+ "state": true,
+ "label": "Win Prize"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WishCould",
+ "state": true,
+ "label": "Wish Could"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WorthToDo",
+ "state": true,
+ "label": "Worth To Do"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AheadAnd",
+ "state": true,
+ "label": "Ahead And"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AllOfASudden",
+ "state": true,
+ "label": "All Of A Sudden"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Alongside",
+ "state": true,
+ "label": "Alongside"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AlzheimersDisease",
+ "state": true,
+ "label": "Alzheimers Disease"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AsFarBackAs",
+ "state": true,
+ "label": "As Far Back As"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AsItHappens",
+ "state": true,
+ "label": "As It Happens"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AsOfCurrently",
+ "state": true,
+ "label": "As Of Currently"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AsOfLately",
+ "state": true,
+ "label": "As Of Lately"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AsOpposedTo",
+ "state": true,
+ "label": "As Opposed To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AtFaceValue",
+ "state": true,
+ "label": "At Face Value"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AtTheBestOfTimes",
+ "state": true,
+ "label": "At The Best Of Times"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AtTheEndOfTheDay",
+ "state": true,
+ "label": "At The End Of The Day"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AtTheExpenseOf",
+ "state": true,
+ "label": "At The Expense Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AwareOf",
+ "state": true,
+ "label": "Aware Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BadRap",
+ "state": true,
+ "label": "Bad Rap"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BanTogether",
+ "state": true,
+ "label": "Ban Together"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BareInMind",
+ "state": true,
+ "label": "Bare In Mind"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BatedBreath",
+ "state": true,
+ "label": "Bated Breath"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BeckAndCall",
+ "state": true,
+ "label": "Beck And Call"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BesideThePoint",
+ "state": true,
+ "label": "Beside The Point"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BewareOf",
+ "state": true,
+ "label": "Beware Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BlacklistWhitelist",
+ "state": true,
+ "label": "Blacklist Whitelist"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BlanketStatement",
+ "state": true,
+ "label": "Blanket Statement"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Brutality",
+ "state": true,
+ "label": "Brutality"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ComprisesOf",
+ "state": true,
+ "label": "Comprises Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CoursingThroughVeins",
+ "state": true,
+ "label": "Coursing Through Veins"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CuttingAgeEggcorn",
+ "state": true,
+ "label": "Cutting Age Eggcorn"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DampSquib",
+ "state": true,
+ "label": "Damp Squib"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DoToDueTo",
+ "state": true,
+ "label": "Do To Due To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DueDiligence",
+ "state": true,
+ "label": "Due Diligence"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DuringAges",
+ "state": true,
+ "label": "During Ages"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EggYolk",
+ "state": true,
+ "label": "Egg Yolk"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EnMasse",
+ "state": true,
+ "label": "En Masse"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EnRoute",
+ "state": true,
+ "label": "En Route"
+ }
+ },
+ {
+ "Bool": {
+ "name": "EveryOnceAndAgain",
+ "state": true,
+ "label": "Every Once And Again"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FairBit",
+ "state": true,
+ "label": "Fair Bit"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FarAndFewBetween",
+ "state": true,
+ "label": "Far And Few Between"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FastPaste",
+ "state": true,
+ "label": "Fast Paste"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ForArgumentsSake",
+ "state": true,
+ "label": "For Arguments Sake"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ForTheMostPart",
+ "state": true,
+ "label": "For The Most Part"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FreeRein",
+ "state": true,
+ "label": "Free Rein"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GildedAge",
+ "state": true,
+ "label": "Gilded Age"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Haphazard",
+ "state": true,
+ "label": "Haphazard"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HiddenIn",
+ "state": true,
+ "label": "Hidden In"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HungerPang",
+ "state": true,
+ "label": "Hunger Pang"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ImitateFrom",
+ "state": true,
+ "label": "Imitate From"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InAHurry",
+ "state": true,
+ "label": "In A Hurry"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InNeedOf",
+ "state": true,
+ "label": "In Need Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Initiatively",
+ "state": true,
+ "label": "Initiatively"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Insensitive",
+ "state": true,
+ "label": "Insensitive"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Insurmountable",
+ "state": true,
+ "label": "Insurmountable"
+ }
+ },
+ {
+ "Bool": {
+ "name": "JawDropping",
+ "state": true,
+ "label": "Jaw Dropping"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LastButNotLeast",
+ "state": true,
+ "label": "Last But Not Least"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LastNight",
+ "state": true,
+ "label": "Last Night"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LaughOfAt",
+ "state": true,
+ "label": "Laugh Of At"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LeaveToFor",
+ "state": true,
+ "label": "Leave To For"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LikeThePlague",
+ "state": true,
+ "label": "Like The Plague"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LikeTheresNoTomorrow",
+ "state": true,
+ "label": "Like Theres No Tomorrow"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LikelyHood",
+ "state": true,
+ "label": "Likely Hood"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LowHangingFruit",
+ "state": true,
+ "label": "Low Hanging Fruit"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ManagerialReins",
+ "state": true,
+ "label": "Managerial Reins"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Monumentous",
+ "state": true,
+ "label": "Monumentous"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NerveRacking",
+ "state": true,
+ "label": "Nerve Racking"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OldWivesTale",
+ "state": true,
+ "label": "Old Wives Tale"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OnFirstGlance",
+ "state": true,
+ "label": "On First Glance"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OnTheSpurOfTheMoment",
+ "state": true,
+ "label": "On The Spur Of The Moment"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OnTopOf",
+ "state": true,
+ "label": "On Top Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OnceInAWhile",
+ "state": true,
+ "label": "Once In A While"
+ }
+ },
+ {
+ "Bool": {
+ "name": "OneFellSwoop",
+ "state": true,
+ "label": "One Fell Swoop"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PeaceOfMind",
+ "state": true,
+ "label": "Peace Of Mind"
+ }
+ },
+ {
+ "Bool": {
+ "name": "PrayingMantis",
+ "state": true,
+ "label": "Praying Mantis"
+ }
+ },
+ {
+ "Bool": {
+ "name": "QuiteMany",
+ "state": true,
+ "label": "Quite Many"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RealTrouper",
+ "state": true,
+ "label": "Real Trouper"
+ }
+ },
+ {
+ "Bool": {
+ "name": "RifeWith",
+ "state": true,
+ "label": "Rife With"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ScantilyClad",
+ "state": true,
+ "label": "Scantily Clad"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SimilarLike",
+ "state": true,
+ "label": "Similar Like"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SimpleGrammatical",
+ "state": true,
+ "label": "Simple Grammatical"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SneakPeekPreview",
+ "state": true,
+ "label": "Sneak Peek Preview"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SneakingSuspicion",
+ "state": true,
+ "label": "Sneaking Suspicion"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SoonerOrLater",
+ "state": true,
+ "label": "Sooner Or Later"
+ }
+ },
+ {
+ "Bool": {
+ "name": "StatuteOfLimitations",
+ "state": true,
+ "label": "Statute Of Limitations"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SufficeItToSay",
+ "state": true,
+ "label": "Suffice It To Say"
+ }
+ },
+ {
+ "Bool": {
+ "name": "SupposedTo",
+ "state": true,
+ "label": "Supposed To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TakeItPersonally",
+ "state": true,
+ "label": "Take It Personally"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThatChallenged",
+ "state": true,
+ "label": "That Challenged"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheDifferenceBetween",
+ "state": true,
+ "label": "The Difference Between"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheWhetherWeather",
+ "state": true,
+ "label": "The Whether Weather"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToBackOut",
+ "state": true,
+ "label": "To Back Out"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToTheMannerBorn",
+ "state": true,
+ "label": "To The Manner Born"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TongueInCheek",
+ "state": true,
+ "label": "Tongue In Cheek"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Unless",
+ "state": true,
+ "label": "Unless"
+ }
+ },
+ {
+ "Bool": {
+ "name": "VeryKnown",
+ "state": true,
+ "label": "Very Known"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WaveFunction",
+ "state": true,
+ "label": "Wave Function"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WellKept",
+ "state": true,
+ "label": "Well Kept"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WroughtIron",
+ "state": true,
+ "label": "Wrought Iron"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Damages",
+ "state": true,
+ "label": "Damages"
+ }
+ },
+ {
+ "Bool": {
+ "name": "WebScraping",
+ "state": true,
+ "label": "Web Scraping"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Regionalisms and Dialect",
+ "description": "Groups dialect-sensitive wording and regional usage that may not fit the selected audience.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "Regionalisms",
+ "state": true,
+ "label": "Regionalisms"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Touristic",
+ "state": true,
+ "label": "Touristic"
+ }
+ }
+ ]
+ }
+ }
+ },
+ {
+ "Group": {
+ "label": "Miscellaneous",
+ "description": "A catch-all for rules that do not fit neatly into the other categories but are still useful to surface.",
+ "child": {
+ "settings": [
+ {
+ "Bool": {
+ "name": "APart",
+ "state": true,
+ "label": "A Part"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AWhile",
+ "state": true,
+ "label": "A While"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Addicting",
+ "state": true,
+ "label": "Addicting"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AfterLater",
+ "state": true,
+ "label": "After Later"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AllHellBreakLoose",
+ "state": true,
+ "label": "All Hell Break Loose"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AllIntentsAndPurposes",
+ "state": true,
+ "label": "All Intents And Purposes"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AmInTheMorning",
+ "state": true,
+ "label": "Am In The Morning"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AmountsFor",
+ "state": true,
+ "label": "Amounts For"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AnA",
+ "state": true,
+ "label": "An A"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AndIn",
+ "state": true,
+ "label": "And In"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AndTheLike",
+ "state": true,
+ "label": "And The Like"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AnotherThingComing",
+ "state": true,
+ "label": "Another Thing Coming"
+ }
+ },
+ {
+ "Bool": {
+ "name": "AnotherThinkComing",
+ "state": false,
+ "label": "Another Think Coming"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ApartFrom",
+ "state": true,
+ "label": "Apart From"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BackInTheDay",
+ "state": true,
+ "label": "Back In The Day"
+ }
+ },
+ {
+ "Bool": {
+ "name": "BehindTheScenes",
+ "state": true,
+ "label": "Behind The Scenes"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Cant",
+ "state": true,
+ "label": "Can't"
+ }
+ },
+ {
+ "Bool": {
+ "name": "CriteriaPhenomena",
+ "state": true,
+ "label": "Criteria Phenomena"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DespiteItIs",
+ "state": true,
+ "label": "Despite It Is"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DespiteOf",
+ "state": true,
+ "label": "Despite Of"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DidPast",
+ "state": true,
+ "label": "Did Past"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Didnt",
+ "state": true,
+ "label": "Didn't"
+ }
+ },
+ {
+ "Bool": {
+ "name": "DisjointPrefixes",
+ "state": true,
+ "label": "Disjoint Prefixes"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FedUpWith",
+ "state": true,
+ "label": "Fed Up With"
+ }
+ },
+ {
+ "Bool": {
+ "name": "FindFine",
+ "state": true,
+ "label": "Find Fine"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GoSoFarAsTo",
+ "state": true,
+ "label": "Go So Far As To"
+ }
+ },
+ {
+ "Bool": {
+ "name": "GoToWar",
+ "state": true,
+ "label": "Go To War"
+ }
+ },
+ {
+ "Bool": {
+ "name": "HaveTakeALook",
+ "state": true,
+ "label": "Have Take A Look"
+ }
+ },
+ {
+ "Bool": {
+ "name": "InOnTheCards",
+ "state": true,
+ "label": "In On The Cards"
+ }
+ },
+ {
+ "Bool": {
+ "name": "LetsConfusion",
+ "state": true,
+ "label": "Lets Confusion"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NailOnTheHead",
+ "state": true,
+ "label": "Nail On The Head"
+ }
+ },
+ {
+ "Bool": {
+ "name": "NotOnlyInversion",
+ "state": true,
+ "label": "Not Only Inversion"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ShootOneselfInTheFoot",
+ "state": true,
+ "label": "Shoot Oneself In The Foot"
+ }
+ },
+ {
+ "Bool": {
+ "name": "TheHowWhy",
+ "state": true,
+ "label": "The How Why"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThePointFor",
+ "state": true,
+ "label": "The Point For"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThesesThese",
+ "state": true,
+ "label": "Theses These"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThingThink",
+ "state": true,
+ "label": "Thing Think"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThisTypeOfThing",
+ "state": true,
+ "label": "This Type Of Thing"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThoughThought",
+ "state": true,
+ "label": "Though Thought"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThrowAway",
+ "state": true,
+ "label": "Throw Away"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ThrowRubbish",
+ "state": true,
+ "label": "Throw Rubbish"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ToTwoToo",
+ "state": true,
+ "label": "To Two Too"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ViciousCircle",
+ "state": true,
+ "label": "Vicious Circle"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ViciousCircleOrCycle",
+ "state": false,
+ "label": "Vicious Circle Or Cycle"
+ }
+ },
+ {
+ "Bool": {
+ "name": "ViciousCycle",
+ "state": false,
+ "label": "Vicious Cycle"
+ }
+ },
+ {
+ "Bool": {
+ "name": "Whereas",
+ "state": true,
+ "label": "Whereas"
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+}
diff --git a/harper-core/src/linting/lint_group/flat_config.rs b/harper-core/src/linting/lint_group/flat_config.rs
new file mode 100644
index 000000000..8551b74bc
--- /dev/null
+++ b/harper-core/src/linting/lint_group/flat_config.rs
@@ -0,0 +1,127 @@
+use std::collections::BTreeMap;
+use std::hash::{Hash, Hasher};
+use std::mem;
+use std::sync::OnceLock;
+
+use hashbrown::HashMap;
+use serde::{Deserialize, Deserializer, Serialize, Serializer};
+
+use super::LintGroup;
+use crate::Dialect;
+use crate::spell::MutableDictionary;
+
+fn ser_ordered<S>(map: &HashMap<String, Option<bool>>, ser: S) -> Result<S::Ok, S::Error>
+where
+ S: Serializer,
+{
+ let ordered: BTreeMap<_, _> = map.iter().map(|(k, v)| (k.clone(), *v)).collect();
+ ordered.serialize(ser)
+}
+
+fn de_hashbrown<'de, D>(de: D) -> Result<HashMap<String, Option<bool>>, D::Error>
+where
+ D: Deserializer<'de>,
+{
+ let ordered: BTreeMap<String, Option<bool>> = BTreeMap::deserialize(de)?;
+ Ok(ordered.into_iter().collect())
+}
+
+/// The rule-level configuration for a [`LintGroup`].
+/// Previously named `LintGroupConfig`.
+/// Each child linter can be enabled, disabled, or set to a curated value.
+/// So named because it represents the structure of a [`LintGroup`] exactly: it's flat.
+#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq, Eq)]
+#[serde(transparent)]
+pub struct FlatConfig {
+ /// We do this shenanigans with the [`BTreeMap`] to keep the serialized format consistent.
+ #[serde(serialize_with = "ser_ordered", deserialize_with = "de_hashbrown")]
+ inner: HashMap<String, Option<bool>>,
+}
+
+impl FlatConfig {
+ fn curated() -> Self {
+ static CURATED: OnceLock<FlatConfig> = OnceLock::new();
+
+ CURATED
+ .get_or_init(|| {
+ // The Dictionary and Dialect do not matter, we're just after the config.
+ let group =
+ LintGroup::new_curated(MutableDictionary::new().into(), Dialect::American);
+ group.config
+ })
+ .clone()
+ }
+
+ /// Check if a rule exists in the configuration.
+ pub fn has_rule(&self, key: impl AsRef<str>) -> bool {
+ self.inner.contains_key(key.as_ref())
+ }
+
+ pub fn set_rule_enabled(&mut self, key: impl ToString, val: bool) {
+ self.inner.insert(key.to_string(), Some(val));
+ }
+
+ /// Remove any configuration attached to a rule.
+ /// This allows it to assume its default (curated) state.
+ pub fn unset_rule_enabled(&mut self, key: impl AsRef<str>) {
+ self.inner.remove(key.as_ref());
+ }
+
+ pub fn set_rule_enabled_if_unset(&mut self, key: impl AsRef<str>, val: bool) {
+ if !self.inner.contains_key(key.as_ref()) {
+ self.set_rule_enabled(key.as_ref().to_string(), val);
+ }
+ }
+
+ pub fn is_rule_enabled(&self, key: &str) -> bool {
+ self.inner.get(key).cloned().flatten().unwrap_or(false)
+ }
+
+ /// Clear all config options.
+ /// This will reset them all to disable them.
+ pub fn clear(&mut self) {
+ for val in self.inner.values_mut() {
+ *val = None
+ }
+ }
+
+ /// Merge the contents of another [`FlatConfig`] into this one.
+ ///
+ /// Conflicting keys will be overridden by the value in the other group.
+ pub fn merge_from(&mut self, other: FlatConfig) {
+ for (key, val) in other.inner {
+ if val.is_none() {
+ continue;
+ }
+
+ self.inner.insert(key.to_string(), val);
+ }
+ }
+
+ /// Fill the group with the values for the curated lint group.
+ pub fn fill_with_curated(&mut self) {
+ let mut temp = Self::new_curated();
+ mem::swap(self, &mut temp);
+ self.merge_from(temp);
+ }
+
+ pub fn new_curated() -> Self {
+ Self::curated()
+ }
+}
+
+impl Hash for FlatConfig {
+ fn hash<H: Hasher>(&self, hasher: &mut H) {
+ for (key, value) in &self.inner {
+ hasher.write(key.as_bytes());
+ if let Some(value) = value {
+ hasher.write_u8(1);
+ hasher.write_u8(*value as u8);
+ } else {
+ // Do it twice so we fill the same number of bytes as the other branch.
+ hasher.write_u8(0);
+ hasher.write_u8(0);
+ }
+ }
+ }
+}
diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group/mod.rs
similarity index 90%
rename from harper-core/src/linting/lint_group.rs
rename to harper-core/src/linting/lint_group/mod.rs
index f8efb0a38..7ce52c709 100644
--- a/harper-core/src/linting/lint_group.rs
+++ b/harper-core/src/linting/lint_group/mod.rs
@@ -1,15 +1,14 @@
+mod flat_config;
+mod structured_config;
+
use std::collections::BTreeMap;
-use std::hash::Hash;
-use std::hash::{BuildHasher, Hasher};
-use std::mem;
+use std::hash::BuildHasher;
use std::num::NonZero;
use std::sync::Arc;
-use cached::proc_macro::cached;
use foldhash::quality::RandomState;
use hashbrown::HashMap;
use lru::LruCache;
-use serde::{Deserialize, Deserializer, Serialize, Serializer};
use super::a_part::APart;
use super::a_while::AWhile;
@@ -263,121 +262,18 @@ use crate::linting::open_compounds::OpenCompounds;
use crate::linting::{
be_adjective_confusions, closed_compounds, initialisms, phrase_set_corrections, weir_rules,
};
-use crate::spell::{Dictionary, MutableDictionary};
+use crate::spell::Dictionary;
use crate::{Dialect, Document, Lrc, TokenStringExt};
-fn ser_ordered<S>(map: &HashMap<String, Option<bool>>, ser: S) -> Result<S::Ok, S::Error>
-where
- S: Serializer,
-{
- let ordered: BTreeMap<_, _> = map.iter().map(|(k, v)| (k.clone(), *v)).collect();
- ordered.serialize(ser)
-}
-
-fn de_hashbrown<'de, D>(de: D) -> Result<HashMap<String, Option<bool>>, D::Error>
-where
- D: Deserializer<'de>,
-{
- let ordered: BTreeMap<String, Option<bool>> = BTreeMap::deserialize(de)?;
- Ok(ordered.into_iter().collect())
-}
-
-/// The configuration for a [`LintGroup`].
-/// Each child linter can be enabled, disabled, or set to a curated value.
-#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq, Eq)]
-#[serde(transparent)]
-pub struct LintGroupConfig {
- /// We do this shenanigans with the [`BTreeMap`] to keep the serialized format consistent.
- #[serde(serialize_with = "ser_ordered", deserialize_with = "de_hashbrown")]
- inner: HashMap<String, Option<bool>>,
-}
-
-#[cached]
-fn curated_config() -> LintGroupConfig {
- // The Dictionary and Dialect do not matter, we're just after the config.
- let group = LintGroup::new_curated(MutableDictionary::new().into(), Dialect::American);
- group.config
-}
-
-impl LintGroupConfig {
- /// Check if a rule exists in the configuration.
- pub fn has_rule(&self, key: impl AsRef<str>) -> bool {
- self.inner.contains_key(key.as_ref())
- }
-
- pub fn set_rule_enabled(&mut self, key: impl ToString, val: bool) {
- self.inner.insert(key.to_string(), Some(val));
- }
-
- /// Remove any configuration attached to a rule.
- /// This allows it to assume its default (curated) state.
- pub fn unset_rule_enabled(&mut self, key: impl AsRef<str>) {
- self.inner.remove(key.as_ref());
- }
-
- pub fn set_rule_enabled_if_unset(&mut self, key: impl AsRef<str>, val: bool) {
- if !self.inner.contains_key(key.as_ref()) {
- self.set_rule_enabled(key.as_ref().to_string(), val);
- }
- }
-
- pub fn is_rule_enabled(&self, key: &str) -> bool {
- self.inner.get(key).cloned().flatten().unwrap_or(false)
- }
-
- /// Clear all config options.
- /// This will reset them all to disable them.
- pub fn clear(&mut self) {
- for val in self.inner.values_mut() {
- *val = None
- }
- }
-
- /// Merge the contents of another [`LintGroupConfig`] into this one.
- ///
- /// Conflicting keys will be overridden by the value in the other group.
- pub fn merge_from(&mut self, other: LintGroupConfig) {
- for (key, val) in other.inner {
- if val.is_none() {
- continue;
- }
-
- self.inner.insert(key.to_string(), val);
- }
- }
-
- /// Fill the group with the values for the curated lint group.
- pub fn fill_with_curated(&mut self) {
- let mut temp = Self::new_curated();
- mem::swap(self, &mut temp);
- self.merge_from(temp);
- }
-
- pub fn new_curated() -> Self {
- curated_config()
- }
-}
-
-impl Hash for LintGroupConfig {
- fn hash<H: Hasher>(&self, hasher: &mut H) {
- for (key, value) in &self.inner {
- hasher.write(key.as_bytes());
- if let Some(value) = value {
- hasher.write_u8(1);
- hasher.write_u8(*value as u8);
- } else {
- // Do it twice so we fill the same number of bytes as the other branch.
- hasher.write_u8(0);
- hasher.write_u8(0);
- }
- }
- }
-}
+pub use flat_config::FlatConfig;
+pub use structured_config::{
+ HumanReadableSetting, HumanReadableStructuredConfig, StructuredConfig,
+};
/// A struct for collecting the output of a number of individual [Linter]s.
/// Each child can be toggled via the public, mutable `Self::config` object.
pub struct LintGroup {
- pub config: LintGroupConfig,
+ pub config: FlatConfig,
/// We use a binary map here so the ordering is stable.
linters: BTreeMap<String, Box<dyn Linter>>,
/// We use a binary map here so the ordering is stable.
@@ -399,7 +295,7 @@ impl LintGroup {
pub fn empty() -> Self {
Self {
- config: LintGroupConfig::default(),
+ config: FlatConfig::default(),
linters: BTreeMap::new(),
chunk_expr_linters: BTreeMap::new(),
chunk_expr_cache: LruCache::new(NonZero::new(1000).unwrap()),
@@ -530,8 +426,8 @@ impl LintGroup {
.collect()
}
- /// Swap out [`Self::config`] with another [`LintGroupConfig`].
- pub fn with_lint_config(mut self, config: LintGroupConfig) -> Self {
+ /// Swap out [`Self::config`] with another [`FlatConfig`].
+ pub fn with_lint_config(mut self, config: FlatConfig) -> Self {
self.config = config;
self
}
@@ -969,7 +865,7 @@ impl Linter for LintGroup {
mod tests {
use std::sync::Arc;
- use super::{LintGroup, LintGroupConfig};
+ use super::{FlatConfig, LintGroup};
use crate::linting::LintKind;
use crate::linting::tests::assert_no_lints;
use crate::spell::{FstDictionary, MutableDictionary};
@@ -1039,7 +935,7 @@ mod tests {
fn lint_descriptions_are_clean() {
let lints_to_check = LintGroup::new_curated(FstDictionary::curated(), Dialect::American);
- let enforcer_config = LintGroupConfig::new_curated();
+ let enforcer_config = FlatConfig::new_curated();
let mut lints_to_enforce =
LintGroup::new_curated(FstDictionary::curated(), Dialect::American)
.with_lint_config(enforcer_config);
diff --git a/harper-core/src/linting/lint_group/structured_config/human_readable_structured_config.rs b/harper-core/src/linting/lint_group/structured_config/human_readable_structured_config.rs
new file mode 100644
index 000000000..3f18a9527
--- /dev/null
+++ b/harper-core/src/linting/lint_group/structured_config/human_readable_structured_config.rs
@@ -0,0 +1,400 @@
+use serde::{Deserialize, Serialize};
+
+use super::{Setting, StructuredConfig};
+
+/// A human-readable mirror of [`super::StructuredConfig`].
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct HumanReadableStructuredConfig {
+ pub settings: Vec<HumanReadableSetting>,
+}
+
+impl HumanReadableStructuredConfig {
+ /// Validate that the structure of the settings is valid.
+ /// Returns `true` if it is valid and `false` otherwise.
+ pub fn validate(&self) -> bool {
+ self.settings.iter().all(|setting| setting.validate())
+ }
+
+ /// Convert this human-readable structure into a runtime [`StructuredConfig`].
+ ///
+ /// Human-facing metadata is preserved where the runtime structure supports it.
+ pub fn to_structured_config(&self) -> Option<StructuredConfig> {
+ if !self.validate() {
+ return None;
+ }
+
+ Some(StructuredConfig {
+ settings: self
+ .settings
+ .iter()
+ .map(HumanReadableSetting::to_setting)
+ .collect::<Option<_>>()?,
+ })
+ }
+
+ /// Build a human-readable structure from a runtime [`StructuredConfig`].
+ pub fn from_structured_config(config: &StructuredConfig) -> Self {
+ Self {
+ settings: config
+ .settings
+ .iter()
+ .map(HumanReadableSetting::from_setting)
+ .collect(),
+ }
+ }
+}
+
+/// A human-readable mirror of [`super::Setting`].
+#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub enum HumanReadableSetting {
+ Bool {
+ name: String,
+ state: bool,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ label: Option<String>,
+ },
+ /// Selects one of many rules.
+ OneOfMany {
+ /// The names of the linters we can select from.
+ names: Vec<String>,
+ /// The selected linter name, if any.
+ name: Option<String>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ labels: Option<Vec<String>>,
+ },
+ Group {
+ label: Option<String>,
+ description: String,
+ child: HumanReadableStructuredConfig,
+ },
+}
+
+impl HumanReadableSetting {
+ /// Validate that the internal structure of the enum is valid.
+ /// Returns `true` if it is valid and `false` otherwise.
+ pub fn validate(&self) -> bool {
+ match self {
+ Self::Bool { .. } => true,
+ Self::OneOfMany {
+ names,
+ name,
+ labels,
+ ..
+ } => {
+ labels
+ .as_ref()
+ .is_none_or(|labels| labels.len() == names.len())
+ && name
+ .as_ref()
+ .is_none_or(|selected| names.iter().any(|name| name == selected))
+ }
+ Self::Group { child, .. } => child.validate(),
+ }
+ }
+
+ fn to_setting(&self) -> Option<Setting> {
+ match self {
+ Self::Bool { name, state, .. } => Some(Setting::Bool {
+ name: name.clone(),
+ state: *state,
+ }),
+ Self::OneOfMany {
+ names,
+ name,
+ labels,
+ ..
+ } => {
+ let choice = match name {
+ Some(selected) => Some(names.iter().position(|name| name == selected)?),
+ None => None,
+ };
+
+ Some(Setting::OneOfMany {
+ names: names.clone(),
+ labels: labels.clone().unwrap_or_else(|| names.clone()),
+ choice,
+ })
+ }
+ Self::Group {
+ label,
+ description,
+ child,
+ } => Some(Setting::Group {
+ label: label.clone().unwrap_or_default(),
+ description: description.clone(),
+ child: child.to_structured_config()?,
+ }),
+ }
+ }
+
+ fn from_setting(setting: &Setting) -> Self {
+ match setting {
+ Setting::Bool { name, state } => Self::Bool {
+ name: name.clone(),
+ state: *state,
+ label: None,
+ },
+ Setting::OneOfMany {
+ names,
+ labels,
+ choice,
+ } => Self::OneOfMany {
+ names: names.clone(),
+ name: choice.map(|choice| names[choice].clone()),
+ labels: (labels != names).then(|| labels.clone()),
+ },
+ Setting::Group {
+ label,
+ description,
+ child,
+ } => Self::Group {
+ label: Some(label.clone()),
+ description: description.clone(),
+ child: HumanReadableStructuredConfig::from_structured_config(child),
+ },
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::{HumanReadableSetting, HumanReadableStructuredConfig};
+ use crate::linting::FlatConfig;
+ use crate::linting::lint_group::structured_config::{Setting, StructuredConfig};
+
+ fn collect_rule_names(config: &HumanReadableStructuredConfig) -> Vec<&str> {
+ let mut out = Vec::new();
+
+ for setting in &config.settings {
+ match setting {
+ HumanReadableSetting::Bool { name, .. } => out.push(name.as_str()),
+ HumanReadableSetting::OneOfMany { names, .. } => {
+ out.extend(names.iter().map(|name| name.as_str()));
+ }
+ HumanReadableSetting::Group { child, .. } => out.extend(collect_rule_names(child)),
+ }
+ }
+
+ out
+ }
+
+ #[test]
+ fn human_readable_config_round_trips_json() {
+ let settings = HumanReadableStructuredConfig {
+ settings: vec![
+ HumanReadableSetting::Bool {
+ name: "A".to_owned(),
+ state: true,
+ label: Some("Rule A".to_owned()),
+ },
+ HumanReadableSetting::OneOfMany {
+ names: vec!["B".to_owned(), "C".to_owned()],
+ name: Some("C".to_owned()),
+ labels: Some(vec!["Rule B".to_owned(), "Rule C".to_owned()]),
+ },
+ HumanReadableSetting::Group {
+ label: Some("Group D".to_owned()),
+ description: "Description D".to_owned(),
+ child: HumanReadableStructuredConfig {
+ settings: vec![HumanReadableSetting::Bool {
+ name: "D".to_owned(),
+ state: false,
+ label: None,
+ }],
+ },
+ },
+ ],
+ };
+
+ let json = serde_json::to_string(&settings).unwrap();
+ let decoded: HumanReadableStructuredConfig = serde_json::from_str(&json).unwrap();
+
+ assert_eq!(decoded, settings);
+ }
+
+ #[test]
+ fn converts_to_structured_config() {
+ let settings = HumanReadableStructuredConfig {
+ settings: vec![
+ HumanReadableSetting::Bool {
+ name: "A".to_owned(),
+ state: true,
+ label: Some("Rule A".to_owned()),
+ },
+ HumanReadableSetting::OneOfMany {
+ names: vec!["B".to_owned(), "C".to_owned()],
+ name: Some("C".to_owned()),
+ labels: Some(vec!["Rule B".to_owned(), "Rule C".to_owned()]),
+ },
+ HumanReadableSetting::Group {
+ label: Some("Group D".to_owned()),
+ description: "Description D".to_owned(),
+ child: HumanReadableStructuredConfig {
+ settings: vec![HumanReadableSetting::Bool {
+ name: "D".to_owned(),
+ state: false,
+ label: None,
+ }],
+ },
+ },
+ ],
+ };
+
+ let structured = settings.to_structured_config().unwrap();
+
+ assert_eq!(
+ structured,
+ StructuredConfig {
+ settings: vec![
+ Setting::Bool {
+ name: "A".to_owned(),
+ state: true,
+ },
+ Setting::OneOfMany {
+ names: vec!["B".to_owned(), "C".to_owned()],
+ labels: vec!["Rule B".to_owned(), "Rule C".to_owned()],
+ choice: Some(1),
+ },
+ Setting::Group {
+ label: "Group D".to_owned(),
+ description: "Description D".to_owned(),
+ child: StructuredConfig {
+ settings: vec![Setting::Bool {
+ name: "D".to_owned(),
+ state: false,
+ }],
+ },
+ },
+ ],
+ }
+ );
+ }
+
+ #[test]
+ fn converts_from_structured_config() {
+ let structured = StructuredConfig {
+ settings: vec![
+ Setting::Bool {
+ name: "A".to_owned(),
+ state: true,
+ },
+ Setting::OneOfMany {
+ names: vec!["B".to_owned(), "C".to_owned()],
+ labels: vec!["Rule B".to_owned(), "Rule C".to_owned()],
+ choice: Some(1),
+ },
+ Setting::Group {
+ label: "Group D".to_owned(),
+ description: "Description D".to_owned(),
+ child: StructuredConfig {
+ settings: vec![Setting::Bool {
+ name: "D".to_owned(),
+ state: false,
+ }],
+ },
+ },
+ ],
+ };
+
+ let human = HumanReadableStructuredConfig::from_structured_config(&structured);
+
+ assert_eq!(
+ human,
+ HumanReadableStructuredConfig {
+ settings: vec![
+ HumanReadableSetting::Bool {
+ name: "A".to_owned(),
+ state: true,
+ label: None,
+ },
+ HumanReadableSetting::OneOfMany {
+ names: vec!["B".to_owned(), "C".to_owned()],
+ name: Some("C".to_owned()),
+ labels: Some(vec!["Rule B".to_owned(), "Rule C".to_owned()]),
+ },
+ HumanReadableSetting::Group {
+ label: Some("Group D".to_owned()),
+ description: "Description D".to_owned(),
+ child: HumanReadableStructuredConfig {
+ settings: vec![HumanReadableSetting::Bool {
+ name: "D".to_owned(),
+ state: false,
+ label: None,
+ }],
+ },
+ },
+ ],
+ }
+ );
+ }
+
+ #[test]
+ fn rejects_invalid_one_of_many_selection() {
+ let settings = HumanReadableStructuredConfig {
+ settings: vec![HumanReadableSetting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned()],
+ name: Some("C".to_owned()),
+ labels: None,
+ }],
+ };
+
+ assert!(!settings.validate());
+ assert!(settings.to_structured_config().is_none());
+ }
+
+ #[test]
+ fn rejects_invalid_one_of_many_labels() {
+ let settings = HumanReadableStructuredConfig {
+ settings: vec![HumanReadableSetting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned()],
+ name: Some("B".to_owned()),
+ labels: Some(vec!["Only one".to_owned()]),
+ }],
+ };
+
+ assert!(!settings.validate());
+ assert!(settings.to_structured_config().is_none());
+ }
+
+ #[test]
+ fn uses_rule_names_as_labels_when_none_are_provided() {
+ let settings = HumanReadableStructuredConfig {
+ settings: vec![HumanReadableSetting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned()],
+ name: Some("B".to_owned()),
+ labels: None,
+ }],
+ };
+
+ assert_eq!(
+ settings.to_structured_config().unwrap(),
+ StructuredConfig {
+ settings: vec![Setting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned()],
+ labels: vec!["A".to_owned(), "B".to_owned()],
+ choice: Some(1),
+ }],
+ }
+ );
+ }
+
+ #[test]
+ fn default_config_matches_curated_flat_config() {
+ let settings = StructuredConfig::curated();
+ let actual = settings.to_flat_config().unwrap();
+ let curated = FlatConfig::new_curated();
+
+ assert!(settings.validate());
+
+ let human = HumanReadableStructuredConfig::from_structured_config(&settings);
+ let rule_names = collect_rule_names(&human);
+
+ for rule_name in rule_names {
+ assert_eq!(
+ actual.is_rule_enabled(rule_name),
+ curated.is_rule_enabled(rule_name),
+ "mismatch for rule {rule_name}"
+ );
+ }
+ }
+}
diff --git a/harper-core/src/linting/lint_group/structured_config/mod.rs b/harper-core/src/linting/lint_group/structured_config/mod.rs
new file mode 100644
index 000000000..fde274e16
--- /dev/null
+++ b/harper-core/src/linting/lint_group/structured_config/mod.rs
@@ -0,0 +1,286 @@
+mod human_readable_structured_config;
+
+use super::FlatConfig;
+use serde_json;
+
+pub use human_readable_structured_config::{HumanReadableSetting, HumanReadableStructuredConfig};
+
+/// A structure for defining which rules to be enabled or disabled in a
+/// [`LintGroup`](super::LintGroup).
+///
+/// So named because it represents a more structured view for organizing rules.
+/// Designed to be something that can be converted _into_ a [`FlatConfig`] at runtime before
+/// being passed to an actual [`LintGroup`](super::LintGroup`)
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct StructuredConfig {
+ pub settings: Vec<Setting>,
+}
+
+impl StructuredConfig {
+ /// Build the curated structured config, including labels.
+ pub fn curated() -> Self {
+ let human: HumanReadableStructuredConfig = serde_json::from_str(include_str!(concat!(
+ env!("CARGO_MANIFEST_DIR"),
+ "/default_config.json"
+ )))
+ .unwrap();
+
+ human.to_structured_config().unwrap()
+ }
+
+ /// Validate that the structure of the settings is valid.
+ /// Returns `true` if it is valid and `false` otherwise.
+ pub fn validate(&self) -> bool {
+ self.settings.iter().all(|s| s.validate())
+ }
+
+ /// Creates a [`FlatConfig`] that represents these settings.
+ /// Will return `None` if `self` is invalid.
+ pub fn to_flat_config(&self) -> Option<FlatConfig> {
+ if !self.validate() {
+ return None;
+ }
+
+ let mut config = FlatConfig::default();
+
+ for setting in &self.settings {
+ match setting {
+ Setting::Bool { name, state } => config.set_rule_enabled(name, *state),
+ Setting::OneOfMany { names, choice, .. } => {
+ if let Some(choice) = choice {
+ config.set_rule_enabled(&names[*choice], true);
+ }
+ }
+ Setting::Group { child, .. } => {
+ let flat = child.to_flat_config()?;
+ config.merge_from(flat);
+ }
+ }
+ }
+
+ Some(config)
+ }
+
+ /// Fills in the relevant values from a [`FlatConfig`] according to the relevant `name`
+ /// fields.
+ pub fn copy_from_flat_config(&mut self, config: &FlatConfig) {
+ for setting in self.settings.iter_mut() {
+ match setting {
+ Setting::Bool { name, state } => *state = config.is_rule_enabled(name),
+ Setting::OneOfMany { names, choice, .. } => {
+ *choice = names.iter().position(|n| config.is_rule_enabled(n))
+ }
+ Setting::Group { child, .. } => child.copy_from_flat_config(config),
+ }
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum Setting {
+ Bool {
+ name: String,
+ state: bool,
+ },
+ /// Selects one of many rules.
+ /// Think of it as a dropdown field, where you can select one or no of several options.
+ /// The labels are separate from the rule names, for readability.
+ OneOfMany {
+ /// The names of the linters we can select from.
+ names: Vec<String>,
+ labels: Vec<String>,
+ choice: Option<usize>,
+ },
+ Group {
+ label: String,
+ description: String,
+ child: StructuredConfig,
+ },
+}
+
+impl Setting {
+ /// Validate that the internal structure of the enum is valid.
+ /// Returns `true` if it is valid and `false` otherwise.
+ pub fn validate(&self) -> bool {
+ match self {
+ Setting::Bool { .. } => true,
+ Setting::OneOfMany {
+ names,
+ labels,
+ choice,
+ } => labels.len() == names.len() && choice.is_none_or(|v| v < names.len()),
+ Setting::Group { child, .. } => child.validate(),
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::linting::FlatConfig;
+
+ use super::{Setting, StructuredConfig};
+
+ #[test]
+ fn validates_bool_true() {
+ assert!(
+ Setting::Bool {
+ name: "A".to_owned(),
+ state: true,
+ }
+ .validate()
+ )
+ }
+
+ #[test]
+ fn validates_bool_false() {
+ assert!(
+ Setting::Bool {
+ name: "A".to_owned(),
+ state: false,
+ }
+ .validate()
+ )
+ }
+
+ #[test]
+ fn validates_valid_one_of_many_some() {
+ assert!(
+ Setting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned()],
+ labels: vec!["C".to_owned(), "D".to_owned()],
+ choice: Some(1)
+ }
+ .validate()
+ )
+ }
+
+ #[test]
+ fn validates_valid_one_of_many_none() {
+ assert!(
+ Setting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned()],
+ labels: vec!["C".to_owned(), "D".to_owned()],
+ choice: None
+ }
+ .validate()
+ )
+ }
+
+ #[test]
+ fn validates_invalid_one_of_many_some_too_large() {
+ assert!(
+ !Setting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned()],
+ labels: vec!["C".to_owned(), "D".to_owned()],
+ choice: Some(2)
+ }
+ .validate()
+ )
+ }
+
+ #[test]
+ fn validates_invalid_one_of_many_inconsistent_len() {
+ assert!(
+ !Setting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned()],
+ labels: vec!["C".to_owned(), "D".to_owned(), "E".to_owned()],
+ choice: None
+ }
+ .validate()
+ )
+ }
+
+ #[test]
+ fn converts_only_bools() {
+ let settings = StructuredConfig {
+ settings: vec![
+ Setting::Bool {
+ name: "A".to_owned(),
+ state: false,
+ },
+ Setting::Bool {
+ name: "B".to_owned(),
+ state: true,
+ },
+ Setting::Bool {
+ name: "C".to_owned(),
+ state: false,
+ },
+ ],
+ };
+
+ let config = settings.to_flat_config().unwrap();
+
+ assert!(!config.is_rule_enabled("A"));
+ assert!(config.is_rule_enabled("B"));
+ assert!(!config.is_rule_enabled("C"));
+ }
+
+ #[test]
+ fn converts_only_one_of_many() {
+ let settings = StructuredConfig {
+ settings: vec![Setting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned(), "C".to_owned()],
+ labels: vec!["A".to_owned(), "B".to_owned(), "C".to_owned()],
+ choice: Some(2),
+ }],
+ };
+
+ let config = settings.to_flat_config().unwrap();
+
+ assert!(!config.is_rule_enabled("A"));
+ assert!(!config.is_rule_enabled("B"));
+ assert!(config.is_rule_enabled("C"));
+ }
+
+ #[test]
+ fn can_pull_simple_config_from_flat_config() {
+ let mut settings = StructuredConfig {
+ settings: vec![Setting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned(), "C".to_owned()],
+ labels: vec!["A".to_owned(), "B".to_owned(), "C".to_owned()],
+ choice: None,
+ }],
+ };
+
+ let mut lgc = FlatConfig::default();
+ lgc.set_rule_enabled("A", false);
+ lgc.set_rule_enabled("B", false);
+ lgc.set_rule_enabled("C", true);
+
+ settings.copy_from_flat_config(&lgc);
+
+ assert_eq!(
+ settings,
+ StructuredConfig {
+ settings: vec![Setting::OneOfMany {
+ names: vec!["A".to_owned(), "B".to_owned(), "C".to_owned()],
+ labels: vec!["A".to_owned(), "B".to_owned(), "C".to_owned()],
+ choice: Some(2),
+ }],
+ }
+ )
+ }
+
+ #[test]
+ fn validates_group_with_label() {
+ assert!(
+ Setting::Group {
+ label: "Group".to_owned(),
+ description: "Description".to_owned(),
+ child: StructuredConfig {
+ settings: vec![Setting::Bool {
+ name: "A".to_owned(),
+ state: true,
+ }],
+ },
+ }
+ .validate()
+ );
+ }
+
+ #[test]
+ fn curated_is_valid() {
+ assert!(StructuredConfig::curated().validate());
+ }
+}
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index 83c20a6ba..33850602d 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -269,7 +269,9 @@ mod wrong_apostrophe;
pub use expr_linter::{Chunk, ExprLinter};
pub use initialism_linter::InitialismLinter;
pub use lint::Lint;
-pub use lint_group::{LintGroup, LintGroupConfig};
+pub use lint_group::{
+ FlatConfig, HumanReadableSetting, HumanReadableStructuredConfig, LintGroup, StructuredConfig,
+};
pub use lint_kind::LintKind;
pub use map_phrase_linter::MapPhraseLinter;
pub use map_phrase_set_linter::MapPhraseSetLinter;
diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs
index 7156f661c..ea91f0ffe 100644
--- a/harper-ls/src/backend.rs
+++ b/harper-ls/src/backend.rs
@@ -14,7 +14,7 @@ use anyhow::{Context, Result, anyhow};
use futures::future::join;
use harper_asciidoc::AsciidocParser;
use harper_comments::CommentParser;
-use harper_core::linting::{LintGroup, LintGroupConfig};
+use harper_core::linting::{FlatConfig, LintGroup};
use harper_core::parsers::{
CollapseIdentifiers, IsolateEnglish, Markdown, OrgMode, Parser, PlainEnglish,
};
@@ -316,7 +316,7 @@ impl Backend {
parser: impl Parser + 'static,
uri: &'a Uri,
doc_state: &'a mut DocumentState,
- lint_config: &LintGroupConfig,
+ lint_config: &FlatConfig,
dialect: Dialect,
) -> Result<Box<dyn Parser>> {
if doc_state.ident_dict != new_dict {
diff --git a/harper-ls/src/config.rs b/harper-ls/src/config.rs
index 7fd4db942..a55f849ad 100644
--- a/harper-ls/src/config.rs
+++ b/harper-ls/src/config.rs
@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
use anyhow::{Result, bail};
use dirs::{config_dir, data_local_dir};
use globset::{Glob, GlobSet};
-use harper_core::{Dialect, linting::LintGroupConfig, parsers::MarkdownOptions};
+use harper_core::{Dialect, linting::FlatConfig, parsers::MarkdownOptions};
use resolve_path::PathResolveExt;
use serde::{Deserialize, Serialize};
use serde_json::Value;
@@ -69,7 +69,7 @@ pub struct Config {
pub workspace_dict_path: PathBuf,
pub ignored_lints_path: PathBuf,
pub stats_path: PathBuf,
- pub lint_config: LintGroupConfig,
+ pub lint_config: FlatConfig,
pub diagnostic_severity: DiagnosticSeverity,
pub code_action_config: CodeActionConfig,
pub isolate_english: bool,
@@ -218,7 +218,7 @@ impl Default for Config {
workspace_dict_path: ".harper-dictionary.txt".into(),
ignored_lints_path: data_local_dir().unwrap().join("harper-ls/ignored_lints/"),
stats_path: data_local_dir().unwrap().join("harper-ls/stats.txt"),
- lint_config: LintGroupConfig::default(),
+ lint_config: FlatConfig::default(),
diagnostic_severity: DiagnosticSeverity::Hint,
code_action_config: CodeActionConfig::default(),
isolate_english: false,
diff --git a/harper-stats/src/record.rs b/harper-stats/src/record.rs
index 15b458b83..b66d9319f 100644
--- a/harper-stats/src/record.rs
+++ b/harper-stats/src/record.rs
@@ -1,5 +1,5 @@
use harper_core::{
- linting::{Lint, LintGroupConfig, LintKind},
+ linting::{FlatConfig, Lint, LintKind},
Document, FatStringToken,
};
use serde::{Deserialize, Serialize};
@@ -30,7 +30,7 @@ pub enum RecordKind {
kind: LintKind,
context: Vec<FatStringToken>,
},
- LintConfigUpdate(LintGroupConfig),
+ LintConfigUpdate(FlatConfig),
}
impl RecordKind {
diff --git a/harper-stats/src/summary.rs b/harper-stats/src/summary.rs
index dcfa51b1d..585aed0bc 100644
--- a/harper-stats/src/summary.rs
+++ b/harper-stats/src/summary.rs
@@ -1,13 +1,13 @@
use std::{collections::HashMap, fmt::Display};
-use harper_core::linting::{LintGroupConfig, LintKind};
+use harper_core::linting::{FlatConfig, LintKind};
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct Summary {
pub lint_counts: HashMap<LintKind, u32>,
pub total_applied: u32,
- pub final_config: LintGroupConfig,
+ pub final_config: FlatConfig,
// The most common misspelled words.
pub misspelled: HashMap<String, u32>,
}
diff --git a/harper-wasm/src/lib.rs b/harper-wasm/src/lib.rs
index 68fd77f2d..15d6cd170 100644
--- a/harper-wasm/src/lib.rs
+++ b/harper-wasm/src/lib.rs
@@ -6,6 +6,7 @@ use std::io::Cursor;
use std::sync::Arc;
use harper_core::language_detection::is_doc_likely_english;
+use harper_core::linting::{HumanReadableStructuredConfig, StructuredConfig};
use harper_core::linting::{LintGroup, Linter as _};
use harper_core::parsers::{IsolateEnglish, Markdown, Mask, OopsAllHeadings, Parser, PlainEnglish};
use harper_core::remove_overlaps_map;
@@ -222,6 +223,14 @@ impl Linter {
serde_json::to_string(&self.lint_group.config).unwrap()
}
+ pub fn get_structured_lint_config_as_json(&self) -> String {
+ let mut config = StructuredConfig::curated();
+ config.copy_from_flat_config(&self.lint_group.config);
+
+ let human = HumanReadableStructuredConfig::from_structured_config(&config);
+ serde_json::to_string(&human).unwrap()
+ }
+
pub fn set_lint_config_from_json(&mut self, json: String) -> Result<(), String> {
self.lint_group.config = serde_json::from_str(&json).map_err(|v| v.to_string())?;
Ok(())
@@ -251,6 +260,16 @@ impl Linter {
self.lint_group.config.serialize(&serializer).unwrap()
}
+ pub fn get_structured_lint_config_as_object(&self) -> JsValue {
+ let serializer = Serializer::json_compatible();
+
+ let mut config = StructuredConfig::curated();
+ config.copy_from_flat_config(&self.lint_group.config);
+
+ let human = HumanReadableStructuredConfig::from_structured_config(&config);
+ human.serialize(&serializer).unwrap()
+ }
+
pub fn set_lint_config_from_object(&mut self, object: JsValue) -> Result<(), String> {
self.lint_group.config =
serde_wasm_bindgen::from_value(object).map_err(|v| v.to_string())?;
diff --git a/packages/chrome-plugin/src/ProtocolClient.ts b/packages/chrome-plugin/src/ProtocolClient.ts
index cce960ae2..84a89603f 100644
--- a/packages/chrome-plugin/src/ProtocolClient.ts
+++ b/packages/chrome-plugin/src/ProtocolClient.ts
@@ -1,4 +1,4 @@
-import type { Dialect, LintConfig, LintOptions } from 'harper.js';
+import type { Dialect, LintConfig, LintOptions, StructuredLintConfig } from 'harper.js';
import type { UnpackedLintGroups } from 'lint-framework';
import { LRUCache } from 'lru-cache';
import type { ActivationKey, Hotkey, WeirpackMeta } from './protocol';
@@ -33,6 +33,10 @@ export default class ProtocolClient {
return (await chrome.runtime.sendMessage({ kind: 'getConfig' })).config;
}
+ public static async getStructuredLintConfig(): Promise<StructuredLintConfig> {
+ return (await chrome.runtime.sendMessage({ kind: 'getStructuredConfig' })).config;
+ }
+
public static async setLintConfig(lintConfig: LintConfig): Promise<void> {
this.lintCache.clear();
await chrome.runtime.sendMessage({ kind: 'setConfig', config: lintConfig });
diff --git a/packages/chrome-plugin/src/background/index.ts b/packages/chrome-plugin/src/background/index.ts
index 209901531..3792011ec 100644
--- a/packages/chrome-plugin/src/background/index.ts
+++ b/packages/chrome-plugin/src/background/index.ts
@@ -28,6 +28,7 @@ import {
type GetLintDescriptionsResponse,
type GetReviewedRequest,
type GetReviewedResponse,
+ type GetStructuredConfigResponse,
type GetUserDictionaryResponse,
type GetWeirpacksResponse,
type Hotkey,
@@ -71,11 +72,16 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
let linter: LocalLinter;
const WEIRPACKS_KEY = 'weirpacks';
-getDialect()
+const linterReady = getDialect()
.then(setDialect)
.catch((err) => console.error('Failed to initialize linter:', err));
setInstalledOnIfMissing();
+/** Await this function to "wait" for the linter to boot up. */
+async function ensureLinterReady() {
+ await linterReady;
+}
+
async function enableDefaultDomains() {
const defaultEnabledDomains = [
'old.reddit.com',
@@ -149,6 +155,8 @@ function handleRequest(message: Request, sender?: chrome.runtime.MessageSender):
return handleLint(message, sender);
case 'getConfig':
return handleGetConfig(message);
+ case 'getStructuredConfig':
+ return handleGetStructuredConfig();
case 'setConfig':
return handleSetConfig(message);
case 'getLintDescriptions':
@@ -210,6 +218,8 @@ async function handleLint(
req: LintRequest,
sender?: chrome.runtime.MessageSender,
): Promise<LintResponse> {
+ await ensureLinterReady();
+
// Keep the content-script keepalive ping cheap; empty requests should not hit inheritance or linting.
if (req.text.length === 0) {
return { kind: 'lints', lints: {} };
@@ -264,10 +274,20 @@ function getParentDomain(sender?: chrome.runtime.MessageSender): string | null {
}
async function handleGetConfig(_req: GetConfigRequest): Promise<GetConfigResponse> {
+ await ensureLinterReady();
return { kind: 'getConfig', config: await getLintConfig() };
}
+async function handleGetStructuredConfig(): Promise<GetStructuredConfigResponse> {
+ await ensureLinterReady();
+ return {
+ kind: 'getStructuredConfig',
+ config: JSON.parse(await linter.getStructuredLintConfigJSON()),
+ };
+}
+
async function handleSetConfig(req: SetConfigRequest): Promise<UnitResponse> {
+ await ensureLinterReady();
await setLintConfig(req.config);
return createUnitResponse();
@@ -284,6 +304,7 @@ async function handleGetDialect(_req: GetDialectRequest): Promise<GetDialectResp
}
async function handleIgnoreLint(req: IgnoreLintRequest): Promise<UnitResponse> {
+ await ensureLinterReady();
await linter.ignoreLintHash(BigInt(req.contextHash));
await setIgnoredLints(await linter.exportIgnoredLints());
@@ -333,10 +354,12 @@ async function handleSetDefaultStatus(req: SetDefaultStatusRequest): Promise<Uni
async function handleGetLintDescriptions(
_req: GetLintDescriptionsRequest,
): Promise<GetLintDescriptionsResponse> {
+ await ensureLinterReady();
return { kind: 'getLintDescriptions', descriptions: await linter.getLintDescriptionsHTML() };
}
async function handleSetUserDictionary(req: SetUserDictionaryRequest): Promise<UnitResponse> {
+ await ensureLinterReady();
await resetDictionary();
await addToDictionary(req.words);
@@ -344,6 +367,7 @@ async function handleSetUserDictionary(req: SetUserDictionaryRequest): Promise<U
}
async function handleAddToUserDictionary(req: AddToUserDictionaryRequest): Promise<UnitResponse> {
+ await ensureLinterReady();
await addToDictionary(req.words);
return createUnitResponse();
@@ -452,6 +476,7 @@ async function handleGetWeirpacks(): Promise<GetWeirpacksResponse> {
}
async function handleAddWeirpack(req: AddWeirpackRequest): Promise<UnitResponse> {
+ await ensureLinterReady();
const bytes = Uint8Array.from(req.bytes);
const failures = await linter.loadWeirpackFromBytes(bytes);
if (failures !== undefined) {
@@ -487,6 +512,7 @@ async function handleAddWeirpack(req: AddWeirpackRequest): Promise<UnitResponse>
}
async function handleRemoveWeirpack(req: RemoveWeirpackRequest): Promise<UnitResponse> {
+ await ensureLinterReady();
const current = await getStoredWeirpacks();
const next = current.filter((item) => item.id !== req.id);
await setStoredWeirpacks(next);
@@ -556,7 +582,7 @@ async function setHotkey(hotkey: Hotkey) {
await chrome.storage.local.set({ hotkey: hotkey });
}
-function initializeLinter(dialect: Dialect) {
+async function initializeLinter(dialect: Dialect) {
if (linter != null) {
linter.dispose();
}
@@ -566,16 +592,19 @@ function initializeLinter(dialect: Dialect) {
dialect,
});
- getIgnoredLints().then((i) => linter.importIgnoredLints(i));
- getUserDictionary().then((u) => linter.importWords(u));
- getLintConfig().then((c) => linter.setLintConfig(c));
- loadStoredWeirpacksIntoLinter();
- linter.setup();
+ await Promise.all([
+ getIgnoredLints().then((i) => linter.importIgnoredLints(i)),
+ getUserDictionary().then((u) => linter.importWords(u)),
+ getLintConfig().then((c) => linter.setLintConfig(c)),
+ loadStoredWeirpacksIntoLinter(),
+ ]);
+
+ await linter.setup();
}
async function setDialect(dialect: Dialect) {
await chrome.storage.local.set({ dialect });
- initializeLinter(dialect);
+ await initializeLinter(dialect);
}
/** Format the key to be used in local storage to store domain status. */
diff --git a/packages/chrome-plugin/src/options/Options.svelte b/packages/chrome-plugin/src/options/Options.svelte
index 2e2eb5dfe..d3bffb23e 100644
--- a/packages/chrome-plugin/src/options/Options.svelte
+++ b/packages/chrome-plugin/src/options/Options.svelte
@@ -1,15 +1,23 @@
<script lang="ts">
import { Button, Card, Input, Select, Textarea } from 'components';
-import { Dialect, type LintConfig } from 'harper.js';
+import {
+ Dialect,
+ type LintConfig,
+ type StructuredLintConfig,
+ type StructuredLintSetting,
+} from 'harper.js';
import logo from '/logo.png';
import ProtocolClient from '../ProtocolClient';
import type { Hotkey, Modifier, WeirpackMeta } from '../protocol';
import { ActivationKey } from '../protocol';
+import StructuredRuleSettings from './StructuredRuleSettings.svelte';
let lintConfig: LintConfig = $state({});
+let structuredLintConfig: StructuredLintConfig = $state({ settings: [] });
let lintDescriptions: Record<string, string> = $state({});
let searchQuery = $state('');
let searchQueryLower = $derived(searchQuery.toLowerCase());
+let expandedGroups: Record<string, boolean> = $state({});
let dialect = $state(Dialect.American);
let defaultEnabled = $state(false);
let activationKey: ActivationKey = $state(ActivationKey.Off);
@@ -41,12 +49,14 @@ $effect(() => {
ProtocolClient.setUserDictionary(stringToDict(userDict));
});
-ProtocolClient.getLintConfig().then((l) => {
- lintConfig = l;
-});
-
-ProtocolClient.getLintDescriptions().then((d) => {
- lintDescriptions = d;
+Promise.all([
+ ProtocolClient.getLintConfig(),
+ ProtocolClient.getStructuredLintConfig(),
+ ProtocolClient.getLintDescriptions(),
+]).then(([nextLintConfig, nextStructuredConfig, nextLintDescriptions]) => {
+ lintConfig = nextLintConfig;
+ structuredLintConfig = nextStructuredConfig;
+ lintDescriptions = nextLintDescriptions;
});
ProtocolClient.getDialect().then((d) => {
@@ -62,7 +72,6 @@ ProtocolClient.getActivationKey().then((d) => {
});
ProtocolClient.getHotkey().then((d) => {
- // Ensure we have a plain object, not a Proxy
hotkey = {
modifiers: [...d.modifiers],
key: d.key,
@@ -78,31 +87,6 @@ ProtocolClient.getWeirpacks().then((stored) => {
weirpacks = stored.toSorted((a, b) => b.installedAt.localeCompare(a.installedAt));
});
-function configValueToString(value: boolean | undefined): string {
- switch (value) {
- case true:
- return 'enable';
- case false:
- return 'disable';
- case undefined:
- case null:
- return 'default';
- }
-}
-
-function configStringToValue(str: string): boolean | undefined | null {
- switch (str) {
- case 'enable':
- return true;
- case 'disable':
- return false;
- case 'default':
- return null;
- }
-
- throw 'Fell through case';
-}
-
/** Converts the content of a text area to viable dictionary values. */
export function stringToDict(s: string): string[] {
return s
@@ -144,6 +128,79 @@ function toggleAllRules(): void {
updateAllRules(!anyRulesEnabled);
}
+function collectStructuredRuleNames(settings: StructuredLintSetting[]): string[] {
+ const out: string[] = [];
+
+ for (const setting of settings) {
+ if ('Bool' in setting) {
+ out.push(setting.Bool.name);
+ continue;
+ }
+
+ if ('OneOfMany' in setting) {
+ out.push(...setting.OneOfMany.names);
+ continue;
+ }
+
+ out.push(...collectStructuredRuleNames(setting.Group.child.settings));
+ }
+
+ return out;
+}
+
+function buildDisplaySettings(
+ structured: StructuredLintConfig,
+ flat: LintConfig,
+): StructuredLintSetting[] {
+ const settings = [...(structured.settings ?? [])];
+ const knownRules = new Set(collectStructuredRuleNames(settings));
+ const extraRuleNames = Object.keys(flat)
+ .filter((name) => !knownRules.has(name))
+ .sort();
+
+ if (extraRuleNames.length === 0) {
+ return settings;
+ }
+
+ settings.push({
+ Group: {
+ label: 'Additional Rules',
+ description: 'Rules present in the flat config but not yet assigned to a curated category.',
+ child: {
+ settings: extraRuleNames.map(
+ (name) =>
+ ({
+ Bool: {
+ name,
+ state: flat[name] ?? false,
+ label: name,
+ },
+ }) as StructuredLintSetting,
+ ),
+ },
+ },
+ });
+
+ return settings;
+}
+
+let displayStructuredSettings: StructuredLintSetting[] = $state([]);
+
+$effect(() => {
+ displayStructuredSettings = buildDisplaySettings(structuredLintConfig, lintConfig);
+});
+
+function updateLintConfig(nextConfig: LintConfig) {
+ lintConfig = nextConfig;
+}
+
+function toggleGroup(groupKey: string) {
+ expandedGroups = {
+ ...expandedGroups,
+ [groupKey]: !expandedGroups[groupKey],
+ };
+}
+
async function exportEnabledDomainsCSV() {
try {
const enabledDomains = await ProtocolClient.getEnabledDomains();
@@ -418,33 +475,20 @@ async function removeWeirpack(id: string) {
</Button>
</div>
- {#each Object.entries(lintConfig).filter(
- ([key]) =>
- (lintDescriptions[key] ?? '').toLowerCase().includes(searchQueryLower) ||
- key.toLowerCase().includes(searchQueryLower)
- ) as [key, value]}
- <div class="rule-scroll space-y-4 max-h-80 overflow-y-auto pr-1">
- <!-- rule card sample -->
- <div class="flex items-start justify-between gap-4">
- <div class="space-y-0.5">
- <h3 class="text-sm">{key}</h3>
- <p class="text-xs">{@html lintDescriptions[key]}</p>
- </div>
- <Select
- size="md"
- value={configValueToString(value)}
- onchange={(e) => {
- lintConfig[key] = configStringToValue(e.target.value);
- }}
- >
- <option value="default">⚙️ Default</option>
- <option value="enable">✅ On</option>
- <option value="disable">🚫 Off</option>
- </Select>
- </div>
- </div>
- {/each}
-
- </Card>
- </div>
+ <div class="rule-scroll space-y-4 max-h-80 overflow-y-auto pr-1">
+ {#key displayStructuredSettings.length}
+ <StructuredRuleSettings
+ settings={displayStructuredSettings}
+ {lintConfig}
+ {lintDescriptions}
+ {searchQueryLower}
+ {expandedGroups}
+ handleLintConfigChange={updateLintConfig}
+ handleToggleGroup={toggleGroup}
+ />
+ {/key}
+ </div>
+
+ </Card>
+ </div>
</div>
diff --git a/packages/chrome-plugin/src/options/StructuredRuleSettings.svelte b/packages/chrome-plugin/src/options/StructuredRuleSettings.svelte
new file mode 100644
index 000000000..42c5faf1d
--- /dev/null
+++ b/packages/chrome-plugin/src/options/StructuredRuleSettings.svelte
@@ -0,0 +1,396 @@
+<script lang="ts">
+import { Select } from 'components';
+import type { LintConfig, StructuredLintSetting } from 'harper.js';
+import { startCase } from 'lodash-es';
+
+type StructuredOneOfManySetting = Extract<
+ StructuredLintSetting,
+ { OneOfMany: unknown }
+>['OneOfMany'];
+
+type RenderNode = GroupRenderNode | BoolRenderNode | OneOfManyRenderNode;
+
+type GroupRenderNode = {
+ kind: 'group';
+ label: string;
+ description: string;
+ groupKey: string;
+ indent: number;
+ ruleNames: string[];
+ ruleCount: number;
+ state: 'default' | 'enable' | 'disable' | 'mixed';
+ expanded: boolean;
+ childNodes: RenderNode[];
+};
+
+type BoolRenderNode = {
+ kind: 'bool';
+ name: string;
+ label: string;
+ description: string;
+ title: string;
+ value: string;
+ indent: number;
+};
+
+type OneOfManyRenderNode = {
+ kind: 'oneOfMany';
+ name: string;
+ title: string;
+ options: { value: string; label: string }[];
+ value: string;
+ setting: StructuredOneOfManySetting;
+ indent: number;
+};
+
+export let settings: StructuredLintSetting[] = [];
+export let nodes: RenderNode[] | undefined = undefined;
+export let lintConfig: LintConfig = {};
+export let lintDescriptions: Record<string, string> = {};
+export let searchQueryLower = '';
+export let expandedGroups: Record<string, boolean> = {};
+export let groupPath: string[] = [];
+export let indent = 0;
+export let forceShow = false;
+export let handleLintConfigChange: (next: LintConfig) => void;
+export let handleToggleGroup: (groupKey: string) => void;
+
+function configValueToString(value: boolean | undefined | null): string {
+ switch (value) {
+ case true:
+ return 'enable';
+ case false:
+ return 'disable';
+ case undefined:
+ case null:
+ return 'default';
+ }
+}
+
+function configStringToValue(str: string): boolean | undefined | null {
+ switch (str) {
+ case 'enable':
+ return true;
+ case 'disable':
+ return false;
+ case 'default':
+ return null;
+ }
+
+ throw new Error('Unexpected config value');
+}
+
+function rowStyle(indent: number): string | undefined {
+ return indent > 0 ? `padding-left: ${indent * 1.5}rem` : undefined;
+}
+
+function displayRuleLabel(ruleName: string, label?: string | null): string {
+ return label ?? startCase(ruleName);
+}
+
+function matchesRule(ruleName: string, label?: string | null, forceMatch = false): boolean {
+ if (forceMatch || searchQueryLower === '') {
+ return true;
+ }
+
+ const description = lintDescriptions[ruleName] ?? '';
+ const displayLabel = displayRuleLabel(ruleName, label);
+ return (
+ ruleName.toLowerCase().includes(searchQueryLower) ||
+ displayLabel.toLowerCase().includes(searchQueryLower) ||
+ description.toLowerCase().includes(searchQueryLower)
+ );
+}
+
+function settingVisible(setting: StructuredLintSetting, forceMatch = false): boolean {
+ if (forceMatch || searchQueryLower === '') {
+ return true;
+ }
+
+ if ('Bool' in setting) {
+ return matchesRule(setting.Bool.name, setting.Bool.label, false);
+ }
+
+ if ('OneOfMany' in setting) {
+ return (
+ (setting.OneOfMany.name?.toLowerCase().includes(searchQueryLower) ?? false) ||
+ setting.OneOfMany.names.some((name, index) =>
+ matchesRule(name, setting.OneOfMany.labels?.[index], false),
+ )
+ );
+ }
+
+ if (setting.Group.label.toLowerCase().includes(searchQueryLower)) {
+ return true;
+ }
+
+ return setting.Group.child.settings.some((child) => settingVisible(child, false));
+}
+
+function collectRuleNames(settings: StructuredLintSetting[]): string[] {
+ const out: string[] = [];
+
+ for (const setting of settings) {
+ if ('Bool' in setting) {
+ out.push(setting.Bool.name);
+ continue;
+ }
+
+ if ('OneOfMany' in setting) {
+ out.push(...setting.OneOfMany.names);
+ continue;
+ }
+
+ out.push(...collectRuleNames(setting.Group.child.settings));
+ }
+
+ return out;
+}
+
+function groupKeyFor(label: string): string {
+ return [...groupPath, label].join(' / ');
+}
+
+function groupState(ruleNames: string[]): 'default' | 'enable' | 'disable' | 'mixed' {
+ const values = ruleNames.map((name) => lintConfig[name] ?? null);
+
+ if (values.every((value) => value === null)) {
+ return 'default';
+ }
+
+ if (values.every((value) => value === true)) {
+ return 'enable';
+ }
+
+ if (values.every((value) => value === false)) {
+ return 'disable';
+ }
+
+ return 'mixed';
+}
+
+function updateGroup(ruleNames: string[], value: string) {
+ const nextConfig: LintConfig = { ...lintConfig };
+
+ for (const ruleName of ruleNames) {
+ nextConfig[ruleName] = configStringToValue(value);
+ }
+
+ handleLintConfigChange(nextConfig);
+}
+
+function oneOfManyValue(setting: StructuredOneOfManySetting): string {
+ const values = setting.names.map((name) => lintConfig[name] ?? null);
+ if (values.every((value) => value === null)) {
+ return 'default';
+ }
+
+ return setting.names.find((name) => lintConfig[name] === true) ?? 'default';
+}
+
+function updateOneOfMany(setting: StructuredOneOfManySetting, selected: string) {
+ const nextConfig: LintConfig = { ...lintConfig };
+
+ for (const name of setting.names) {
+ nextConfig[name] = selected === 'default' ? null : name === selected;
+ }
+
+ handleLintConfigChange(nextConfig);
+}
+
+function buildRenderNodes(
+ settings: StructuredLintSetting[],
+ path: string[],
+ forceMatch: boolean,
+ currentIndent: number,
+): { nodes: RenderNode[]; ruleNames: string[] } {
+ const out: RenderNode[] = [];
+ const ruleNames: string[] = [];
+
+ for (const setting of settings) {
+ if ('Bool' in setting) {
+ ruleNames.push(setting.Bool.name);
+
+ if (!matchesRule(setting.Bool.name, setting.Bool.label, forceMatch)) {
+ continue;
+ }
+
+ const label = displayRuleLabel(setting.Bool.name, setting.Bool.label);
+ out.push({
+ kind: 'bool',
+ name: setting.Bool.name,
+ label,
+ description: lintDescriptions[setting.Bool.name] ?? '',
+ title: `Set ${label} to its default, on, or off state.`,
+ value: configValueToString(lintConfig[setting.Bool.name]),
+ indent: currentIndent,
+ });
+ continue;
+ }
+
+ if ('OneOfMany' in setting) {
+ ruleNames.push(...setting.OneOfMany.names);
+
+ if (!settingVisible(setting, forceMatch)) {
+ continue;
+ }
+
+ const name = setting.OneOfMany.name ?? setting.OneOfMany.labels?.join(' / ') ?? 'Choose one';
+ out.push({
+ kind: 'oneOfMany',
+ name,
+ title: `Choose an option for ${name}.`,
+ options: [
+ { value: 'default', label: '⚙️ Default' },
+ ...setting.OneOfMany.names.map((value, index) => ({
+ value,
+ label: setting.OneOfMany.labels?.[index] ?? value,
+ })),
+ ],
+ value: oneOfManyValue(setting.OneOfMany),
+ setting: setting.OneOfMany,
+ indent: currentIndent,
+ });
+ continue;
+ }
+
+ const groupKey = [...path, setting.Group.label].join(' / ');
+ const groupMatches =
+ searchQueryLower !== '' &&
+ (setting.Group.label.toLowerCase().includes(searchQueryLower) ||
+ setting.Group.description.toLowerCase().includes(searchQueryLower));
+ const child = buildRenderNodes(
+ setting.Group.child.settings,
+ [...path, setting.Group.label],
+ forceMatch || groupMatches,
+ currentIndent + 1,
+ );
+ ruleNames.push(...child.ruleNames);
+
+ const visible = forceMatch || searchQueryLower === '' || groupMatches || child.nodes.length > 0;
+ if (!visible) {
+ continue;
+ }
+
+ out.push({
+ kind: 'group',
+ label: setting.Group.label,
+ description: setting.Group.description,
+ groupKey,
+ indent: currentIndent,
+ ruleNames: child.ruleNames,
+ ruleCount: child.ruleNames.length,
+ state: groupState(child.ruleNames),
+ expanded:
+ Boolean(expandedGroups[groupKey]) ||
+ (searchQueryLower !== '' && (groupMatches || child.nodes.length > 0)),
+ childNodes: child.nodes,
+ });
+ }
+
+ return { nodes: out, ruleNames };
+}
+
+let renderedNodes: RenderNode[] = [];
+
+$: {
+ void searchQueryLower;
+ void expandedGroups;
+ void lintConfig;
+ void lintDescriptions;
+ renderedNodes = nodes ?? buildRenderNodes(settings, groupPath, forceShow, indent).nodes;
+}
+</script>
+
+<div class="space-y-4">
+ {#each renderedNodes as node}
+ {#if node.kind === 'group'}
+ <div class="space-y-3">
+ <div class="flex items-start justify-between gap-4" style={rowStyle(node.indent)}>
+ <div class="space-y-0.5">
+ <h3 class="text-sm">{node.label}</h3>
+ <p class="text-xs text-gray-600 dark:text-gray-400">{node.description}</p>
+ <p class="text-xs text-gray-600 dark:text-gray-400">{node.ruleCount} rules</p>
+ </div>
+ <div class="flex items-center gap-2">
+ <button
+ type="button"
+ class="cursor-pointer inline-flex items-center gap-2 justify-center rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-center text-gray-900 transition-colors hover:bg-gray-100 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-700 dark:focus:ring-gray-700"
+ title={node.expanded
+ ? `Collapse the ${node.label} category`
+ : `Expand the ${node.label} category`}
+ onclick={() => handleToggleGroup(node.groupKey)}
+ >
+ {node.expanded ? 'Collapse' : 'Expand'}
+ </button>
+ <Select
+ size="md"
+ title={`Set all rules in the ${node.label} category to their default, on, or off state.`}
+ value={node.state === 'mixed' ? 'default' : node.state}
+ onchange={(event) => updateGroup(node.ruleNames, (event.target as HTMLSelectElement).value)}
+ >
+ <option value="default">{node.state === 'mixed' ? '⚙️ Default (mixed)' : '⚙️ Default'}</option>
+ <option value="enable">✅ On</option>
+ <option value="disable">🚫 Off</option>
+ </Select>
+ </div>
+ </div>
+
+ {#if node.expanded}
+ <svelte:self
+ nodes={node.childNodes}
+ settings={[]}
+ {lintConfig}
+ {lintDescriptions}
+ {searchQueryLower}
+ {expandedGroups}
+ groupPath={[]}
+ indent={indent}
+ forceShow={forceShow}
+ {handleLintConfigChange}
+ {handleToggleGroup}
+ />
+ {/if}
+ </div>
+ {:else if node.kind === 'bool'}
+ <div class="flex items-start justify-between gap-4" style={rowStyle(node.indent)}>
+ <div class="space-y-0.5">
+ <h3 class="text-sm">{node.label}</h3>
+ <p class="text-xs">{@html node.description}</p>
+ </div>
+ <Select
+ size="md"
+ title={node.title}
+ value={node.value}
+ onchange={(event) => {
+ const nextConfig: LintConfig = { ...lintConfig };
+ nextConfig[node.name] = configStringToValue(
+ (event.target as HTMLSelectElement).value,
+ );
+ handleLintConfigChange(nextConfig);
+ }}
+ >
+ <option value="default">⚙️ Default</option>
+ <option value="enable">✅ On</option>
+ <option value="disable">🚫 Off</option>
+ </Select>
+ </div>
+ {:else if node.kind === 'oneOfMany'}
+ <div class="flex items-start justify-between gap-4" style={rowStyle(node.indent)}>
+ <div class="space-y-0.5">
+ <h3 class="text-sm">{node.name}</h3>
+ </div>
+ <Select
+ size="md"
+ title={node.title}
+ value={node.value}
+ onchange={(event) => updateOneOfMany(node.setting, (event.target as HTMLSelectElement).value)}
+ >
+ {#each node.options as option}
+ <option value={option.value}>{option.label}</option>
+ {/each}
+ </Select>
+ </div>
+ {/if}
+ {/each}
+</div>
diff --git a/packages/chrome-plugin/src/protocol.ts b/packages/chrome-plugin/src/protocol.ts
index a736ac45a..8c18696e5 100644
--- a/packages/chrome-plugin/src/protocol.ts
+++ b/packages/chrome-plugin/src/protocol.ts
@@ -1,9 +1,10 @@
-import type { Dialect, LintConfig, LintOptions } from 'harper.js';
+import type { Dialect, LintConfig, LintOptions, StructuredLintConfig } from 'harper.js';
import type { UnpackedLintGroups } from 'lint-framework';
export type Request =
| LintRequest
| GetConfigRequest
+ | GetStructuredConfigRequest
| SetConfigRequest
| GetLintDescriptionsRequest
| SetDialectRequest
@@ -34,6 +35,7 @@ export type Request =
export type Response =
| LintResponse
| GetConfigResponse
+ | GetStructuredConfigResponse
| UnitResponse
| GetLintDescriptionsResponse
| GetDialectResponse
@@ -69,6 +71,15 @@ export type GetConfigResponse = {
config: LintConfig;
};
+export type GetStructuredConfigRequest = {
+ kind: 'getStructuredConfig';
+};
+
+export type GetStructuredConfigResponse = {
+ kind: 'getStructuredConfig';
+ config: StructuredLintConfig;
+};
+
export type SetConfigRequest = {
kind: 'setConfig';
config: LintConfig;
diff --git a/packages/chrome-plugin/tests/options_structured_rules.spec.ts b/packages/chrome-plugin/tests/options_structured_rules.spec.ts
new file mode 100644
index 000000000..fa8d9825e
--- /dev/null
+++ b/packages/chrome-plugin/tests/options_structured_rules.spec.ts
@@ -0,0 +1,110 @@
+import { expect, test } from './fixtures';
+import { getStoredLintConfig, openExtensionPage } from './testUtils';
+
+const STYLE_CATEGORY = 'Style and Redundancy';
+const STYLE_DESCRIPTION =
+ 'Highlights wordy, repetitive, or overly weak phrasing that can usually be tightened up.';
+const STYLE_BUTTON_TITLE = `Expand the ${STYLE_CATEGORY} category`;
+const STYLE_BUTTON_COLLAPSE_TITLE = `Collapse the ${STYLE_CATEGORY} category`;
+const STYLE_DROPDOWN_TITLE = `Set all rules in the ${STYLE_CATEGORY} category to their default, on, or off state.`;
+const REPEATED_WORDS_TITLE = 'Set Repeated Words to its default, on, or off state.';
+
+test.describe('structured rule settings', () => {
+ test.describe.configure({ mode: 'serial' });
+ test.setTimeout(90_000);
+ test.skip(
+ ({ browserName }) => browserName === 'firefox',
+ 'Firefox MV3 background context is not exposed reliably in playwright-webextext.',
+ );
+
+ test('renders categories collapsed by default with category controls', async ({
+ context,
+ page,
+ }) => {
+ await openExtensionPage(context, page, 'options.html');
+
+ await expect(page.getByTitle(STYLE_BUTTON_TITLE)).toBeVisible({ timeout: 15000 });
+ await expect(page.getByTitle(STYLE_DROPDOWN_TITLE)).toBeVisible({ timeout: 15000 });
+ await expect(page.locator('h3', { hasText: STYLE_CATEGORY })).toBeVisible({ timeout: 15000 });
+ await expect(page.getByText(STYLE_DESCRIPTION)).toBeVisible({ timeout: 15000 });
+ await expect(page.locator('h3', { hasText: 'Repeated Words' })).toHaveCount(0);
+ });
+
+ test('expands categories and indents nested rules', async ({ context, page }) => {
+ await openExtensionPage(context, page, 'options.html');
+
+ await page.getByTitle(STYLE_BUTTON_TITLE).click();
+ await expect(page.locator('[style*="padding-left: 1.5rem"]').first()).toBeVisible();
+ });
+
+ test('search expands matching categories and reveals nested rules', async ({ context, page }) => {
+ await openExtensionPage(context, page, 'options.html');
+ await expect(page.getByTitle(STYLE_DROPDOWN_TITLE)).toBeVisible({ timeout: 15000 });
+
+ await page.getByPlaceholder('Search for a rule…').fill('wordy');
+
+ await expect(page.locator('h3', { hasText: STYLE_CATEGORY })).toBeVisible();
+ await expect(page.getByText(STYLE_DESCRIPTION)).toBeVisible();
+ await expect(page.getByTitle(REPEATED_WORDS_TITLE)).toBeVisible({ timeout: 15000 });
+ });
+
+ test('category dropdown bulk updates constituent flat rules', async ({ context, page }) => {
+ await openExtensionPage(context, page, 'options.html');
+
+ await page.getByTitle(STYLE_DROPDOWN_TITLE).selectOption('disable');
+
+ await expect
+ .poll(async () => {
+ const config = await getStoredLintConfig(context);
+ return {
+ BoringWords: config.BoringWords,
+ DiscourseMarkers: config.DiscourseMarkers,
+ RepeatedWords: config.RepeatedWords,
+ };
+ })
+ .toEqual({
+ BoringWords: false,
+ DiscourseMarkers: false,
+ RepeatedWords: false,
+ });
+
+ await page.getByTitle(STYLE_DROPDOWN_TITLE).selectOption('default');
+
+ await expect
+ .poll(async () => {
+ const config = await getStoredLintConfig(context);
+ return {
+ BoringWords: config.BoringWords,
+ DiscourseMarkers: config.DiscourseMarkers,
+ RepeatedWords: config.RepeatedWords,
+ };
+ })
+ .toEqual({
+ BoringWords: null,
+ DiscourseMarkers: null,
+ RepeatedWords: null,
+ });
+ });
+
+ test('rule dropdown updates only the targeted flat rule', async ({ context, page }) => {
+ await openExtensionPage(context, page, 'options.html');
+ await expect(page.getByTitle(STYLE_DROPDOWN_TITLE)).toBeVisible({ timeout: 15000 });
+
+ await page.getByPlaceholder('Search for a rule…').fill('Repeated Words');
+ await expect(page.getByTitle(REPEATED_WORDS_TITLE)).toBeVisible({ timeout: 15000 });
+ await page.getByTitle(REPEATED_WORDS_TITLE).selectOption('disable');
+
+ await expect
+ .poll(async () => {
+ const config = await getStoredLintConfig(context);
+ return {
+ BoringWords: config.BoringWords,
+ RepeatedWords: config.RepeatedWords,
+ };
+ })
+ .toEqual({
+ BoringWords: null,
+ RepeatedWords: false,
+ });
+ });
+});
diff --git a/packages/chrome-plugin/tests/testUtils.ts b/packages/chrome-plugin/tests/testUtils.ts
index 58795f01d..56f590794 100644
--- a/packages/chrome-plugin/tests/testUtils.ts
+++ b/packages/chrome-plugin/tests/testUtils.ts
@@ -1,4 +1,5 @@
-import type { Locator, Page } from '@playwright/test';
+import type { BrowserContext, Locator, Page } from '@playwright/test';
+import type { LintConfig } from 'harper.js';
import type { Box } from 'lint-framework';
import { expect, test } from './fixtures';
@@ -16,6 +17,36 @@ export function randomString(length: number): string {
return result;
}
+export async function getBackground(context: BrowserContext) {
+ return (
+ context.serviceWorkers()[0] ??
+ context.backgroundPages()[0] ??
+ (await context.waitForEvent('serviceworker', { timeout: 90000 }))
+ );
+}
+
+export async function getExtensionId(context: BrowserContext): Promise<string> {
+ const background = await getBackground(context);
+ return background.url().split('/')[2];
+}
+
+export async function openExtensionPage(
+ context: BrowserContext,
+ page: Page,
+ path: 'popup.html' | 'options.html',
+) {
+ const extensionId = await getExtensionId(context);
+ await page.goto(`chrome-extension://${extensionId}/${path}`);
+}
+
+export async function getStoredLintConfig(context: BrowserContext): Promise<LintConfig> {
+ const background = await getBackground(context);
+ return await background.evaluate(async () => {
+ const value = await chrome.storage.local.get('lintConfig');
+ return JSON.parse(value.lintConfig ?? '{}');
+ });
+}
+
/** Locate the [`Slate`](https://www.slatejs.org/examples/richtext) editor on the page. */
export function getSlateEditor(page: Page): Locator {
return page.locator('[data-slate-editor="true"]');
diff --git a/packages/harper.js/src/Linter.test.ts b/packages/harper.js/src/Linter.test.ts
index 380913190..12f804b94 100644
--- a/packages/harper.js/src/Linter.test.ts
+++ b/packages/harper.js/src/Linter.test.ts
@@ -262,6 +262,50 @@ for (const [linterName, Linter] of Object.entries(linters)) {
await linter.dispose();
});
+ test(`${linterName} can get structured lint config`, async () => {
+ const linter = new Linter({ binary });
+
+ const structuredConfig = await linter.getStructuredLintConfig();
+ const firstGroup = structuredConfig.settings.find((setting) => 'Group' in setting);
+
+ expect(structuredConfig).toBeTypeOf('object');
+ expect(structuredConfig.settings).toBeTypeOf('object');
+ expect(structuredConfig.settings.length).toBeGreaterThan(0);
+ expect(firstGroup && 'Group' in firstGroup).toBe(true);
+ if (!firstGroup || !('Group' in firstGroup)) {
+ throw new Error('Expected at least one group in the structured config.');
+ }
+ expect(firstGroup.Group.description).toBeTypeOf('string');
+ expect(firstGroup.Group.description.length).toBeGreaterThan(0);
+
+ await linter.dispose();
+ });
+
+ test(`${linterName} structured lint config JSON parses`, async () => {
+ const linter = new Linter({ binary });
+
+ const json = await linter.getStructuredLintConfigJSON();
+ const structuredConfig = JSON.parse(json);
+
+ expect(structuredConfig).toBeTypeOf('object');
+ expect(structuredConfig.settings).toBeTypeOf('object');
+
+ await linter.dispose();
+ });
+
+ test(`${linterName} structured lint config JSON and object agree`, async () => {
+ const linter = new Linter({ binary });
+
+ const json = await linter.getStructuredLintConfigJSON();
+ const object = await linter.getStructuredLintConfig();
+
+ expect(object).toBeTypeOf('object');
+ expect(json).toBeTypeOf('string');
+ expect(object).toEqual(JSON.parse(json));
+
+ await linter.dispose();
+ });
+
test(`${linterName} can generate lint context hashes`, async () => {
const linter = new Linter({ binary });
const source = 'This is an test.';
diff --git a/packages/harper.js/src/Linter.ts b/packages/harper.js/src/Linter.ts
index 0c31b6244..afff6975c 100644
--- a/packages/harper.js/src/Linter.ts
+++ b/packages/harper.js/src/Linter.ts
@@ -1,6 +1,6 @@
import type { Dialect, Lint, Suggestion } from 'harper-wasm';
import type { BinaryModule } from './BinaryModule';
-import type { LintConfig, LintOptions } from './main';
+import type { LintConfig, LintOptions, StructuredLintConfig } from './main';
import type Summary from './Summary';
export interface WeirpackTestFailure {
@@ -45,6 +45,16 @@ export default interface Linter {
* This method does not affect the caller's lint configuration, nor does it return the current one. */
getDefaultLintConfig(): Promise<LintConfig>;
+ /** Get the linter's current structured configuration.
+ * This is intended for organizing and rendering settings UIs.
+ * Persisted config changes must still be applied through the flat `setLintConfig` API. */
+ getStructuredLintConfig(): Promise<StructuredLintConfig>;
+
+ /** Get the linter's current structured configuration as JSON.
+ * This is a presentation-oriented view over the underlying flat config.
+ * Persisted config changes must still be applied through the flat `setLintConfig` API. */
+ getStructuredLintConfigJSON(): Promise<string>;
+
/** Set the linter's current configuration. */
setLintConfig(config: LintConfig): Promise<void>;
diff --git a/packages/harper.js/src/LocalLinter.ts b/packages/harper.js/src/LocalLinter.ts
index 8aafe6086..bbcfe3ce1 100644
--- a/packages/harper.js/src/LocalLinter.ts
+++ b/packages/harper.js/src/LocalLinter.ts
@@ -4,7 +4,7 @@ import LazyPromise from 'p-lazy';
import type { SuperBinaryModule } from './BinaryModule';
import type Linter from './Linter';
import type { LinterInit, WeirpackTestFailures } from './Linter';
-import type { LintConfig, LintOptions } from './main';
+import type { LintConfig, LintOptions, StructuredLintConfig } from './main';
/** A Linter that runs in the current JavaScript context (meaning it is allowed to block the event loop).
* See the interface definition for more details. */
@@ -120,6 +120,16 @@ export default class LocalLinter implements Linter {
return await this.binary.getDefaultLintConfig();
}
+ async getStructuredLintConfig(): Promise<StructuredLintConfig> {
+ const inner = await this.inner;
+ return inner.get_structured_lint_config_as_object();
+ }
+
+ async getStructuredLintConfigJSON(): Promise<string> {
+ const inner = await this.inner;
+ return inner.get_structured_lint_config_as_json();
+ }
+
async setLintConfig(config: LintConfig): Promise<void> {
const inner = await this.inner;
inner.set_lint_config_from_object(config);
diff --git a/packages/harper.js/src/WorkerLinter/index.ts b/packages/harper.js/src/WorkerLinter/index.ts
index 9fff8caa0..21a548e65 100644
--- a/packages/harper.js/src/WorkerLinter/index.ts
+++ b/packages/harper.js/src/WorkerLinter/index.ts
@@ -2,7 +2,7 @@ import type { Dialect, Lint, Suggestion } from 'harper-wasm';
import type { BinaryModule } from '../BinaryModule';
import type Linter from '../Linter';
import type { LinterInit, WeirpackTestFailures } from '../Linter';
-import type { LintConfig, LintOptions } from '../main';
+import type { LintConfig, LintOptions, StructuredLintConfig } from '../main';
import type { DeserializedRequest } from '../Serializer';
import Serializer from '../Serializer';
import Worker from './worker.ts?worker&inline';
@@ -134,6 +134,14 @@ export default class WorkerLinter implements Linter {
return JSON.parse(await this.getDefaultLintConfigAsJSON()) as LintConfig;
}
+ async getStructuredLintConfig(): Promise<StructuredLintConfig> {
+ return JSON.parse(await this.getStructuredLintConfigJSON()) as StructuredLintConfig;
+ }
+
+ getStructuredLintConfigJSON(): Promise<string> {
+ return this.rpc('getStructuredLintConfigJSON', []);
+ }
+
async dispose(): Promise<void> {
if (this.disposed) {
return;
diff --git a/packages/harper.js/src/main.ts b/packages/harper.js/src/main.ts
index b301e5dff..b459a6ec6 100644
--- a/packages/harper.js/src/main.ts
+++ b/packages/harper.js/src/main.ts
@@ -16,6 +16,39 @@ export { packWeirpackFiles, unpackWeirpackBytes } from './weirpack';
* This is a record, since you shouldn't hard-code the existence of any particular rules and should generalize based on this struct. */
export type LintConfig = Record<string, boolean | null>;
+export type StructuredLintSetting =
+ | StructuredLintBoolSetting
+ | StructuredLintOneOfManySetting
+ | StructuredLintGroupSetting;
+
+export interface StructuredLintConfig {
+ settings: StructuredLintSetting[];
+}
+
+export interface StructuredLintBoolSetting {
+ Bool: {
+ name: string;
+ state: boolean;
+ label?: string | null;
+ };
+}
+
+export interface StructuredLintOneOfManySetting {
+ OneOfMany: {
+ names: string[];
+ name?: string | null;
+ labels?: string[] | null;
+ };
+}
+
+export interface StructuredLintGroupSetting {
+ Group: {
+ label: string;
+ description: string;
+ child: StructuredLintConfig;
+ };
+}
+
/** Options available to configure Harper's parser for an individual linting operation. */
export interface LintOptions {
/** The markup language that is being passed. Defaults to `markdown`. */
diff --git a/packages/obsidian-plugin/src/HarperSettingTab.ts b/packages/obsidian-plugin/src/HarperSettingTab.ts
index 63037658f..4217cdc09 100644
--- a/packages/obsidian-plugin/src/HarperSettingTab.ts
+++ b/packages/obsidian-plugin/src/HarperSettingTab.ts
@@ -1,4 +1,5 @@
import './index.js';
+import type { StructuredLintConfig, StructuredLintSetting } from 'harper.js';
import { Dialect } from 'harper.js';
import { startCase } from 'lodash-es';
import type { ButtonComponent } from 'obsidian';
@@ -11,12 +12,14 @@ import { linesToString, stringToLines } from './textUtils';
const LintSettingId = 'HarperLintSettings';
export class HarperSettingTab extends PluginSettingTab {
- private settings: Settings;
- private descriptionsHTML: Record<string, string>;
- private defaultLintConfig: Record<string, boolean>;
+ private settings?: Settings;
+ private descriptionsHTML: Record<string, string> = {};
+ private defaultLintConfig: Record<string, boolean> = {};
+ private structuredLintConfig?: StructuredLintConfig;
private currentRuleSearchQuery = '';
private plugin: HarperPlugin;
private toggleAllButton?: ButtonComponent;
+ private expandedGroups = new Set<string>();
private get state() {
return this.plugin.state;
@@ -31,18 +34,26 @@ export class HarperSettingTab extends PluginSettingTab {
this.updateDescriptions();
this.updateSettings();
this.updateDefaults();
+ this.updateStructuredConfig();
}
updateSettings() {
this.state.getSettings().then((v) => {
+ const shouldRedrawWholeTab = this.settings == null;
this.settings = v;
this.updateToggleAllRulesButton();
+ if (shouldRedrawWholeTab) {
+ this.display(false);
+ return;
+ }
+ this.rerenderLintSettings();
});
}
updateDescriptions() {
this.state.getDescriptionHTML().then((v) => {
this.descriptionsHTML = v;
+ this.rerenderLintSettings();
});
}
@@ -50,6 +61,14 @@ export class HarperSettingTab extends PluginSettingTab {
this.state.getDefaultLintConfig().then((v) => {
this.defaultLintConfig = v as unknown as Record<string, boolean>;
this.updateToggleAllRulesButton();
+ this.rerenderLintSettings();
+ });
+ }
+
+ updateStructuredConfig() {
+ this.state.getStructuredLintConfig().then((v) => {
+ this.structuredLintConfig = v;
+ this.rerenderLintSettings();
});
}
@@ -62,15 +81,24 @@ export class HarperSettingTab extends PluginSettingTab {
const { containerEl } = this;
containerEl.empty();
+ if (!this.settings) {
+ const loading = document.createElement('p');
+ loading.textContent = 'Loading Harper settings...';
+ containerEl.appendChild(loading);
+ return;
+ }
+
+ const settings = this.settings;
+
new Setting(containerEl)
.setName('Use Web Worker')
.setDesc(
'Whether to run the Harper engine in a separate thread. Improves stability and speed at the cost of memory.',
)
.addToggle((toggle) =>
- toggle.setValue(this.settings.useWebWorker).onChange(async (value) => {
- this.settings.useWebWorker = value;
- await this.state.initializeFromSettings(this.settings);
+ toggle.setValue(settings.useWebWorker).onChange(async (value) => {
+ settings.useWebWorker = value;
+ await this.state.initializeFromSettings(settings);
}),
);
@@ -81,11 +109,11 @@ export class HarperSettingTab extends PluginSettingTab {
.addOption(Dialect.British.toString(), 'British')
.addOption(Dialect.Australian.toString(), 'Australian')
.addOption(Dialect.Indian.toString(), 'Indian')
- .setValue((this.settings.dialect ?? Dialect.American).toString())
+ .setValue((settings.dialect ?? Dialect.American).toString())
.onChange(async (value) => {
const dialect = Number.parseInt(value, 10);
- this.settings.dialect = dialect;
- await this.state.initializeFromSettings(this.settings);
+ settings.dialect = dialect;
+ await this.state.initializeFromSettings(settings);
this.plugin.updateStatusBar(dialect);
});
});
@@ -94,7 +122,7 @@ export class HarperSettingTab extends PluginSettingTab {
.setName('Activate Harper')
.setDesc('Enable or disable Harper with this option.')
.addToggle((toggle) =>
- toggle.setValue(this.settings.lintEnabled).onChange(async (_value) => {
+ toggle.setValue(settings.lintEnabled ?? true).onChange(async (_value) => {
this.state.toggleAutoLint();
this.plugin.updateStatusBar();
}),
@@ -118,9 +146,9 @@ export class HarperSettingTab extends PluginSettingTab {
"Hide certain text from Harper's pedantic gaze with a regular expression. Follows the standard Rust syntax.",
)
.addTextArea((ta) =>
- ta.setValue(this.settings.regexMask ?? '').onChange(async (value) => {
- this.settings.regexMask = value;
- await this.state.initializeFromSettings(this.settings);
+ ta.setValue(settings.regexMask ?? '').onChange(async (value) => {
+ settings.regexMask = value;
+ await this.state.initializeFromSettings(settings);
}),
);
@@ -131,10 +159,10 @@ export class HarperSettingTab extends PluginSettingTab {
)
.addTextArea((ta) => {
ta.inputEl.cols = 20;
- ta.setValue(linesToString(this.settings.userDictionary ?? [''])).onChange(async (v) => {
+ ta.setValue(linesToString(settings.userDictionary ?? [''])).onChange(async (v) => {
const dict = stringToLines(v);
- this.settings.userDictionary = dict;
- await this.state.initializeFromSettings(this.settings);
+ settings.userDictionary = dict;
+ await this.state.initializeFromSettings(settings);
});
});
@@ -145,10 +173,10 @@ export class HarperSettingTab extends PluginSettingTab {
)
.addTextArea((ta) => {
ta.inputEl.cols = 20;
- ta.setValue(linesToString(this.settings.ignoredGlobs ?? [''])).onChange(async (v) => {
+ ta.setValue(linesToString(settings.ignoredGlobs ?? [''])).onChange(async (v) => {
const lines = stringToLines(v);
- this.settings.ignoredGlobs = lines;
- await this.state.initializeFromSettings(this.settings);
+ settings.ignoredGlobs = lines;
+ await this.state.initializeFromSettings(settings);
});
});
@@ -161,10 +189,10 @@ export class HarperSettingTab extends PluginSettingTab {
slider
.setDynamicTooltip()
.setLimits(-1, 10000, 50)
- .setValue(this.settings.delay ?? -1)
+ .setValue(settings.delay ?? -1)
.onChange(async (value) => {
- this.settings.delay = value;
- await this.state.initializeFromSettings(this.settings);
+ settings.delay = value;
+ await this.state.initializeFromSettings(settings);
});
});
@@ -172,8 +200,8 @@ export class HarperSettingTab extends PluginSettingTab {
button
.setButtonText('Forget Ignored Suggestions')
.onClick(() => {
- this.settings.ignoredLints = undefined;
- this.state.initializeFromSettings(this.settings);
+ settings.ignoredLints = undefined;
+ this.state.initializeFromSettings(settings);
})
.setWarning();
});
@@ -238,11 +266,17 @@ export class HarperSettingTab extends PluginSettingTab {
lintSettings.id = LintSettingId;
containerEl.appendChild(lintSettings);
- // Ensure default config is loaded before initial render so values reflect defaults.
- this.state.getDefaultLintConfig().then((v) => {
- this.defaultLintConfig = v as unknown as Record<string, boolean>;
- this.renderLintSettingsToId(this.currentRuleSearchQuery, lintSettings.id);
- });
+ Promise.all([this.state.getDefaultLintConfig(), this.state.getStructuredLintConfig()]).then(
+ ([defaults, structured]) => {
+ this.defaultLintConfig = defaults as unknown as Record<string, boolean>;
+ this.structuredLintConfig = structured;
+ this.renderLintSettingsToId(this.currentRuleSearchQuery, lintSettings.id);
+ },
+ );
+ }
+
+ private rerenderLintSettings() {
+ this.renderLintSettingsToId(this.currentRuleSearchQuery, LintSettingId);
}
private async updateToggleAllRulesButton() {
@@ -267,49 +301,339 @@ export class HarperSettingTab extends PluginSettingTab {
const queryLower = searchQuery.toLowerCase();
- for (const setting of Object.keys(this.settings.lintSettings)) {
- const value = this.settings.lintSettings[setting];
- const descriptionHTML = this.descriptionsHTML[setting];
-
- if (
- searchQuery !== '' &&
- !(
- descriptionHTML?.toLowerCase().contains(queryLower) ||
- setting.toLowerCase().contains(queryLower)
- )
- ) {
+ if (!this.structuredLintConfig) {
+ return;
+ }
+
+ const rendered = this.renderStructuredSettings(
+ this.structuredLintConfig.settings,
+ containerEl,
+ effectiveConfig,
+ queryLower,
+ 0,
+ false,
+ );
+
+ if (rendered === 0) {
+ const empty = document.createElement('p');
+ empty.textContent = 'No rules match your search.';
+ containerEl.appendChild(empty);
+ }
+ }
+
+ private renderStructuredSettings(
+ settings: StructuredLintSetting[],
+ containerEl: HTMLElement,
+ effectiveConfig: Record<string, boolean>,
+ queryLower: string,
+ depth: number,
+ forceShow: boolean,
+ path: string[] = [],
+ ): number {
+ let rendered = 0;
+
+ for (const setting of settings) {
+ if ('Group' in setting) {
+ const groupPath = [...path, setting.Group.label];
+ const groupKey = groupPath.join(' / ');
+ const groupMatches =
+ queryLower !== '' &&
+ (setting.Group.label.toLowerCase().includes(queryLower) ||
+ setting.Group.description.toLowerCase().includes(queryLower));
+
+ const childEl = document.createElement('div');
+ childEl.style.marginLeft = '1.5rem';
+
+ const childCount = this.renderStructuredSettings(
+ setting.Group.child.settings,
+ childEl,
+ effectiveConfig,
+ queryLower,
+ depth + 1,
+ forceShow || groupMatches,
+ groupPath,
+ );
+
+ if (childCount === 0) {
+ continue;
+ }
+
+ const groupRules = this.collectRuleNames(setting.Group.child.settings);
+ const isExpanded = queryLower !== '' || this.expandedGroups.has(groupKey);
+
+ this.renderGroupSetting(
+ setting.Group.label,
+ setting.Group.description,
+ groupKey,
+ groupRules,
+ containerEl,
+ childEl,
+ isExpanded,
+ );
+ rendered += childCount;
continue;
}
- const fragment = document.createDocumentFragment();
+ if ('Bool' in setting) {
+ if (!this.shouldRenderRule(setting.Bool.name, setting.Bool.label, queryLower, forceShow)) {
+ continue;
+ }
+
+ this.renderBoolSetting(setting.Bool.name, setting.Bool.label, containerEl, effectiveConfig);
+ rendered += 1;
+ continue;
+ }
+
+ if ('OneOfMany' in setting) {
+ if (!this.shouldRenderOneOfMany(setting.OneOfMany, queryLower, forceShow)) {
+ continue;
+ }
+
+ this.renderOneOfManySetting(setting.OneOfMany, containerEl, effectiveConfig);
+ rendered += 1;
+ }
+ }
+
+ return rendered;
+ }
+
+ private collectRuleNames(settings: StructuredLintSetting[]): string[] {
+ const out: string[] = [];
+
+ for (const setting of settings) {
+ if ('Bool' in setting) {
+ out.push(setting.Bool.name);
+ continue;
+ }
+
+ if ('OneOfMany' in setting) {
+ out.push(...setting.OneOfMany.names);
+ continue;
+ }
+
+ out.push(...this.collectRuleNames(setting.Group.child.settings));
+ }
+
+ return out;
+ }
+
+ private renderGroupSetting(
+ label: string,
+ description: string,
+ groupKey: string,
+ ruleNames: string[],
+ containerEl: HTMLElement,
+ childEl: HTMLElement,
+ isExpanded: boolean,
+ ) {
+ const state = this.getGroupState(ruleNames);
+ const defaultLabel = state === 'mixed' ? 'Default (mixed)' : 'Default';
+
+ new Setting(containerEl)
+ .setName(label)
+ .setDesc(description)
+ .addButton((button) => {
+ this.setButtonHoverText(
+ button,
+ isExpanded ? `Collapse the ${label} category` : `Expand the ${label} category`,
+ );
+
+ button.setButtonText(isExpanded ? 'Collapse' : 'Expand').onClick(() => {
+ if (this.expandedGroups.has(groupKey)) {
+ this.expandedGroups.delete(groupKey);
+ } else {
+ this.expandedGroups.add(groupKey);
+ }
+
+ this.rerenderLintSettings();
+ });
+ })
+ .addDropdown((dropdown) => {
+ this.setDropdownHoverText(
+ dropdown,
+ `Set all rules in the ${label} category to their default, on, or off state.`,
+ );
+
+ dropdown
+ .addOption('default', defaultLabel)
+ .addOption('enable', 'On')
+ .addOption('disable', 'Off')
+ .setValue(state === 'mixed' ? 'default' : state)
+ .onChange(async (value) => {
+ const settings = this.settings;
+ if (!settings) {
+ return;
+ }
+
+ for (const ruleName of ruleNames) {
+ settings.lintSettings[ruleName] = value === 'default' ? null : value === 'enable';
+ }
+
+ await this.state.initializeFromSettings(settings);
+ this.settings = await this.state.getSettings();
+ this.rerenderLintSettings();
+ this.updateToggleAllRulesButton();
+ });
+ });
+
+ if (isExpanded) {
+ containerEl.appendChild(childEl);
+ }
+ }
+
+ private setButtonHoverText(button: ButtonComponent, text: string) {
+ const maybeTooltipButton = button as ButtonComponent & {
+ setTooltip?: (text: string) => ButtonComponent;
+ buttonEl?: HTMLButtonElement;
+ };
+
+ maybeTooltipButton.setTooltip?.(text);
+ maybeTooltipButton.buttonEl?.setAttribute('title', text);
+ }
+
+ private setDropdownHoverText(dropdown: { selectEl?: HTMLSelectElement }, text: string) {
+ dropdown.selectEl?.setAttribute('title', text);
+ }
+
+ private getGroupState(ruleNames: string[]): 'default' | 'enable' | 'disable' | 'mixed' {
+ const settings = this.settings;
+ if (!settings) {
+ return 'default';
+ }
+
+ const values = ruleNames.map((ruleName) => settings.lintSettings[ruleName] ?? null);
+
+ if (values.every((value) => value === null)) {
+ return 'default';
+ }
+
+ if (values.every((value) => value === true)) {
+ return 'enable';
+ }
+
+ if (values.every((value) => value === false)) {
+ return 'disable';
+ }
+
+ return 'mixed';
+ }
+
+ private shouldRenderRule(
+ ruleName: string,
+ label: string | null | undefined,
+ queryLower: string,
+ forceShow: boolean,
+ ) {
+ if (forceShow || queryLower === '') {
+ return true;
+ }
+
+ const descriptionHTML = this.descriptionsHTML?.[ruleName] ?? '';
+ return (
+ ruleName.toLowerCase().includes(queryLower) ||
+ (label?.toLowerCase().includes(queryLower) ?? false) ||
+ descriptionHTML.toLowerCase().includes(queryLower)
+ );
+ }
+
+ private shouldRenderOneOfMany(
+ setting: Extract<StructuredLintSetting, { OneOfMany: unknown }>['OneOfMany'],
+ queryLower: string,
+ forceShow: boolean,
+ ) {
+ if (forceShow || queryLower === '') {
+ return true;
+ }
+
+ return setting.names.some((name, index) =>
+ this.shouldRenderRule(name, setting.labels?.[index], queryLower, false),
+ );
+ }
+
+ private renderBoolSetting(
+ setting: string,
+ label: string | null | undefined,
+ containerEl: HTMLElement,
+ effectiveConfig: Record<string, boolean>,
+ ) {
+ if (!this.settings) {
+ return;
+ }
+
+ const value = this.settings.lintSettings[setting];
+ const descriptionHTML = this.descriptionsHTML?.[setting] ?? '';
+ const fragment = document.createDocumentFragment();
+ if (descriptionHTML !== '') {
const template = document.createElement('template');
template.innerHTML = descriptionHTML;
fragment.appendChild(template.content);
+ }
- // Determine default for this rule (if available)
- const defaultVal = this.defaultLintConfig?.[setting];
-
- new Setting(containerEl)
- .setName(startCase(setting))
- .setDesc(fragment)
- .addDropdown((dropdown) => {
- const effective: boolean | undefined = effectiveConfig[setting];
- const usingDefault = value === null;
- const onLabel = usingDefault && defaultVal === true ? 'On (default)' : 'On';
- const offLabel = usingDefault && defaultVal === false ? 'Off (default)' : 'Off';
- dropdown
- .addOption('enable', onLabel)
- .addOption('disable', offLabel)
- .setValue(effective ? 'enable' : 'disable')
- .onChange(async (v) => {
- this.settings.lintSettings[setting] = v === 'enable';
- await this.state.initializeFromSettings(this.settings);
- // Re-render to update labels (remove "(default)" once overridden)
- this.renderLintSettingsToId(this.currentRuleSearchQuery, LintSettingId);
- this.updateToggleAllRulesButton();
- });
- });
+ const defaultVal = this.defaultLintConfig?.[setting];
+
+ new Setting(containerEl)
+ .setName(label ?? startCase(setting))
+ .setDesc(fragment)
+ .addDropdown((dropdown) => {
+ this.setDropdownHoverText(
+ dropdown,
+ `Set ${label ?? startCase(setting)} to on or off. Labels marked default reflect the current default behavior.`,
+ );
+
+ const effective: boolean | undefined = effectiveConfig[setting];
+ const usingDefault = value === null;
+ const onLabel = usingDefault && defaultVal === true ? 'On (default)' : 'On';
+ const offLabel = usingDefault && defaultVal === false ? 'Off (default)' : 'Off';
+ dropdown
+ .addOption('enable', onLabel)
+ .addOption('disable', offLabel)
+ .setValue(effective ? 'enable' : 'disable')
+ .onChange(async (v) => {
+ // The structured config only organizes rules for display.
+ // Persist changes through the flat lint config keyed by rule name.
+ this.settings.lintSettings[setting] = v === 'enable';
+ await this.state.initializeFromSettings(this.settings);
+ this.settings = await this.state.getSettings();
+ this.renderLintSettingsToId(this.currentRuleSearchQuery, LintSettingId);
+ this.updateToggleAllRulesButton();
+ });
+ });
+ }
+
+ private renderOneOfManySetting(
+ setting: Extract<StructuredLintSetting, { OneOfMany: unknown }>['OneOfMany'],
+ containerEl: HTMLElement,
+ effectiveConfig: Record<string, boolean>,
+ ) {
+ if (!this.settings) {
+ return;
}
+
+ const currentName =
+ setting.names.find((name) => effectiveConfig[name]) ?? setting.name ?? setting.names[0];
+ const label =
+ setting.labels?.join(' / ') ?? setting.names.map((name) => startCase(name)).join(' / ');
+
+ new Setting(containerEl).setName(label).addDropdown((dropdown) => {
+ this.setDropdownHoverText(dropdown, `Choose an option for ${label}.`);
+
+ for (const [index, name] of setting.names.entries()) {
+ dropdown.addOption(name, setting.labels?.[index] ?? startCase(name));
+ }
+
+ dropdown.setValue(currentName).onChange(async (selected) => {
+ // The structured config only organizes rules for display.
+ // Persist changes through the flat lint config keyed by rule name.
+ for (const name of setting.names) {
+ this.settings.lintSettings[name] = name === selected;
+ }
+
+ await this.state.initializeFromSettings(this.settings);
+ this.settings = await this.state.getSettings();
+ this.renderLintSettingsToId(this.currentRuleSearchQuery, LintSettingId);
+ this.updateToggleAllRulesButton();
+ });
+ });
}
}
diff --git a/packages/obsidian-plugin/src/State.test.ts b/packages/obsidian-plugin/src/State.test.ts
index d96ffdba5..d3b5f4966 100644
--- a/packages/obsidian-plugin/src/State.test.ts
+++ b/packages/obsidian-plugin/src/State.test.ts
@@ -1,3 +1,4 @@
+import type { StructuredLintConfig, StructuredLintSetting } from 'harper.js';
import { shuffle } from 'lodash-es';
import { expect, test } from 'vitest';
import State from './State';
@@ -20,6 +21,32 @@ function createEphemeralState(): State {
);
}
+function collectStructuredRuleNames(config: StructuredLintConfig): string[] {
+ const out: string[] = [];
+
+ const visit = (setting: StructuredLintSetting) => {
+ if ('Bool' in setting) {
+ out.push(setting.Bool.name);
+ return;
+ }
+
+ if ('OneOfMany' in setting) {
+ out.push(...setting.OneOfMany.names);
+ return;
+ }
+
+ for (const child of setting.Group.child.settings) {
+ visit(child);
+ }
+ };
+
+ for (const setting of config.settings) {
+ visit(setting);
+ }
+
+ return out;
+}
+
test('Toggling linting should change extension array.', () => {
const state = createEphemeralState();
@@ -106,6 +133,18 @@ test('Lint settings and descriptions have the same keys', async () => {
expect(extraInDescriptions.length).toBe(0);
});
+test('Structured lint config and flat lint settings have the same keys', async () => {
+ const state = createEphemeralState();
+
+ const settings = await state.getSettings();
+ const structured = await state.getStructuredLintConfig();
+
+ const lintKeys = Object.keys(settings.lintSettings).sort();
+ const structuredKeys = collectStructuredRuleNames(structured).sort();
+
+ expect(structuredKeys).toStrictEqual(lintKeys);
+});
+
test('Can be initialized with incomplete lint settings and retain default state.', async () => {
const state = createEphemeralState();
diff --git a/packages/obsidian-plugin/src/State.ts b/packages/obsidian-plugin/src/State.ts
index b5ed2affd..492918feb 100644
--- a/packages/obsidian-plugin/src/State.ts
+++ b/packages/obsidian-plugin/src/State.ts
@@ -1,5 +1,5 @@
import type { Extension, StateField } from '@codemirror/state';
-import type { Lint, LintConfig, Linter, Suggestion } from 'harper.js';
+import type { Lint, LintConfig, Linter, StructuredLintConfig, Suggestion } from 'harper.js';
import { type Dialect, LocalLinter, SuggestionKind, WorkerLinter } from 'harper.js';
import { slimBinaryInlined } from 'harper.js/slimBinaryInlined';
import { minimatch } from 'minimatch';
@@ -315,6 +315,12 @@ export default class State {
return await this.harper.getLintDescriptionsHTML();
}
+ /** Expose the structured lint configuration for UI rendering only.
+ * Rule state must still be persisted through flat `lintSettings`. */
+ public async getStructuredLintConfig(): Promise<StructuredLintConfig> {
+ return await this.harper.getStructuredLintConfig();
+ }
+
/** Expose the default lint configuration for UI rendering. */
public async getDefaultLintConfig(): Promise<LintConfig> {
return await this.harper.getDefaultLintConfig();
diff --git a/packages/web/src/routes/docs/contributors/author-a-rule/+page.md b/packages/web/src/routes/docs/contributors/author-a-rule/+page.md
index 7d719cd8e..bdb8bc5d1 100644
--- a/packages/web/src/routes/docs/contributors/author-a-rule/+page.md
+++ b/packages/web/src/routes/docs/contributors/author-a-rule/+page.md
@@ -176,6 +176,13 @@ insert_expr_rule!(OutOfDate, true);
If you use a `ExprLinter`, use `insert_expr_rule` to take advantage of Harper's aggressive caching.
Otherwise, use `insert_struct_rule`.
+## Update `default_config.json`
+
+Whenever you add a new rule, update `harper-core/src/linting/lint_group/default_config.json` too.
+That file defines the curated default configuration shown throughout Harper, so a new rule will not
+appear in the default setup until it is added there as well.
+See also [`StructuredConfig`](https://docs.rs/harper-core/latest/harper_core/linting/lint_group/struct.StructuredConfig.html).
+
## Write Your Rule
Defining an expression and [implementing the ExprLinter trait](https://docs.rs/harper-core/latest/harper_core/linting/trait.ExprLinter.html) is the easiest way to define a new rule for Harper.