From 018f40477045d9f35210a62651d8f2336a0cfa61 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Oct 2023 20:23:14 -0500 Subject: [PATCH 1/5] test(cli): Verify shttp shows up --- .../typos-cli/tests/cmd/false-positives.in/README.md | 2 ++ crates/typos-cli/tests/cmd/false-positives.toml | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/typos-cli/tests/cmd/false-positives.in/README.md b/crates/typos-cli/tests/cmd/false-positives.in/README.md index 5871723..1059caa 100644 --- a/crates/typos-cli/tests/cmd/false-positives.in/README.md +++ b/crates/typos-cli/tests/cmd/false-positives.in/README.md @@ -5,3 +5,5 @@ git glossary has both commitish and committish, so don't correct them HTTP_REFERER is a valid HTTP header field It should be reasonable to talk about `` + +SHTTP is a protocol diff --git a/crates/typos-cli/tests/cmd/false-positives.toml b/crates/typos-cli/tests/cmd/false-positives.toml index 324f41d..be505e1 100644 --- a/crates/typos-cli/tests/cmd/false-positives.toml +++ b/crates/typos-cli/tests/cmd/false-positives.toml @@ -1,4 +1,12 @@ bin.name = "typos" stdin = "" -stdout = "" +stdout = """ +error: `SHTTP` should be `HTTPS` + --> ./README.md:9:1 + | +9 | SHTTP is a protocol + | ^^^^^ + | +""" stderr = "" +status.code = 2 From d8ac8702133fcfcbca798187e878e75bfb1c53c2 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Oct 2023 20:25:36 -0500 Subject: [PATCH 2/5] fix(dict): Alllow SHTTP --- crates/typos-cli/tests/cmd/false-positives.toml | 10 +--------- crates/typos-dict/assets/allowed.csv | 1 + crates/typos-dict/assets/words.csv | 1 - crates/typos-dict/src/word_codegen.rs | 2 -- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/crates/typos-cli/tests/cmd/false-positives.toml b/crates/typos-cli/tests/cmd/false-positives.toml index be505e1..324f41d 100644 --- a/crates/typos-cli/tests/cmd/false-positives.toml +++ b/crates/typos-cli/tests/cmd/false-positives.toml @@ -1,12 +1,4 @@ bin.name = "typos" stdin = "" -stdout = """ -error: `SHTTP` should be `HTTPS` - --> ./README.md:9:1 - | -9 | SHTTP is a protocol - | ^^^^^ - | -""" +stdout = "" stderr = "" -status.code = 2 diff --git a/crates/typos-dict/assets/allowed.csv b/crates/typos-dict/assets/allowed.csv index 5203c58..77a19e7 100644 --- a/crates/typos-dict/assets/allowed.csv +++ b/crates/typos-dict/assets/allowed.csv @@ -18,3 +18,4 @@ contiguities,plural of contiguity bellow,valid word and not just a typo of `below` revered,valid word and not just a typoe of `reversed` recuse,valid word despite maybe being a typo of recurse +shttp,also a protocol diff --git a/crates/typos-dict/assets/words.csv b/crates/typos-dict/assets/words.csv index 5795e7a..066db40 100644 --- a/crates/typos-dict/assets/words.csv +++ b/crates/typos-dict/assets/words.csv @@ -52334,7 +52334,6 @@ shtopped,stopped,shopped shtoppes,stops,shops shtopping,stopping,shopping shtops,stops,shops -shttp,https shudown,shutdown shufle,shuffle shuld,should diff --git a/crates/typos-dict/src/word_codegen.rs b/crates/typos-dict/src/word_codegen.rs index 2691efe..1507042 100644 --- a/crates/typos-dict/src/word_codegen.rs +++ b/crates/typos-dict/src/word_codegen.rs @@ -37383,7 +37383,6 @@ pub static WORD_SHT_CHILDREN: dictgen::DictTable<&'static [&'static str]> = dict dictgen::InsensitiveStr::Ascii("oppes"), dictgen::InsensitiveStr::Ascii("opping"), dictgen::InsensitiveStr::Ascii("ops"), - dictgen::InsensitiveStr::Ascii("tp"), ], values: &[ &["shitless"], @@ -37396,7 +37395,6 @@ pub static WORD_SHT_CHILDREN: dictgen::DictTable<&'static [&'static str]> = dict &["stops", "shops"], &["stopping", "shopping"], &["stops", "shops"], - &["https"], ], range: 2..=6, }; From a2777f710b15ab9ccd1da71ab062fc1e27f662b0 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Oct 2023 20:40:15 -0500 Subject: [PATCH 3/5] test(cli): Verify some Julia terms --- .../tests/cmd/false-positives.in/sample.jl | 6 ++++ .../typos-cli/tests/cmd/false-positives.toml | 28 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 crates/typos-cli/tests/cmd/false-positives.in/sample.jl diff --git a/crates/typos-cli/tests/cmd/false-positives.in/sample.jl b/crates/typos-cli/tests/cmd/false-positives.in/sample.jl new file mode 100644 index 0000000..ba7f7a7 --- /dev/null +++ b/crates/typos-cli/tests/cmd/false-positives.in/sample.jl @@ -0,0 +1,6 @@ +# one egal: === +# three egals: === === === + +# When we need to refer to keywords without saying them +var modul = "hello"; +var usig = "hello"; diff --git a/crates/typos-cli/tests/cmd/false-positives.toml b/crates/typos-cli/tests/cmd/false-positives.toml index 324f41d..41e44a3 100644 --- a/crates/typos-cli/tests/cmd/false-positives.toml +++ b/crates/typos-cli/tests/cmd/false-positives.toml @@ -1,4 +1,30 @@ bin.name = "typos" stdin = "" -stdout = "" +stdout = """ +error: `egal` should be `equal` + --> ./sample.jl:1:7 + | +1 | # one egal: === + | ^^^^ + | +error: `egals` should be `equals` + --> ./sample.jl:2:9 + | +2 | # three egals: === === === + | ^^^^^ + | +error: `modul` should be `module` + --> ./sample.jl:5:5 + | +5 | var modul = \"hello\"; + | ^^^^^ + | +error: `usig` should be `using` + --> ./sample.jl:6:5 + | +6 | var usig = \"hello\"; + | ^^^^ + | +""" stderr = "" +status.code = 2 From a640285093ce104a954f410670b90acf1b73c576 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Oct 2023 20:50:39 -0500 Subject: [PATCH 4/5] fix(dict): Match .jl to Julia, rather than lisp --- crates/typos-cli/src/default_types.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/typos-cli/src/default_types.rs b/crates/typos-cli/src/default_types.rs index e64b1a5..b869bb4 100644 --- a/crates/typos-cli/src/default_types.rs +++ b/crates/typos-cli/src/default_types.rs @@ -112,7 +112,6 @@ pub const DEFAULT_TYPES: &[(&str, &[&str])] = &[ ("js", &["*.js", "*.jsx", "*.vue"]), ("json", &["*.json"]), ("jsonl", &["*.jsonl"]), - ("julia", &["*.jl"]), ("jupyter", &["*.ipynb", "*.jpynb"]), ("k", &["*.k"]), ("kotlin", &["*.kt", "*.kts"]), @@ -145,7 +144,7 @@ pub const DEFAULT_TYPES: &[(&str, &[&str])] = &[ "OFL-*[0-9]*", ]), ("lilypond", &["*.ly", "*.ily"]), - ("lisp", &["*.el", "*.jl", "*.lisp", "*.lsp", "*.sc", "*.scm"]), + ("lisp", &["*.el", "*.lisp", "*.lsp", "*.sc", "*.scm"]), ("lock", &["*.lock", "package-lock.json", "requirements.txt", "go.sum", "pnpm-lock.yaml"]), ("log", &["*.log"]), ("lua", &["*.lua"]), From b2685877d27a02ad65fd45470f5f8e85bfa9ce54 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Oct 2023 20:51:12 -0500 Subject: [PATCH 5/5] fix(dict): Dont correct common Julia terms --- crates/typos-cli/src/file_type_specifics.rs | 12 ++++++++ .../typos-cli/tests/cmd/false-positives.toml | 28 +------------------ 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/crates/typos-cli/src/file_type_specifics.rs b/crates/typos-cli/src/file_type_specifics.rs index 273a250..3a69e0f 100644 --- a/crates/typos-cli/src/file_type_specifics.rs +++ b/crates/typos-cli/src/file_type_specifics.rs @@ -16,6 +16,18 @@ pub const TYPE_SPECIFIC_DICTS: &[(&str, StaticDictConfig)] = &[ ignore_words: &[], }, ), + ( + "jl", + StaticDictConfig { + ignore_idents: &[], + ignore_words: &[ + "egal", // name for `===` operator + "egals", // name for `===` operator + "modul", // stand-in for `module` when needing to avoid the keyword + "usig", // stand-in for `using` when needing to avoid the keyword + ], + }, + ), ( "man", StaticDictConfig { diff --git a/crates/typos-cli/tests/cmd/false-positives.toml b/crates/typos-cli/tests/cmd/false-positives.toml index 41e44a3..324f41d 100644 --- a/crates/typos-cli/tests/cmd/false-positives.toml +++ b/crates/typos-cli/tests/cmd/false-positives.toml @@ -1,30 +1,4 @@ bin.name = "typos" stdin = "" -stdout = """ -error: `egal` should be `equal` - --> ./sample.jl:1:7 - | -1 | # one egal: === - | ^^^^ - | -error: `egals` should be `equals` - --> ./sample.jl:2:9 - | -2 | # three egals: === === === - | ^^^^^ - | -error: `modul` should be `module` - --> ./sample.jl:5:5 - | -5 | var modul = \"hello\"; - | ^^^^^ - | -error: `usig` should be `using` - --> ./sample.jl:6:5 - | -6 | var usig = \"hello\"; - | ^^^^ - | -""" +stdout = "" stderr = "" -status.code = 2