mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-23 08:02:15 -05:00
Merge pull request #694 from epage/fix
fix: Actuall ignore ignored identifiers
This commit is contained in:
commit
1aefbee825
23 changed files with 176 additions and 75 deletions
|
@ -249,7 +249,7 @@ impl<'i, 'w, D: typos::Dictionary> typos::Dictionary for Override<'i, 'w, D> {
|
||||||
fn correct_ident<'s, 't>(&'s self, ident: typos::tokens::Identifier<'t>) -> Option<Status<'s>> {
|
fn correct_ident<'s, 't>(&'s self, ident: typos::tokens::Identifier<'t>) -> Option<Status<'s>> {
|
||||||
for ignored in &self.ignored_identifiers {
|
for ignored in &self.ignored_identifiers {
|
||||||
if ignored.is_match(ident.token()) {
|
if ignored.is_match(ident.token()) {
|
||||||
return None;
|
return Some(Status::Valid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,6 +239,7 @@ impl<'s> ConfigEngine<'s> {
|
||||||
|
|
||||||
let dict = crate::dict::BuiltIn::new(dict_config.locale());
|
let dict = crate::dict::BuiltIn::new(dict_config.locale());
|
||||||
let mut dict = crate::dict::Override::new(dict);
|
let mut dict = crate::dict::Override::new(dict);
|
||||||
|
dict.ignored_identifiers(dict_config.extend_ignore_identifiers_re());
|
||||||
dict.identifiers(
|
dict.identifiers(
|
||||||
dict_config
|
dict_config
|
||||||
.extend_identifiers()
|
.extend_identifiers()
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
bin.name = "typos"
|
bin.name = "typos"
|
||||||
status.code = 2
|
status.code = 2
|
||||||
|
stdin = ""
|
||||||
|
stderr = ""
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
\n\n
|
|
||||||
Destory
|
|
|
@ -1,2 +0,0 @@
|
||||||
\n\n
|
|
||||||
Destroy
|
|
|
@ -1,3 +1,12 @@
|
||||||
bin.name = "typos"
|
bin.name = "typos"
|
||||||
args = "--write-changes -"
|
args = "--write-changes -"
|
||||||
status.code = 0
|
status.code = 0
|
||||||
|
stdin = '''
|
||||||
|
\n\n
|
||||||
|
Destory
|
||||||
|
'''
|
||||||
|
stdout = """
|
||||||
|
/n/n
|
||||||
|
Destroy
|
||||||
|
"""
|
||||||
|
stderr = ""
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
[files]
|
||||||
|
extend-exclude = ["_typos.toml"]
|
||||||
|
|
||||||
|
[default.extend-identifiers]
|
||||||
|
hello = "goodbye"
|
||||||
|
|
||||||
|
[type.fail]
|
||||||
|
extend-glob = ["*.fail"]
|
||||||
|
|
||||||
|
[type.ignore]
|
||||||
|
extend-glob = ["*.ignore"]
|
||||||
|
extend-ignore-identifiers-re = ["he.*"]
|
|
@ -0,0 +1 @@
|
||||||
|
hello
|
|
@ -0,0 +1 @@
|
||||||
|
hello
|
12
crates/typos-cli/tests/cmd/extend-ignore-identifiers-re.toml
Normal file
12
crates/typos-cli/tests/cmd/extend-ignore-identifiers-re.toml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
bin.name = "typos"
|
||||||
|
status.code = 2
|
||||||
|
stdin = ""
|
||||||
|
stdout = """
|
||||||
|
error: `hello` should be `goodbye`
|
||||||
|
--> ./file.fail:1:1
|
||||||
|
|
|
||||||
|
1 | hello
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
"""
|
||||||
|
stderr = ""
|
|
@ -1,3 +1,43 @@
|
||||||
bin.name = "typos"
|
bin.name = "typos"
|
||||||
args = "../../README.md"
|
args = "../../README.md"
|
||||||
status.code = 2
|
status.code = 2
|
||||||
|
stdin = ""
|
||||||
|
stdout = """
|
||||||
|
error: `Supress` should be `Suppress`
|
||||||
|
--> ../../README.md:78:19
|
||||||
|
|
|
||||||
|
78 | \"AttributeID.*Supress.*\",
|
||||||
|
| ^^^^^^^
|
||||||
|
|
|
||||||
|
error: `Supress` should be `Suppress`
|
||||||
|
--> ../../README.md:83:12
|
||||||
|
|
|
||||||
|
83 | AttributeIDSupressMenu = \"AttributeIDSupressMenu\"
|
||||||
|
| ^^^^^^^
|
||||||
|
|
|
||||||
|
error: `Supress` should be `Suppress`
|
||||||
|
--> ../../README.md:83:38
|
||||||
|
|
|
||||||
|
83 | AttributeIDSupressMenu = \"AttributeIDSupressMenu\"
|
||||||
|
| ^^^^^^^
|
||||||
|
|
|
||||||
|
error: `Teh` should be `The`
|
||||||
|
--> ../../README.md:86:30
|
||||||
|
|
|
||||||
|
86 | # Don't correct the surname \"Teh\"
|
||||||
|
| ^^^
|
||||||
|
|
|
||||||
|
error: `teh` should be `the`
|
||||||
|
--> ../../README.md:87:1
|
||||||
|
|
|
||||||
|
87 | teh = \"teh\"
|
||||||
|
| ^^^
|
||||||
|
|
|
||||||
|
error: `teh` should be `the`
|
||||||
|
--> ../../README.md:87:8
|
||||||
|
|
|
||||||
|
87 | teh = \"teh\"
|
||||||
|
| ^^^
|
||||||
|
|
|
||||||
|
"""
|
||||||
|
stderr = ""
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
bin.name = "typos"
|
bin.name = "typos"
|
||||||
args = "."
|
args = "."
|
||||||
status.code = 2
|
status.code = 2
|
||||||
|
stdin = ""
|
||||||
|
stderr = ""
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Apropriate world
|
|
|
@ -1 +0,0 @@
|
||||||
Appropriate world
|
|
|
@ -1,2 +1,9 @@
|
||||||
bin.name = "typos"
|
bin.name = "typos"
|
||||||
args = "--write-changes -"
|
args = "--write-changes -"
|
||||||
|
stdin = '''
|
||||||
|
Apropriate world
|
||||||
|
'''
|
||||||
|
stdout = """
|
||||||
|
Appropriate world
|
||||||
|
"""
|
||||||
|
stderr = ""
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
---
|
|
||||||
Korean character (NFC)
|
|
||||||
Grapheme clusters: 1, codepoints: 1, UnicodeWidthStr::width() == 2
|
|
||||||
|
|
||||||
한 Apropriate world
|
|
||||||
^^^^^^^^^^ highlight here
|
|
||||||
|
|
||||||
---
|
|
||||||
Korean character (NFD).
|
|
||||||
Grapheme clusters: 1, codepoints: 3, UnicodeWidthStr::width() == 2
|
|
||||||
|
|
||||||
한 Apropriate world
|
|
||||||
^^^^^^^^^^ highlight here
|
|
||||||
|
|
||||||
---
|
|
||||||
Eye in Speech Bubble Emoji (U+1F441 U+FE0F U+200D U+1F5E8 U+FE0F, Recommended Emoji ZWJ Sequences, v2.0)
|
|
||||||
Grapheme clusters: 1, codepoints: 5, UnicodeWidthStr::width() == 2 (Read NOTE: https://github.com/unicode-rs/unicode-width)
|
|
||||||
|
|
||||||
👁️🗨️ Apropriate world
|
|
||||||
^^^^^^^^^^ highlight here
|
|
||||||
|
|
||||||
---
|
|
||||||
Face with spiral eyes (U+1F635 U+200D U+1F4AB, Recommended Emoji ZWJ Sequence, v13.1)
|
|
||||||
Grapheme clusters: 1, codepoints: 3, UnicodeWidthStr::width() == 4 (Read NOTE: https://github.com/unicode-rs/unicode-width)
|
|
||||||
|
|
||||||
😵💫 Apropriate world
|
|
||||||
^^^^^^^^^^ highlight here
|
|
||||||
|
|
||||||
---
|
|
||||||
Horizontal tab (\t, U+09)
|
|
||||||
Grapheme clusters: 1, codepoints: 1, UnicodeWidthStr::width() == 0
|
|
||||||
|
|
||||||
Apropriate world
|
|
||||||
^^^^^^^^^^ highlight here
|
|
|
@ -1,30 +0,0 @@
|
||||||
error: `Apropriate` should be `Appropriate`
|
|
||||||
--> -:5:3
|
|
||||||
|
|
|
||||||
5 | 한 Apropriate world
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
|
||||||
error: `Apropriate` should be `Appropriate`
|
|
||||||
--> -:12:3
|
|
||||||
|
|
|
||||||
12 | 한 Apropriate world
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
|
||||||
error: `Apropriate` should be `Appropriate`
|
|
||||||
--> -:19:3
|
|
||||||
|
|
|
||||||
19 | 👁️🗨️ Apropriate world
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
|
||||||
error: `Apropriate` should be `Appropriate`
|
|
||||||
--> -:26:3
|
|
||||||
|
|
|
||||||
26 | 😵💫 Apropriate world
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
|
||||||
error: `Apropriate` should be `Appropriate`
|
|
||||||
--> -:33:2
|
|
||||||
|
|
|
||||||
33 | Apropriate world
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
|
|
@ -1,3 +1,72 @@
|
||||||
bin.name = "typos"
|
bin.name = "typos"
|
||||||
args = "-"
|
args = "-"
|
||||||
status.code = 2
|
status.code = 2
|
||||||
|
stdin = '''
|
||||||
|
---
|
||||||
|
Korean character (NFC)
|
||||||
|
Grapheme clusters: 1, codepoints: 1, UnicodeWidthStr::width() == 2
|
||||||
|
|
||||||
|
한 Apropriate world
|
||||||
|
^^^^^^^^^^ highlight here
|
||||||
|
|
||||||
|
---
|
||||||
|
Korean character (NFD).
|
||||||
|
Grapheme clusters: 1, codepoints: 3, UnicodeWidthStr::width() == 2
|
||||||
|
|
||||||
|
한 Apropriate world
|
||||||
|
^^^^^^^^^^ highlight here
|
||||||
|
|
||||||
|
---
|
||||||
|
Eye in Speech Bubble Emoji (U+1F441 U+FE0F U+200D U+1F5E8 U+FE0F, Recommended Emoji ZWJ Sequences, v2.0)
|
||||||
|
Grapheme clusters: 1, codepoints: 5, UnicodeWidthStr::width() == 2 (Read NOTE: https://github.com/unicode-rs/unicode-width)
|
||||||
|
|
||||||
|
👁️🗨️ Apropriate world
|
||||||
|
^^^^^^^^^^ highlight here
|
||||||
|
|
||||||
|
---
|
||||||
|
Face with spiral eyes (U+1F635 U+200D U+1F4AB, Recommended Emoji ZWJ Sequence, v13.1)
|
||||||
|
Grapheme clusters: 1, codepoints: 3, UnicodeWidthStr::width() == 4 (Read NOTE: https://github.com/unicode-rs/unicode-width)
|
||||||
|
|
||||||
|
😵💫 Apropriate world
|
||||||
|
^^^^^^^^^^ highlight here
|
||||||
|
|
||||||
|
---
|
||||||
|
Horizontal tab (\t, U+09)
|
||||||
|
Grapheme clusters: 1, codepoints: 1, UnicodeWidthStr::width() == 0
|
||||||
|
|
||||||
|
Apropriate world
|
||||||
|
^^^^^^^^^^ highlight here
|
||||||
|
'''
|
||||||
|
stdout = """
|
||||||
|
error: `Apropriate` should be `Appropriate`
|
||||||
|
--> -:5:3
|
||||||
|
|
|
||||||
|
5 | 한 Apropriate world
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
error: `Apropriate` should be `Appropriate`
|
||||||
|
--> -:12:3
|
||||||
|
|
|
||||||
|
12 | 한 Apropriate world
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
error: `Apropriate` should be `Appropriate`
|
||||||
|
--> -:19:3
|
||||||
|
|
|
||||||
|
19 | 👁️🗨️ Apropriate world
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
error: `Apropriate` should be `Appropriate`
|
||||||
|
--> -:26:3
|
||||||
|
|
|
||||||
|
26 | 😵💫 Apropriate world
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
error: `Apropriate` should be `Appropriate`
|
||||||
|
--> -:33:2
|
||||||
|
|
|
||||||
|
33 | Apropriate world
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
"""
|
||||||
|
stderr = ""
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Apropriate world
|
|
|
@ -1,3 +1,15 @@
|
||||||
bin.name = "typos"
|
bin.name = "typos"
|
||||||
args = "-"
|
args = "-"
|
||||||
status.code = 2
|
status.code = 2
|
||||||
|
stdin = '''
|
||||||
|
Apropriate world
|
||||||
|
'''
|
||||||
|
stdout = """
|
||||||
|
error: `Apropriate` should be `Appropriate`
|
||||||
|
--> -:1:1
|
||||||
|
|
|
||||||
|
1 | Apropriate world
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
"""
|
||||||
|
stderr = ""
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
Hello world
|
|
|
@ -1,2 +1,7 @@
|
||||||
bin.name = "typos"
|
bin.name = "typos"
|
||||||
args = "-"
|
args = "-"
|
||||||
|
stdin = '''
|
||||||
|
Hello world
|
||||||
|
'''
|
||||||
|
stdout = ""
|
||||||
|
stderr = ""
|
||||||
|
|
|
@ -31,4 +31,4 @@ Configuration is read from the following (in precedence order)
|
||||||
| default.extend-ignore-identifiers-re | \- | list of [regexes](https://docs.rs/regex/latest/regex/index.html#syntax) | Pattern-match always-valid identifiers |
|
| default.extend-ignore-identifiers-re | \- | list of [regexes](https://docs.rs/regex/latest/regex/index.html#syntax) | Pattern-match always-valid identifiers |
|
||||||
| default.extend-words | \- | table of strings | Corrections for [words](./design.md#identifiers-and-words). When the correction is blank, the word is never valid. When the correction is the key, the word is always valid. |
|
| default.extend-words | \- | table of strings | Corrections for [words](./design.md#identifiers-and-words). When the correction is blank, the word is never valid. When the correction is the key, the word is always valid. |
|
||||||
| type.\<name>.\<field> | \<varied> | \<varied> | See `default.` for child keys. Run with `--type-list` to see available `<name>`s |
|
| type.\<name>.\<field> | \<varied> | \<varied> | See `default.` for child keys. Run with `--type-list` to see available `<name>`s |
|
||||||
| type.\<name>.extend_globs | \- | list of strings | File globs for matching `<name>` |
|
| type.\<name>.extend-glob | \- | list of strings | File globs for matching `<name>` |
|
||||||
|
|
Loading…
Reference in a new issue