diff --git a/_typos.toml b/_typos.toml index 1d27e1e..583ebdb 100755 --- a/_typos.toml +++ b/_typos.toml @@ -30,17 +30,23 @@ extend-ignore-identifiers-re = [ "prev", "normalises", "goes", + "Bare", "inout", "ba", "ede", - "Bare", ] +[default.extend-words] +Bare = "Bare" +Supress = "Supress" +teh = "teh" +Teh = "Teh" + [files] ignore-hidden = false ignore-files = true extend-exclude = [ - "./CHANGELOG.md", + "CHANGELOG.md", "/usr/**/*", "/tmp/**/*", "/**/node_modules/**", diff --git a/crates/language/src/lib.rs b/crates/language/src/lib.rs index 7709c0e..721ddd6 100644 --- a/crates/language/src/lib.rs +++ b/crates/language/src/lib.rs @@ -1721,17 +1721,17 @@ pub fn from_extension(path: &Path) -> Option { } // Handle extensionless files or files with unknown extensions - if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) { + if let Some(_file_name) = path.file_name().and_then(|n| n.to_str()) { // 1. Check if the full filename matches a known extension (e.g. .bashrc) #[cfg(any(feature = "bash", feature = "all-parsers"))] - if constants::BASH_EXTS.contains(&file_name) { + if constants::BASH_EXTS.contains(&_file_name) { return Some(SupportLang::Bash); } // 2. Check known extensionless file names #[cfg(any(feature = "bash", feature = "all-parsers", feature = "ruby"))] for (name, lang) in constants::LANG_RELATIONSHIPS_WITH_NO_EXTENSION { - if *name == file_name { + if *name == _file_name { return Some(*lang); } } diff --git a/crates/rule-engine/src/transform/trans.rs b/crates/rule-engine/src/transform/trans.rs index 0a80a89..cdf0f1e 100644 --- a/crates/rule-engine/src/transform/trans.rs +++ b/crates/rule-engine/src/transform/trans.rs @@ -551,5 +551,26 @@ if (true) { Ok(()) } - // TODO: add a symbolic test for Rewrite + #[test] + fn test_rewrite() -> R { + let trans = parse( + r#" + rewrite: + source: "$A" + rewriters: ["re1", "re2"] + joinBy: ", " + "#, + )?; + let parsed = trans.parse(&TypeScript::Tsx).expect("should parse"); + match &parsed { + Trans::Rewrite(r) => { + assert_eq!(r.rewriters, vec!["re1", "re2"]); + assert_eq!(r.join_by, Some(", ".to_string())); + } + _ => panic!("should be rewrite"), + } + assert_eq!(parsed.used_rewriters(), &["re1", "re2"]); + assert_eq!(parsed.used_vars(), "A"); + Ok(()) + } }