wowlab_tidy/languages/toml/rules/
ambiguous_unicode.rs1use crate::{Example, TomlCtx, Violation, languages::unicode::ambiguous_unicode_violations};
2
3#[rustfmt::skip]
4const EXAMPLES: &[Example] = &[
5 Example { label: "ambiguous punctuation in comment", code: "# range 1\u{2013}5\nvalue = 1\n", pass: false },
6 Example { label: "homoglyph in string", code: "name = \"p\u{0430}ssword\"\n", pass: false },
7 Example { label: "normal ASCII", code: "# range 1-5\nvalue = 1\n", pass: true },
8 Example { label: "unambiguous non-ASCII", code: "# r\u{00E9}sum\u{00E9}\nvalue = 1\n", pass: true },
9];
10
11crate::toml_rule!(
12 toml_ambiguous_unicode,
13 "Ban Unicode characters in TOML that are visually confusable with ASCII.",
14 "Confusable punctuation and homoglyphs make manifest comments and values easy to misread.",
15 High,
16);
17
18fn check_toml_ambiguous_unicode(ctx: &TomlCtx<'_>) -> Vec<Violation> {
19 ambiguous_unicode_violations(ctx.file)
20}
21
22crate::tidy_toml_test!(check_toml_ambiguous_unicode, {
23 crate::example_tests!(EXAMPLES, check_toml_ambiguous_unicode);
24});